aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2010-11-22 09:58:06 -0800
committerTor Norbye <tnorbye@google.com>2010-11-22 11:11:53 -0800
commitc4f75630aa293ec4027216ae0bfd2d9e6782e209 (patch)
tree9f849640ab63ffd637bd4bcd6fb08d7f23127d24 /eclipse/plugins
parent476a6e18ba87159b34fabb8a0bd73abb804c5079 (diff)
downloadsdk-c4f75630aa293ec4027216ae0bfd2d9e6782e209.zip
sdk-c4f75630aa293ec4027216ae0bfd2d9e6782e209.tar.gz
sdk-c4f75630aa293ec4027216ae0bfd2d9e6782e209.tar.bz2
Fix live manipulation of <include> elements
This changeset fixes bugs related to dragging included views around in the canvas: First, the <include> tag would get rewritten to <null>. This happened because the layout editor treats the FQCN and the XML node name as equivalent, but in the case of the include tag the FQCN was set to null instead of "include". Second, the "layout" attribute would not get copied because it is NOT in the Android namespace, and the code to copy attributes ended up with an empty-string namespace which was not handled correctly. Third, when copied the "layout" attribute would end up with the namespace "ns:" because the code to create attribute nodes always created namespaced attribute nodes rather than a plain attribute node when the namespace is null. Change-Id: Ibd34212517615aa8ec79abe14bca765cdca525f6
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java26
2 files changed, 23 insertions, 5 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java
index 500c8ba..2021533 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/LayoutDescriptors.java
@@ -314,7 +314,7 @@ public final class LayoutDescriptors implements IDescriptorProvider {
// Create the include descriptor
ViewElementDescriptor desc = new ViewElementDescriptor(xml_name, // xml_name
xml_name, // ui_name
- null, // canonical class name, we don't have one
+ VIEW_INCLUDE, // "class name"; the GLE only treats this as an element tag
"Lets you statically include XML layouts inside other XML layouts.", // tooltip
null, // sdk_url
attributes.toArray(new AttributeDescriptor[attributes.size()]),
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
index a78da12..b57901f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
@@ -1370,10 +1370,16 @@ public class UiElementNode implements IPropertySource {
// Add or replace an attribute
Document doc = element.getOwnerDocument();
if (doc != null) {
- Attr attr = doc.createAttributeNS(attrNsUri, attrLocalName);
+ Attr attr;
+ if (attrNsUri != null && attrNsUri.length() > 0) {
+ attr = doc.createAttributeNS(attrNsUri, attrLocalName);
+ attr.setPrefix(lookupNamespacePrefix(element, attrNsUri));
+ attrMap.setNamedItemNS(attr);
+ } else {
+ attr = doc.createAttribute(attrLocalName);
+ attrMap.setNamedItem(attr);
+ }
attr.setValue(newValue);
- attr.setPrefix(lookupNamespacePrefix(element, attrNsUri));
- attrMap.setNamedItemNS(attr);
return true;
}
}
@@ -1529,8 +1535,11 @@ public class UiElementNode implements IPropertySource {
// Try with all internal attributes
UiAttributeNode uiAttr = setInternalAttrValue(
getInternalUiAttributes().values(), attrXmlName, attrNsUri, value, override);
+ if (uiAttr != null) {
+ return uiAttr;
+ }
- // Look at existing unknown (aka custom) attributes
+ // Look at existing unknown (a.k.a. custom) attributes
uiAttr = setInternalAttrValue(
getUnknownUiAttributes(), attrXmlName, attrNsUri, value, override);
@@ -1539,6 +1548,7 @@ public class UiElementNode implements IPropertySource {
// in which case we just create a new custom one.
uiAttr = addUnknownAttribute(attrXmlName, attrXmlName, attrNsUri);
+ // FIXME: The will create the attribute, but not actually set the value on it...
}
return uiAttr;
@@ -1550,6 +1560,14 @@ public class UiElementNode implements IPropertySource {
String attrNsUri,
String value,
boolean override) {
+
+ // For namespace less attributes (like the "layout" attribute of an <include> tag
+ // we may be passed "" as the namespace (during an attribute copy), and it
+ // should really be null instead.
+ if (attrNsUri != null && attrNsUri.length() == 0) {
+ attrNsUri = null;
+ }
+
for (UiAttributeNode uiAttr : attributes) {
AttributeDescriptor uiDesc = uiAttr.getDescriptor();