diff options
author | Tor Norbye <tnorbye@google.com> | 2011-12-19 15:35:24 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-12-19 15:35:24 -0800 |
commit | 60ba30f8a2d4a059437fad141d73e81bfef3a625 (patch) | |
tree | a440ef6ba2c065677fc29b4bb55703c510c2b5a9 | |
parent | aeac6ced11a0d0544c55973f29e32a028e8c406e (diff) | |
parent | 941a503ab45b455aabe270f68ed14e0ecab870dc (diff) | |
download | sdk-60ba30f8a2d4a059437fad141d73e81bfef3a625.zip sdk-60ba30f8a2d4a059437fad141d73e81bfef3a625.tar.gz sdk-60ba30f8a2d4a059437fad141d73e81bfef3a625.tar.bz2 |
Merge "Fix issue 23022: Preview rendering breaks some widgets"
3 files changed, 31 insertions, 16 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/DomUtilities.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/DomUtilities.java index e44fe90..47790de 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/DomUtilities.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/DomUtilities.java @@ -759,8 +759,7 @@ public class DomUtilities { * @return the structured model */ public static IStructuredModel createStructuredModel(String xml) { - IModelManager modelManager = StructuredModelManager.getModelManager(); - IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeID_XML); + IStructuredModel model = createEmptyModel(); IStructuredDocument document = model.getStructuredDocument(); model.aboutToChangeModel(); document.set(xml); @@ -770,6 +769,31 @@ public class DomUtilities { } /** + * Creates an empty Eclipse XML model + * + * @return a new Eclipse XML model + */ + public static IStructuredModel createEmptyModel() { + IModelManager modelManager = StructuredModelManager.getModelManager(); + return modelManager.createUnManagedStructuredModelFor(ContentTypeID_XML); + } + + /** + * Creates an empty Eclipse XML document + * + * @return an empty Eclipse XML document + */ + public static Document createEmptyDocument() { + IStructuredModel model = createEmptyModel(); + if (model instanceof IDOMModel) { + IDOMModel domModel = (IDOMModel) model; + return domModel.getDocument(); + } + + return null; + } + + /** * Parses the given XML string as a DOM document, using the JDK parser. * The parser does not validate, and is namespace aware. * diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java index 65f717a..36fdda4 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java @@ -109,10 +109,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - /** * A palette control for the {@link GraphicalEditorPart}. * <p/> @@ -892,16 +888,7 @@ public class PaletteControl extends Composite { } // Create blank XML document - Document document = null; - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - factory.setNamespaceAware(true); - factory.setValidating(false); - DocumentBuilder builder = factory.newDocumentBuilder(); - document = builder.newDocument(); - } catch (ParserConfigurationException e) { - return null; - } + Document document = DomUtilities.createEmptyDocument(); // Insert our target view's XML into it as a node GraphicalEditorPart editor = getEditor(); @@ -964,6 +951,9 @@ public class PaletteControl extends Composite { try { canvas.getRulesEngine().callCreateHooks(layoutEditor, null, childNode, InsertType.CREATE_PREVIEW); + childNode.applyPendingChanges(); + } catch (Throwable t) { + AdtPlugin.log(t, "Failed calling creation hooks for widget %1$s", viewName); } finally { layoutEditor.setIgnoreXmlUpdate(false); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/extra-view-metadata.xml b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/extra-view-metadata.xml index f80fa60..8563a06 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/extra-view-metadata.xml +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/extra-view-metadata.xml @@ -262,6 +262,7 @@ render="skip" /> <view class="android.widget.SlidingDrawer" + render="skip" topAttrs="allowSingleTap,bottomOffset,content,handle,topOffset,visibility" /> <view class="android.widget.TabHost" |