package com.android.ide.eclipse.adt.internal.editors.descriptors;
+import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
import static com.android.ide.common.layout.LayoutConstants.ATTR_ID;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_BELOW;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
false /* override */);
}
- // Don't set default text value into edit texts - they typically start out blank
- if (!descriptor.getXmlLocalName().equals(EDIT_TEXT)) {
+ // Set a text attribute on textual widgets -- but only on those that define a text
+ // attribute
+ if (descriptor.definesAttribute(ANDROID_URI, ATTR_TEXT)
+ // Don't set default text value into edit texts - they typically start out blank
+ && !descriptor.getXmlLocalName().equals(EDIT_TEXT)) {
String type = getBasename(descriptor.getUiName());
node.setAttributeValue(
ATTR_TEXT,
return new String(c).replace("-", " "); //$NON-NLS-1$ //$NON-NLS-2$
}
+ /**
+ * Returns true if this node defines the given attribute
+ *
+ * @param namespaceUri the namespace URI of the target attribute
+ * @param attributeName the attribute name
+ * @return true if this element defines an attribute of the given name and namespace
+ */
+ public boolean definesAttribute(String namespaceUri, String attributeName) {
+ for (AttributeDescriptor desc : mAttributes) {
+ if (desc.getXmlLocalName().equals(attributeName) &&
+ desc.getNamespaceUri().equals(namespaceUri)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
// Implements Comparable<ElementDescriptor>:
public int compareTo(ElementDescriptor o) {
return mUiName.compareToIgnoreCase(o.mUiName);