diff options
23 files changed, 278 insertions, 234 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorDescriptors.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorDescriptors.java index 9afeb88..2c1923e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorDescriptors.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorDescriptors.java @@ -76,18 +76,18 @@ public class ColorDescriptors implements IDescriptorProvider { + "its attributes. Must be a child of a <selector> element.", SDK_URL, new ReferenceAttributeDescriptor( - ResourceType.COLOR, ATTR_COLOR, ATTR_COLOR, + ResourceType.COLOR, ATTR_COLOR, SdkConstants.NS_RESOURCES, - "Hexadeximal color. Required. The color is specified with an RGB value and " - + "optional alpha channel.\n" - + "The value always begins with a pound (#) character and then " - + "followed by the Alpha-Red-Green-Blue information in one of " - + "the following formats:\n" - + "* RGB\n" - + "* ARGB\n" - + "* RRGGBB\n" - + "* AARRGGBB", - new AttributeInfo("drawable", new Format[] { Format.COLOR })), + new AttributeInfo(ATTR_COLOR, new Format[] { Format.COLOR })).setTooltip( + "Hexadeximal color. Required. The color is specified with an RGB value and " + + "optional alpha channel.\n" + + "The value always begins with a pound (#) character and then " + + "followed by the Alpha-Red-Green-Blue information in one of " + + "the following formats:\n" + + "* RGB\n" + + "* ARGB\n" + + "* RRGGBB\n" + + "* AARRGGBB"), null, /* This is wrong -- we can now embed any above drawable (but without xmlns as extra) */ false /*mandatory*/); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/BooleanAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/BooleanAttributeDescriptor.java index f1def39..7d76687 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/BooleanAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/BooleanAttributeDescriptor.java @@ -26,9 +26,8 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiListAttributeNode; public class BooleanAttributeDescriptor extends ListAttributeDescriptor { private static final String[] VALUES = new String[] { "true", "false" }; //$NON-NLS-1$ //$NON-NLS-2$ - public BooleanAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo, VALUES); + public BooleanAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo, VALUES); } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java index f44faf4..ce8e3b1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java @@ -51,6 +51,7 @@ import com.android.sdklib.SdkConstants; import org.eclipse.swt.graphics.Image; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; import java.util.Locale; import java.util.Map; @@ -64,7 +65,6 @@ import java.util.regex.Pattern; * Utility methods related to descriptors handling. */ public final class DescriptorsUtils { - private static final String DEFAULT_WIDGET_PREFIX = "widget"; private static final int JAVADOC_BREAK_LENGTH = 60; @@ -135,74 +135,21 @@ public final class DescriptorsUtils { String nsUri, AttributeInfo info, boolean required, Map<String, ITextAttributeCreator> overrides) { - AttributeDescriptor attr = null; + TextAttributeDescriptor attr = null; String xmlLocalName = info.getName(); - String uiName = prettyAttributeUiName(info.getName()); // ui_name - if (required) { - uiName += "*"; //$NON-NLS-1$ - } - - String tooltip = null; - String rawTooltip = info.getJavaDoc(); - if (rawTooltip == null) { - rawTooltip = ""; - } - - String deprecated = info.getDeprecatedDoc(); - if (deprecated != null) { - if (rawTooltip.length() > 0) { - rawTooltip += "@@"; //$NON-NLS-1$ insert a break - } - rawTooltip += "* Deprecated"; - if (deprecated.length() != 0) { - rawTooltip += ": " + deprecated; //$NON-NLS-1$ - } - if (deprecated.length() == 0 || !deprecated.endsWith(".")) { //$NON-NLS-1$ - rawTooltip += "."; //$NON-NLS-1$ - } - } // Add the known types to the tooltip Format[] formats_list = info.getFormats(); int flen = formats_list.length; if (flen > 0) { // Fill the formats in a set for faster access - HashSet<Format> formats_set = new HashSet<Format>(); - - StringBuilder sb = new StringBuilder(); - if (rawTooltip != null && rawTooltip.length() > 0) { - sb.append(rawTooltip); - sb.append(" "); //$NON-NLS-1$ - } - if (sb.length() > 0) { - sb.append("@@"); //$NON-NLS-1$ @@ inserts a break before the types - } - sb.append("["); //$NON-NLS-1$ + EnumSet<Format> formats_set = EnumSet.noneOf(Format.class); for (int i = 0; i < flen; i++) { Format f = formats_list[i]; formats_set.add(f); - - sb.append(f.toString().toLowerCase(Locale.US)); - if (i < flen - 1) { - sb.append(", "); //$NON-NLS-1$ - } - } - // The extra space at the end makes the tooltip more readable on Windows. - sb.append("]"); //$NON-NLS-1$ - - if (required) { - // Note: this string is split in 2 to make it translatable. - sb.append(".@@"); //$NON-NLS-1$ @@ inserts a break and is not translatable - sb.append("* Required."); } - // The extra space at the end makes the tooltip more readable on Windows. - sb.append(" "); //$NON-NLS-1$ - - rawTooltip = sb.toString(); - tooltip = formatTooltip(rawTooltip); - // Create a specialized attribute if we can if (overrides != null) { for (Entry<String, ITextAttributeCreator> entry: overrides.entrySet()) { @@ -245,7 +192,7 @@ public final class DescriptorsUtils { ITextAttributeCreator override = entry.getValue(); if (override != null) { - attr = override.create(xmlLocalName, uiName, nsUri, tooltip, info); + attr = override.create(xmlLocalName, nsUri, info); } } } // if overrides @@ -255,30 +202,32 @@ public final class DescriptorsUtils { if (formats_set.contains(Format.REFERENCE)) { // This is either a multi-type reference or a generic reference. attr = new ReferenceAttributeDescriptor( - xmlLocalName, uiName, nsUri, tooltip, info); + xmlLocalName, nsUri, info); } else if (formats_set.contains(Format.ENUM)) { attr = new ListAttributeDescriptor( - xmlLocalName, uiName, nsUri, tooltip, info); + xmlLocalName, nsUri, info); } else if (formats_set.contains(Format.FLAG)) { attr = new FlagAttributeDescriptor( - xmlLocalName, uiName, nsUri, tooltip, info); + xmlLocalName, nsUri, info); } else if (formats_set.contains(Format.BOOLEAN)) { attr = new BooleanAttributeDescriptor( - xmlLocalName, uiName, nsUri, tooltip, info); + xmlLocalName, nsUri, info); } else if (formats_set.contains(Format.STRING)) { attr = new ReferenceAttributeDescriptor( - ResourceType.STRING, xmlLocalName, uiName, nsUri, tooltip, info); + ResourceType.STRING, xmlLocalName, nsUri, info); } } } // By default a simple text field is used if (attr == null) { - if (tooltip == null) { - tooltip = formatTooltip(rawTooltip); - } - attr = new TextAttributeDescriptor(xmlLocalName, uiName, nsUri, tooltip, info); + attr = new TextAttributeDescriptor(xmlLocalName, nsUri, info); } + + if (required) { + attr.setRequired(true); + } + attributes.add(attr); } @@ -320,25 +269,25 @@ public final class DescriptorsUtils { if (name.length() < 1) { return name; } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(2 * name.length()); char c = name.charAt(0); // Use upper case initial letter - buf.append((char)(c >= 'a' && c <= 'z' ? c + 'A' - 'a' : c)); + buf.append(Character.toUpperCase(c)); int len = name.length(); for (int i = 1; i < len; i++) { c = name.charAt(i); - if (c >= 'A' && c <= 'Z') { + if (Character.isUpperCase(c)) { // Break camel case into separate words buf.append(' '); // Use a lower case initial letter for the next word, except if the // word is solely X, Y or Z. if (c >= 'X' && c <= 'Z' && (i == len-1 || - (i < len-1 && name.charAt(i+1) >= 'A' && name.charAt(i+1) <= 'Z'))) { + (i < len-1 && Character.isUpperCase(name.charAt(i+1))))) { buf.append(c); } else { - buf.append((char)(c - 'A' + 'a')); + buf.append(Character.toLowerCase(c)); } } else if (c == '_') { buf.append(' '); @@ -352,8 +301,15 @@ public final class DescriptorsUtils { // Replace these acronyms by upper-case versions // - (?<=^| ) means "if preceded by a space or beginning of string" // - (?=$| ) means "if followed by a space or end of string" - name = name.replaceAll("(?<=^| )sdk(?=$| )", "SDK"); - name = name.replaceAll("(?<=^| )uri(?=$| )", "URI"); + if (name.contains("sdk") || name.startsWith("Sdk")) { + name = name.replaceAll("(?<=^| )[sS]dk(?=$| )", "SDK"); + } + if (name.contains("uri") || name.startsWith("Uri")) { + name = name.replaceAll("(?<=^| )[uU]ri(?=$| )", "URI"); + } + if (name.contains("ime") || name.startsWith("Ime")) { + name = name.replaceAll("(?<=^| )[iI]me(?=$| )", "IME"); + } return name; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/EnumAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/EnumAttributeDescriptor.java index 647d8bd..2923357 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/EnumAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/EnumAttributeDescriptor.java @@ -29,7 +29,7 @@ public class EnumAttributeDescriptor extends ListAttributeDescriptor { public EnumAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + super(xmlLocalName, nsUri, attrInfo); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/FlagAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/FlagAttributeDescriptor.java index 03f76ca..4f4b215 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/FlagAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/FlagAttributeDescriptor.java @@ -49,9 +49,8 @@ public class FlagAttributeDescriptor extends TextAttributeDescriptor { * used for the list. * Otherwise values are automatically extracted from the FrameworkResourceManager. */ - public FlagAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public FlagAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); if (attrInfo != null) { mNames = attrInfo.getFlagValues(); } @@ -63,7 +62,7 @@ public class FlagAttributeDescriptor extends TextAttributeDescriptor { */ public FlagAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, String tooltip, IAttributeInfo attrInfo, String[] names) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + super(xmlLocalName, nsUri, attrInfo); mNames = names; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ITextAttributeCreator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ITextAttributeCreator.java index 88b11ae..37202b2 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ITextAttributeCreator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ITextAttributeCreator.java @@ -35,18 +35,13 @@ public interface ITextAttributeCreator { * UI name and tooltip. * * @param xmlLocalName The XML name of the attribute (case sensitive) - * @param uiName The UI attribute name. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip An optional tooltip. * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. - * * @return A new {@link TextAttributeDescriptor} (or derived) instance. */ public TextAttributeDescriptor create( String xmlLocalName, - String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ListAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ListAttributeDescriptor.java index 63dee0d..16b0d55 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ListAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ListAttributeDescriptor.java @@ -39,9 +39,8 @@ public class ListAttributeDescriptor extends TextAttributeDescriptor { public static final ITextAttributeCreator CREATOR = new ITextAttributeCreator() { @Override public TextAttributeDescriptor create(String xmlLocalName, - String uiName, String nsUri, String tooltip, - IAttributeInfo attrInfo) { - return new ListAttributeDescriptor(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + String nsUri, IAttributeInfo attrInfo) { + return new ListAttributeDescriptor(xmlLocalName, nsUri, attrInfo); } }; @@ -52,9 +51,8 @@ public class ListAttributeDescriptor extends TextAttributeDescriptor { * used for the list. * Otherwise values are automatically extracted from the FrameworkResourceManager. */ - public ListAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public ListAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); if (attrInfo != null) { mValues = attrInfo.getEnumValues(); } @@ -64,9 +62,9 @@ public class ListAttributeDescriptor extends TextAttributeDescriptor { * Creates a new {@link ListAttributeDescriptor} which uses the provided values * and does not lookup the content of <code>attrInfo</code>. */ - public ListAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo, String[] values) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public ListAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo, + String[] values) { + super(xmlLocalName, nsUri, attrInfo); mValues = values; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ReferenceAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ReferenceAttributeDescriptor.java index 347a284..9f1f501 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ReferenceAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/ReferenceAttributeDescriptor.java @@ -47,11 +47,10 @@ public final class ReferenceAttributeDescriptor extends TextAttributeDescriptor public static final ITextAttributeCreator CREATOR = new ITextAttributeCreator() { @Override public TextAttributeDescriptor create(String xmlLocalName, - String uiName, String nsUri, String tooltip, - IAttributeInfo attrInfo) { + String nsUri, IAttributeInfo attrInfo) { return new ReferenceAttributeDescriptor( ResourceType.DRAWABLE, - xmlLocalName, uiName, nsUri, tooltip, + xmlLocalName, nsUri, new AttributeInfo(xmlLocalName, new Format[] { Format.REFERENCE })); } }; @@ -59,15 +58,13 @@ public final class ReferenceAttributeDescriptor extends TextAttributeDescriptor /** * Creates a reference attributes that can contain any type of resources. * @param xmlLocalName The XML name of the attribute (case sensitive) - * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip A non-empty tooltip string or null * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. */ - public ReferenceAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public ReferenceAttributeDescriptor(String xmlLocalName, String nsUri, + IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); } /** @@ -76,16 +73,13 @@ public final class ReferenceAttributeDescriptor extends TextAttributeDescriptor * @param resourceType The specific {@link ResourceType} that this reference attribute supports. * It can be <code>null</code>, in which case, all resource types are supported. * @param xmlLocalName The XML name of the attribute (case sensitive) - * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip A non-empty tooltip string or null * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. */ public ReferenceAttributeDescriptor(ResourceType resourceType, - String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); mResourceType = resourceType; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextAttributeDescriptor.java index 88b474b..dece813 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextAttributeDescriptor.java @@ -16,7 +16,10 @@ package com.android.ide.eclipse.adt.internal.editors.descriptors; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IAttributeInfo; +import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.eclipse.adt.internal.editors.ui.TextValueCellEditor; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; @@ -29,6 +32,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.views.properties.IPropertyDescriptor; +import java.util.Locale; + /** * Describes a textual XML attribute. @@ -43,35 +48,93 @@ public class TextAttributeDescriptor extends AttributeDescriptor implements IPro private String mUiName; private String mTooltip; + private boolean mRequired; /** * Creates a new {@link TextAttributeDescriptor} * * @param xmlLocalName The XML name of the attribute (case sensitive) - * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip A non-empty tooltip string or null * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. */ public TextAttributeDescriptor( String xmlLocalName, - String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { super(xmlLocalName, nsUri, attrInfo); - mUiName = uiName; - mTooltip = (tooltip != null && tooltip.length() > 0) ? tooltip : null; } /** * @return The UI name of the attribute. Cannot be an empty string and cannot be null. */ - public final String getUiName() { + @NonNull + public String getUiName() { + if (mUiName == null) { + IAttributeInfo info = getAttributeInfo(); + if (info != null) { + mUiName = DescriptorsUtils.prettyAttributeUiName(info.getName()); + if (mRequired) { + mUiName += "*"; //$NON-NLS-1$ + } + } else { + mUiName = getXmlLocalName(); + } + } + return mUiName; } + + /** + * Sets the UI name to be associated with this descriptor. This is usually + * computed lazily from the {@link #getAttributeInfo()} data, but for some + * hardcoded/builtin descriptor this is manually initialized. + * + * @param uiName the new UI name to be used + * @return this, for constructor setter chaining + */ + public TextAttributeDescriptor setUiName(String uiName) { + mUiName = uiName; + + return this; + } + + /** + * Sets the tooltip to be associated with this descriptor. This is usually + * computed lazily from the {@link #getAttributeInfo()} data, but for some + * hardcoded/builtin descriptor this is manually initialized. + * + * @param tooltip the new tooltip to be used + * @return this, for constructor setter chaining + */ + public TextAttributeDescriptor setTooltip(String tooltip) { + mTooltip = tooltip; + + return this; + } + + /** + * Sets whether this attribute is required + * + * @param required whether this attribute is required + * @return this, for constructor setter chaining + */ + public TextAttributeDescriptor setRequired(boolean required) { + mRequired = required; + + return this; + } + + /** + * Returns whether this attribute is required + * + * @return whether this attribute is required + */ + public boolean isRequired() { + return mRequired; + } + /** * The tooltip string is either null or a non-empty string. * <p/> @@ -84,8 +147,78 @@ public class TextAttributeDescriptor extends AttributeDescriptor implements IPro * * @return A non-empty tooltip string or null */ - public final String getTooltip() { - return mTooltip; + @Nullable + public String getTooltip() { + if (mTooltip == null) { + IAttributeInfo info = getAttributeInfo(); + if (info == null) { + mTooltip = ""; + return mTooltip; + } + + String tooltip = null; + String rawTooltip = info.getJavaDoc(); + if (rawTooltip == null) { + rawTooltip = ""; + } + + String deprecated = info.getDeprecatedDoc(); + if (deprecated != null) { + if (rawTooltip.length() > 0) { + rawTooltip += "@@"; //$NON-NLS-1$ insert a break + } + rawTooltip += "* Deprecated"; + if (deprecated.length() != 0) { + rawTooltip += ": " + deprecated; //$NON-NLS-1$ + } + if (deprecated.length() == 0 || !deprecated.endsWith(".")) { //$NON-NLS-1$ + rawTooltip += "."; //$NON-NLS-1$ + } + } + + // Add the known types to the tooltip + Format[] formats_list = info.getFormats(); + int flen = formats_list.length; + if (flen > 0) { + StringBuilder sb = new StringBuilder(); + if (rawTooltip != null && rawTooltip.length() > 0) { + sb.append(rawTooltip); + sb.append(" "); //$NON-NLS-1$ + } + if (sb.length() > 0) { + sb.append("@@"); //$NON-NLS-1$ @@ inserts a break before the types + } + sb.append("["); //$NON-NLS-1$ + for (int i = 0; i < flen; i++) { + Format f = formats_list[i]; + sb.append(f.toString().toLowerCase(Locale.US)); + if (i < flen - 1) { + sb.append(", "); //$NON-NLS-1$ + } + } + // The extra space at the end makes the tooltip more readable on Windows. + sb.append("]"); //$NON-NLS-1$ + + if (mRequired) { + // Note: this string is split in 2 to make it translatable. + sb.append(".@@"); //$NON-NLS-1$ @@ inserts a break and is not translatable + sb.append("* Required."); + } + + // The extra space at the end makes the tooltip more readable on Windows. + sb.append(" "); //$NON-NLS-1$ + + rawTooltip = sb.toString(); + tooltip = DescriptorsUtils.formatTooltip(rawTooltip); + } + + if (tooltip == null) { + tooltip = DescriptorsUtils.formatTooltip(rawTooltip); + } + mTooltip = tooltip; + } + + return mTooltip.isEmpty() ? null : mTooltip; } /** @@ -119,12 +252,12 @@ public class TextAttributeDescriptor extends AttributeDescriptor implements IPro @Override public String getDescription() { - return mTooltip; + return getTooltip(); } @Override public String getDisplayName() { - return mUiName; + return getUiName(); } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextValueDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextValueDescriptor.java index b237e37..6bfe4c7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextValueDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/TextValueDescriptor.java @@ -35,7 +35,9 @@ public class TextValueDescriptor extends TextAttributeDescriptor { * @param tooltip A non-empty tooltip string or null */ public TextValueDescriptor(String uiName, String tooltip) { - super("#text" /* xmlLocalName */, uiName, null /* nsUri */, tooltip, null /* info */); + super("#text" /* xmlLocalName */, null /* nsUri */, null /* info */); + setUiName(uiName); + setTooltip(tooltip); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableDescriptors.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableDescriptors.java index 4c11057..ca9710b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableDescriptors.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableDescriptors.java @@ -213,10 +213,9 @@ public class DrawableDescriptors implements IDescriptorProvider { + "its attributes. Must be a child of a <selector> element.", SDK_URL_BASE + "drawable-resource.html#StateList", //$NON-NLS-1$ new ReferenceAttributeDescriptor( - ResourceType.DRAWABLE, "drawable", "drawable", //$NON-NLS-1$ //$NON-NLS-2$ - SdkConstants.NS_RESOURCES, - "Reference to a drawable resource.", - new AttributeInfo("drawable", referenceFormat)), + ResourceType.DRAWABLE, "drawable", SdkConstants.NS_RESOURCES, //$NON-NLS-1$ + new AttributeInfo("drawable", referenceFormat)) + .setTooltip("Reference to a drawable resource."), null, /* This is wrong -- we can now embed any above drawable (but without xmlns as extra) */ false /*mandatory*/); 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 78f2d7f..1eab291 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 @@ -33,6 +33,7 @@ import com.android.ide.eclipse.adt.internal.editors.descriptors.DocumentDescript import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; import com.android.ide.eclipse.adt.internal.editors.descriptors.IDescriptorProvider; import com.android.ide.eclipse.adt.internal.editors.descriptors.SeparatorAttributeDescriptor; +import com.android.ide.eclipse.adt.internal.editors.descriptors.TextAttributeDescriptor; import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.ClassAttributeDescriptor; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; @@ -453,13 +454,13 @@ public final class LayoutDescriptors implements IDescriptorProvider { "A Fragment is a piece of an application's user interface or behavior that " + "can be placed in an Activity"; String sdkUrl = "http://developer.android.com/guide/topics/fundamentals/fragments.html"; - ClassAttributeDescriptor classAttribute = new ClassAttributeDescriptor( + TextAttributeDescriptor classAttribute = new ClassAttributeDescriptor( // Should accept both CLASS_V4_FRAGMENT and CLASS_FRAGMENT null /*superClassName*/, - ATTR_CLASS, ATTR_CLASS, null /* namespace */, - "Supply the name of the fragment class to instantiate", + ATTR_CLASS, null /* namespace */, new AttributeInfo(ATTR_CLASS, new Format[] { Format.STRING}), - true /*mandatory*/); + true /*mandatory*/) + .setTooltip("Supply the name of the fragment class to instantiate"); if (style != null) { descriptor = new ViewElementDescriptor( @@ -493,17 +494,17 @@ public final class LayoutDescriptors implements IDescriptorProvider { new AttributeDescriptor[] { new ClassAttributeDescriptor( null /*superClassName*/, - ATTR_NAME, ATTR_NAME, ANDROID_URI, - "Supply the name of the fragment class to instantiate", + ATTR_NAME, ANDROID_URI, new AttributeInfo(ATTR_NAME, new Format[] { Format.STRING}), - true /*mandatory*/), + true /*mandatory*/) + .setTooltip("Supply the name of the fragment class to instantiate"), classAttribute, new ClassAttributeDescriptor( null /*superClassName*/, - ATTR_TAG, ATTR_TAG, ANDROID_URI, - "Supply a tag for the top-level view containing a String", + ATTR_TAG, ANDROID_URI, new AttributeInfo(ATTR_TAG, new Format[] { Format.STRING}), - true /*mandatory*/), + true /*mandatory*/) + .setTooltip("Supply a tag for the top-level view containing a String"), }, // attributes viewLayoutAttribs, // layout attributes null, // children diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/AndroidManifestDescriptors.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/AndroidManifestDescriptors.java index 060cedc..02f68ba 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/AndroidManifestDescriptors.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/AndroidManifestDescriptors.java @@ -116,10 +116,11 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { // The "package" attribute is treated differently as it doesn't have the standard // Android XML namespace. PACKAGE_ATTR_DESC = new PackageAttributeDescriptor(PACKAGE_ATTR, - "Package", null /* nsUri */, - "This attribute gives a unique name for the package, using a Java-style naming convention to avoid name collisions.\nFor example, applications published by Google could have names of the form com.google.app.appname", - new AttributeInfo(PACKAGE_ATTR, new Format[] { Format.REFERENCE }) ); + new AttributeInfo(PACKAGE_ATTR, new Format[] { Format.REFERENCE })).setTooltip( + "This attribute gives a unique name for the package, using a Java-style " + + "naming convention to avoid name collisions.\nFor example, applications " + + "published by Google could have names of the form com.google.app.appname"); } @Override @@ -249,10 +250,8 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { overrides.put(elementName + "/" + ANDROID_NAME_ATTR, new ITextAttributeCreator() { @Override - public TextAttributeDescriptor create(String xmlName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - uiName += "*"; //$NON-NLS-1$ - + public TextAttributeDescriptor create(String xmlName, String nsUri, + IAttributeInfo attrInfo) { if (attrInfo == null) { attrInfo = new AttributeInfo(xmlName, new Format[] { Format.STRING } ); } @@ -262,9 +261,7 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { className, PostActivityCreationAction.getAction(), xmlName, - uiName, nsUri, - tooltip, attrInfo, true /*mandatory */, true /*defaultToProjectOnly*/); @@ -273,9 +270,7 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { className, PostReceiverCreationAction.getAction(), xmlName, - uiName, nsUri, - tooltip, attrInfo, true /*mandatory */, true /*defaultToProjectOnly*/); @@ -284,9 +279,7 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { className, null, // no post action xmlName, - uiName, nsUri, - tooltip, attrInfo, true /*mandatory */, false /*defaultToProjectOnly*/); @@ -294,9 +287,7 @@ public final class AndroidManifestDescriptors implements IDescriptorProvider { return new ClassAttributeDescriptor( className, xmlName, - uiName, nsUri, - tooltip, attrInfo, true /*mandatory */); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ApplicationAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ApplicationAttributeDescriptor.java index 840f673..4f41ac2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ApplicationAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ApplicationAttributeDescriptor.java @@ -39,16 +39,15 @@ public class ApplicationAttributeDescriptor extends TextAttributeDescriptor { public static final ITextAttributeCreator CREATOR = new ITextAttributeCreator() { @Override public TextAttributeDescriptor create(String xmlLocalName, - String uiName, String nsUri, String tooltip, - IAttributeInfo attrInfo) { + String nsUri, IAttributeInfo attrInfo) { return new ApplicationAttributeDescriptor( - xmlLocalName, uiName, nsUri, tooltip, attrInfo); + xmlLocalName, nsUri, attrInfo); } }; - public ApplicationAttributeDescriptor(String xmlLocalName, String uiName, - String nsUri, String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + private ApplicationAttributeDescriptor(String xmlLocalName, String nsUri, + IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ClassAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ClassAttributeDescriptor.java index 3788880..5c7ae67 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ClassAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ClassAttributeDescriptor.java @@ -45,23 +45,23 @@ public class ClassAttributeDescriptor extends TextAttributeDescriptor { * @param superClassName the fully qualified name of the superclass of the class represented * by the attribute. * @param xmlLocalName The XML name of the attribute (case sensitive, with android: prefix). - * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip A non-empty tooltip string or null. * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. * @param mandatory indicates if the class attribute is mandatory. */ public ClassAttributeDescriptor(String superClassName, String xmlLocalName, - String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo, boolean mandatory) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + super(xmlLocalName, nsUri, attrInfo); mSuperClassName = superClassName; mDefaultToProjectOnly = true; + if (mandatory) { + mMandatory = true; + setRequired(true); + } } /** @@ -71,10 +71,8 @@ public class ClassAttributeDescriptor extends TextAttributeDescriptor { * @param postCreationAction the {@link IPostTypeCreationAction} to be executed on the * newly created class. * @param xmlLocalName The XML local name of the attribute (case sensitive). - * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. * See {@link SdkConstants#NS_RESOURCES} for a common value. - * @param tooltip A non-empty tooltip string or null. * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. * @param mandatory indicates if the class attribute is mandatory. * @param defaultToProjectOnly True if only classes from the sources of this project should @@ -83,16 +81,18 @@ public class ClassAttributeDescriptor extends TextAttributeDescriptor { public ClassAttributeDescriptor(String superClassName, IPostTypeCreationAction postCreationAction, String xmlLocalName, - String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo, boolean mandatory, boolean defaultToProjectOnly) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + super(xmlLocalName, nsUri, attrInfo); mSuperClassName = superClassName; mPostCreationAction = postCreationAction; mDefaultToProjectOnly = defaultToProjectOnly; + if (mandatory) { + mMandatory = true; + setRequired(true); + } } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ManifestPkgAttrDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ManifestPkgAttrDescriptor.java index 4d6941f..74b7894 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ManifestPkgAttrDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ManifestPkgAttrDescriptor.java @@ -37,15 +37,13 @@ public class ManifestPkgAttrDescriptor extends TextAttributeDescriptor { public static final ITextAttributeCreator CREATOR = new ITextAttributeCreator() { @Override public TextAttributeDescriptor create(String xmlLocalName, - String uiName, String nsUri, String tooltip, - IAttributeInfo attrInfo) { - return new ManifestPkgAttrDescriptor(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + String nsUri, IAttributeInfo attrInfo) { + return new ManifestPkgAttrDescriptor(xmlLocalName, nsUri, attrInfo); } }; - public ManifestPkgAttrDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public ManifestPkgAttrDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/PackageAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/PackageAttributeDescriptor.java index 73bd401..e8395ac 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/PackageAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/PackageAttributeDescriptor.java @@ -27,9 +27,8 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; */ public class PackageAttributeDescriptor extends TextAttributeDescriptor { - public PackageAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public PackageAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ThemeAttributeDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ThemeAttributeDescriptor.java index f016e61..881d753 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ThemeAttributeDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/descriptors/ThemeAttributeDescriptor.java @@ -38,15 +38,13 @@ public final class ThemeAttributeDescriptor extends TextAttributeDescriptor { public static final ITextAttributeCreator CREATOR = new ITextAttributeCreator() { @Override public TextAttributeDescriptor create(String xmlLocalName, - String uiName, String nsUri, String tooltip, - IAttributeInfo attrInfo) { - return new ThemeAttributeDescriptor(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + String nsUri, IAttributeInfo attrInfo) { + return new ThemeAttributeDescriptor(xmlLocalName, nsUri, attrInfo); } }; - public ThemeAttributeDescriptor(String xmlLocalName, String uiName, String nsUri, - String tooltip, IAttributeInfo attrInfo) { - super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); + public ThemeAttributeDescriptor(String xmlLocalName, String nsUri, IAttributeInfo attrInfo) { + super(xmlLocalName, nsUri, attrInfo); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/SectionHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/SectionHelper.java index fc82b22..fdb5d82 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/SectionHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/SectionHelper.java @@ -354,7 +354,8 @@ public final class SectionHelper { } text.setWhitespaceNormalized(true); if (isHtml && !label.startsWith("<form>")) { //$NON-NLS-1$ - assert label.startsWith("<form>") : "HTML for FormText must be wrapped in <form>...</form>"; //$NON-NLS-1$ + // This assertion is violated, for example by the Class attribute for an activity + //assert label.startsWith("<form>") : "HTML for FormText must be wrapped in <form>...</form>"; //$NON-NLS-1$ label = "<form>" + label + "</form>"; //$NON-NLS-1$ //$NON-NLS-2$ } text.setText(label, isHtml /* parseTags */, isHtml /* expandURLs */); 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 dfe38b0..706aa66 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 @@ -1482,9 +1482,7 @@ public class UiElementNode implements IPropertySource { // Create a new unknown attribute of format string TextAttributeDescriptor desc = new TextAttributeDescriptor( xmlAttrLocalName, // xml name - xmlFullName, // ui name - xmlNsUri, // NS uri - "Unknown XML attribute", // tooltip, translatable + xmlNsUri, // ui name new AttributeInfo(xmlAttrLocalName, new Format[] { Format.STRING } ) ); UiAttributeNode uiAttr = desc.createUiNode(this); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ColorValueDescriptor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ColorValueDescriptor.java index 914f841..0127850 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ColorValueDescriptor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ColorValueDescriptor.java @@ -30,7 +30,7 @@ public final class ColorValueDescriptor extends TextValueDescriptor { public ColorValueDescriptor(String uiName, String tooltip) { super(uiName, tooltip); } - + /** * @return A new {@link UiResourceAttributeNode} linked to this theme descriptor. */ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ValuesDescriptors.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ValuesDescriptors.java index fd6d476..c450597 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ValuesDescriptors.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/descriptors/ValuesDescriptors.java @@ -90,13 +90,12 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#colorvals", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this color.", nameAttrInfo), new ColorValueDescriptor( "Value*", "A mandatory color value.") + .setTooltip("The mandatory name used in referring to this color.") }, null, // no child nodes false /* not mandatory */); @@ -108,10 +107,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#stringresources", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this string.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this string."), new TextValueDescriptor( "Value*", "A mandatory string value.") @@ -126,22 +124,17 @@ public final class ValuesDescriptors implements IDescriptorProvider { null, // TODO find link to javadoc new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this resource.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this resource."), new ListAttributeDescriptor(TYPE_ATTR, - "Type*", null /* nsUri */, - "The mandatory type of this resource.", new AttributeInfo(TYPE_ATTR, new Format[] { Format.STRING, Format.ENUM } ).setEnumValues(ResourceType.getNames()) - ), + ).setTooltip("The mandatory type of this resource."), new FlagAttributeDescriptor("format", //$NON-NLS-1$ - "Format", null /* nsUri */, - "The optional format of this resource.", new AttributeInfo("format", new Format[] { Format.STRING, Format.FLAG } ).setFlagValues( @@ -155,7 +148,7 @@ public final class ValuesDescriptors implements IDescriptorProvider { "reference", //$NON-NLS-1$ "string" //$NON-NLS-1$ } ) - ), + ).setTooltip("The optional format of this resource."), new TextValueDescriptor( "Value", "A standard string, hex color value, or reference to any other resource type.") @@ -170,10 +163,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#colordrawableresources", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this drawable.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this drawable."), new TextValueDescriptor( "Value*", "A mandatory color value in the form #RGB, #ARGB, #RRGGBB or #AARRGGBB.") @@ -188,10 +180,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#dimension", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this dimension.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this dimension."), new TextValueDescriptor( "Value*", "A mandatory dimension value is a number followed by a unit of measurement. For example: 10px, 2in, 5sp.") @@ -206,16 +197,14 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#stylesandthemes", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this theme.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this theme."), new TextAttributeDescriptor("parent", //$NON-NLS-1$ - "Parent", null /* nsUri */, - "An optional parent theme. All values from the specified theme will be inherited into this theme. Any values with identical names that you specify will override inherited values.", new AttributeInfo("parent", //$NON-NLS-1$ - new Format[] { Format.STRING })), + new Format[] { Format.STRING })) + .setTooltip("An optional parent theme. All values from the specified theme will be inherited into this theme. Any values with identical names that you specify will override inherited values."), }, new ElementDescriptor[] { new ElementDescriptor( @@ -225,10 +214,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { "http://code.google.com/android/reference/available-resources.html#stylesandthemes", //$NON-NLS-1$ new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this item.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this item."), new TextValueDescriptor( "Value*", "A mandatory standard string, hex color value, or reference to any other resource type.") @@ -245,10 +233,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { null, // tooltips new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this string array.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this string array."), }, new ElementDescriptor[] { new ElementDescriptor( @@ -273,10 +260,9 @@ public final class ValuesDescriptors implements IDescriptorProvider { null, // tooltips new AttributeDescriptor[] { new TextAttributeDescriptor(NAME_ATTR, - "Name*", null /* nsUri */, - "The mandatory name used in referring to this integer array.", - nameAttrInfo), + nameAttrInfo) + .setTooltip("The mandatory name used in referring to this integer array.") }, new ElementDescriptor[] { new ElementDescriptor( diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParserTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParserTest.java index fbd3aa0..e3df52d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParserTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParserTest.java @@ -44,9 +44,7 @@ public class UiElementPullParserTest extends TestCase { private TextAttributeDescriptor createTextAttrDesc(String xmlName) { return new TextAttributeDescriptor( xmlName, // xmlLocalName - xmlName, // uiName - SdkConstants.NS_RESOURCES, // ns uri - "", // tooltip + SdkConstants.NS_RESOURCES, new AttributeInfo(xmlName, new Format[] { Format.STRING }) ); } |