diff options
Diffstat (limited to 'eclipse')
38 files changed, 570 insertions, 345 deletions
diff --git a/eclipse/buildConfig/build.properties b/eclipse/buildConfig/build.properties index ae3be41..4c1d471 100644 --- a/eclipse/buildConfig/build.properties +++ b/eclipse/buildConfig/build.properties @@ -221,7 +221,7 @@ javacFailOnError=true javacVerbose=true # Extra arguments for the compiler. These are specific to the java compiler being used. -#compilerArg= +compilerArg=-warn:none # Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties javacSource=1.6 diff --git a/eclipse/dictionary.txt b/eclipse/dictionary.txt index dca9b23..c1640c0 100644 --- a/eclipse/dictionary.txt +++ b/eclipse/dictionary.txt @@ -192,6 +192,8 @@ popup popups pre precompiler +precompute +precomputing pref prefs preload diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java index 47f3a58..76e515e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java @@ -56,7 +56,6 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IAttributeInfo; -import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.api.IClientRulesEngine; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.IDragElement.IDragAttribute; @@ -160,7 +159,7 @@ public class BaseLayoutRule extends BaseViewRule { IAttributeInfo info = first.getAttributeInfo(ANDROID_URI, attributeName); if (info != null) { // Generate list of possible gravity value constants - assert IAttributeInfo.Format.FLAG.in(info.getFormats()); + assert info.getFormats().contains(IAttributeInfo.Format.FLAG); for (String name : info.getFlagValues()) { titles.add(getAttributeDisplayName(name)); ids.add(name); @@ -524,8 +523,7 @@ public class BaseLayoutRule extends BaseViewRule { IAttributeInfo attrInfo = newNode.getAttributeInfo(uri, name); if (attrInfo != null) { - Format[] formats = attrInfo.getFormats(); - if (IAttributeInfo.Format.REFERENCE.in(formats)) { + if (attrInfo.getFormats().contains(IAttributeInfo.Format.REFERENCE)) { if (idMap.containsKey(value)) { value = idMap.get(value).getFirst(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java index 17726d0..ddad36c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java @@ -57,6 +57,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -317,7 +318,7 @@ public class BaseViewRule extends AbstractViewRule { oldValue = ensureValidString(oldValue); IAttributeInfo attributeInfo = node.getAttributeInfo(ANDROID_URI, attribute); if (attributeInfo != null - && IAttributeInfo.Format.REFERENCE.in(attributeInfo.getFormats())) { + && attributeInfo.getFormats().contains(Format.REFERENCE)) { return mRulesEngine.displayReferenceInput(oldValue); } else { // A single resource type? If so use a resource chooser initialized @@ -696,17 +697,17 @@ public class BaseViewRule extends AbstractViewRule { // Layout width/height are already handled at the root level continue; } - Format[] formats = attrInfo != null ? attrInfo.getFormats() : null; - if (formats == null) { + if (attrInfo == null) { continue; } + EnumSet<Format> formats = attrInfo.getFormats(); String title = getAttributeDisplayName(id); String definedBy = attrInfo != null ? attrInfo.getDefinedBy() : null; - if (IAttributeInfo.Format.BOOLEAN.in(formats)) { + if (formats.contains(IAttributeInfo.Format.BOOLEAN)) { props.put(id, new Prop(title, true, definedBy)); - } else if (IAttributeInfo.Format.ENUM.in(formats)) { + } else if (formats.contains(IAttributeInfo.Format.ENUM)) { // Convert each enum into a map id=>title Map<String, String> values = new HashMap<String, String>(); if (attrInfo != null) { @@ -716,7 +717,7 @@ public class BaseViewRule extends AbstractViewRule { } props.put(id, new Prop(title, false, false, values, definedBy)); - } else if (IAttributeInfo.Format.FLAG.in(formats)) { + } else if (formats.contains(IAttributeInfo.Format.FLAG)) { // Convert each flag into a map id=>title Map<String, String> values = new HashMap<String, String>(); if (attrInfo != null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java index b8d381f..ec3d8a4 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java @@ -16,8 +16,11 @@ package com.android.ide.common.resources.platform; +import com.android.annotations.NonNull; import com.android.ide.common.api.IAttributeInfo; +import java.util.EnumSet; + /** * Information about an attribute as gathered from the attrs.xml file where @@ -29,7 +32,7 @@ public class AttributeInfo implements IAttributeInfo { private String mName; /** Formats of the attribute. Cannot be null. Should have at least one format. */ - private Format[] mFormats; + private EnumSet<Format> mFormats; /** Values for enum. null for other types. */ private String[] mEnumValues; /** Values for flag. null for other types. */ @@ -46,7 +49,7 @@ public class AttributeInfo implements IAttributeInfo { * @param formats The formats of the attribute. Cannot be null. * Should have at least one format. */ - public AttributeInfo(String name, Format[] formats) { + public AttributeInfo(@NonNull String name, @NonNull EnumSet<Format> formats) { mName = name; mFormats = formats; } @@ -57,7 +60,7 @@ public class AttributeInfo implements IAttributeInfo { * Should have at least one format. * @param javadoc Short javadoc (i.e. the first sentence). */ - public AttributeInfo(String name, Format[] formats, String javadoc) { + public AttributeInfo(@NonNull String name, @NonNull EnumSet<Format> formats, String javadoc) { mName = name; mFormats = formats; mJavaDoc = javadoc; @@ -80,7 +83,7 @@ public class AttributeInfo implements IAttributeInfo { /** Returns the formats of the attribute. Cannot be null. * Should have at least one format. */ @Override - public Format[] getFormats() { + public EnumSet<Format> getFormats() { return mFormats; } /** Returns the values for enums. null for other types. */ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java index abe56d8..52b0e15 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java @@ -30,11 +30,11 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.EnumSet; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; -import java.util.TreeSet; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -58,6 +58,9 @@ public final class AttrsXmlParser { private final Map<String, DeclareStyleableInfo> mStyleMap = new HashMap<String, DeclareStyleableInfo>(); + /** Map from format name (lower case) to the uppercase version */ + private Map<String, Format> mFormatNames = new HashMap<String, Format>(10); + /** * Map of all (constant, value) pairs for attributes of format enum or flag. * E.g. for attribute name=gravity, this tells us there's an enum/flag called "center" @@ -117,6 +120,12 @@ public final class AttrsXmlParser { mEnumFlagValues = new HashMap<String, Map<String,Integer>>( inheritableAttributes.mEnumFlagValues); } + + // Pre-compute the set of format names such that we don't have to compute the uppercase + // version of the same format string names again and again + for (Format f : Format.values()) { + mFormatNames.put(f.name().toLowerCase(Locale.US), f); + } } /** @@ -396,7 +405,7 @@ public final class AttrsXmlParser { info = mAttributeMap.get(name); // If the attribute is unknown yet, parse it. // If the attribute is know but its format is unknown, parse it too. - if (info == null || info.getFormats().length == 0) { + if (info == null || info.getFormats().size() == 0) { info = parseAttributeTypes(attrNode, name); if (info != null) { mAttributeMap.put(name, info); @@ -468,25 +477,28 @@ public final class AttrsXmlParser { * When reusing a node, it is duplicated and its javadoc reassigned. */ private AttributeInfo parseAttributeTypes(Node attrNode, String name) { - TreeSet<AttributeInfo.Format> formats = new TreeSet<AttributeInfo.Format>(); + EnumSet<Format> formats = null; String[] enumValues = null; String[] flagValues = null; Node attrFormat = attrNode.getAttributes().getNamedItem("format"); //$NON-NLS-1$ if (attrFormat != null) { for (String f : attrFormat.getNodeValue().split("\\|")) { //$NON-NLS-1$ - try { - Format format = AttributeInfo.Format.valueOf(f.toUpperCase(Locale.US)); - // enum and flags are handled differently right below - if (format != null && - format != AttributeInfo.Format.ENUM && - format != AttributeInfo.Format.FLAG) { - formats.add(format); - } - } catch (IllegalArgumentException e) { - mLog.error(e, + Format format = mFormatNames.get(f); + if (format == null) { + mLog.printf( "Unknown format name '%s' in <attr name=\"%s\">, file '%s'.", //$NON-NLS-1$ f, name, getOsAttrsXmlPath()); + } else if (format != AttributeInfo.Format.ENUM && + format != AttributeInfo.Format.FLAG) { + if (formats == null) { + formats = format.asSet(); + } else { + if (formats.size() == 1) { + formats = EnumSet.copyOf(formats); + } + formats.add(format); + } } } } @@ -494,17 +506,34 @@ public final class AttrsXmlParser { // does this <attr> have <enum> children? enumValues = parseEnumFlagValues(attrNode, "enum", name); //$NON-NLS-1$ if (enumValues != null) { - formats.add(AttributeInfo.Format.ENUM); + if (formats == null) { + formats = Format.ENUM_SET; + } else { + if (formats.size() == 1) { + formats = EnumSet.copyOf(formats); + } + formats.add(Format.ENUM); + } } // does this <attr> have <flag> children? flagValues = parseEnumFlagValues(attrNode, "flag", name); //$NON-NLS-1$ if (flagValues != null) { - formats.add(AttributeInfo.Format.FLAG); + if (formats == null) { + formats = Format.FLAG_SET; + } else { + if (formats.size() == 1) { + formats = EnumSet.copyOf(formats); + } + formats.add(Format.FLAG); + } + } + + if (formats == null) { + formats = Format.NONE; } - AttributeInfo info = new AttributeInfo(name, - formats.toArray(new AttributeInfo.Format[formats.size()])); + AttributeInfo info = new AttributeInfo(name, formats); info.setEnumValues(enumValues); info.setFlagValues(flagValues); return info; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java index 14e479e..7c4cba8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java @@ -59,6 +59,7 @@ import org.w3c.dom.Node; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -496,7 +497,7 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor { AttributeDescriptor attributeDescriptor = currAttrNode.getDescriptor(); IAttributeInfo attributeInfo = attributeDescriptor.getAttributeInfo(); if (value.startsWith(PREFIX_RESOURCE_REF) - && !Format.REFERENCE.in(attributeInfo.getFormats())) { + && !attributeInfo.getFormats().contains(Format.REFERENCE)) { // Special case: If the attribute value looks like a reference to a // resource, offer to complete it, since in many cases our metadata // does not correctly state whether a resource value is allowed. We don't @@ -1224,12 +1225,12 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor { */ private Object[] completeSuffix(Object[] choices, String value, UiAttributeNode currAttrNode) { IAttributeInfo attributeInfo = currAttrNode.getDescriptor().getAttributeInfo(); - Format[] formats = attributeInfo.getFormats(); + EnumSet<Format> formats = attributeInfo.getFormats(); List<Object> suffixes = new ArrayList<Object>(); if (value.length() > 0 && Character.isDigit(value.charAt(0))) { - boolean hasDimension = Format.DIMENSION.in(formats); - boolean hasFraction = Format.FRACTION.in(formats); + boolean hasDimension = formats.contains(Format.DIMENSION); + boolean hasFraction = formats.contains(Format.FRACTION); if (hasDimension || hasFraction) { // Split up the value into a numeric part (the prefix) and the @@ -1273,7 +1274,7 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor { } } - boolean hasFlag = Format.FLAG.in(formats); + boolean hasFlag = formats.contains(Format.FLAG); if (hasFlag) { boolean isDone = false; String[] flagValues = attributeInfo.getFlagValues(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationContentAssist.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationContentAssist.java index 476fbd9..6b584b1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationContentAssist.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationContentAssist.java @@ -39,6 +39,7 @@ import org.w3c.dom.Node; import java.util.ArrayList; import java.util.Collections; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -125,17 +126,15 @@ public final class AnimationContentAssist extends AndroidContentAssist { } String name = desc.getXmlLocalName(); if (startsWith(name, attributePrefix)) { - for (Format f : desc.getAttributeInfo().getFormats()) { - if (f == Format.INTEGER || f == Format.FLOAT) { - // TODO: Filter out some common properties - // that the user probably isn't trying to - // animate: - // num*, min*, max*, *Index, *Threshold, - // *Duration, *Id, *Limit - - matches.put(name, desc); - break; - } + EnumSet<Format> formats = desc.getAttributeInfo().getFormats(); + if (formats.contains(Format.INTEGER) + || formats.contains(Format.FLOAT)) { + // TODO: Filter out some common properties + // that the user probably isn't trying to + // animate: + // num*, min*, max*, *Index, *Threshold, + // *Duration, *Id, *Limit + matches.put(name, desc); } } } 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..8db3e0f 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, Format.COLOR_SET)).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..20096f4 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,14 @@ 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; + EnumSet<Format> formats_set = info.getFormats(); + int flen = formats_set.size(); 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$ - 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 +185,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 +195,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 +262,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 +294,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..0d5e209 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,27 +47,24 @@ 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, - new AttributeInfo(xmlLocalName, new Format[] { Format.REFERENCE })); + xmlLocalName, nsUri, + new AttributeInfo(xmlLocalName, Format.REFERENCE_SET)); } }; /** * 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..032363d 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,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.views.properties.IPropertyDescriptor; +import java.util.EnumSet; +import java.util.Locale; + /** * Describes a textual XML attribute. @@ -43,35 +49,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 +148,80 @@ 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 + EnumSet<Format> formats_list = info.getFormats(); + int flen = formats_list.size(); + 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$ + boolean isFirst = true; + for (Format f : formats_list) { + if (isFirst) { + isFirst = false; + } else { + sb.append(", "); + } + sb.append(f.toString().toLowerCase(Locale.US)); + } + // 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 +255,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..5603322 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 @@ -85,8 +85,6 @@ public class DrawableDescriptors implements IDescriptorProvider { public synchronized void updateDescriptors(Map<String, DeclareStyleableInfo> styleMap) { XmlnsAttributeDescriptor xmlns = new XmlnsAttributeDescriptor(ANDROID_NS_NAME, SdkConstants.NS_RESOURCES); - Format[] referenceFormat = new Format[] { Format.REFERENCE }; - List<ElementDescriptor> descriptors = new ArrayList<ElementDescriptor>(); AnimatorDescriptors.addElement(descriptors, styleMap, @@ -213,10 +211,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", Format.REFERENCE_SET)) + .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..10e1a4d 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; @@ -103,14 +104,13 @@ public final class LayoutDescriptors implements IDescriptorProvider { new DocumentDescriptor("layout_doc", null); //$NON-NLS-1$ /** The list of all known ViewLayout descriptors. */ - private List<ViewElementDescriptor> mLayoutDescriptors = - new ArrayList<ViewElementDescriptor>(); + private List<ViewElementDescriptor> mLayoutDescriptors = Collections.emptyList(); /** Read-Only list of View Descriptors. */ private List<ViewElementDescriptor> mROLayoutDescriptors; /** The list of all known View (not ViewLayout) descriptors. */ - private List<ViewElementDescriptor> mViewDescriptors = new ArrayList<ViewElementDescriptor>(); + private List<ViewElementDescriptor> mViewDescriptors = Collections.emptyList(); /** Read-Only list of View Descriptors. */ private List<ViewElementDescriptor> mROViewDescriptors; @@ -276,7 +276,7 @@ public final class LayoutDescriptors implements IDescriptorProvider { // All views and groups have an implicit "style" attribute which is a reference. AttributeInfo styleInfo = new AttributeInfo( "style", //$NON-NLS-1$ xmlLocalName - new Format[] { Format.REFERENCE }); + Format.REFERENCE_SET); styleInfo.setJavaDoc("A reference to a custom style"); //tooltip DescriptorsUtils.appendAttribute(attributes, "style", //$NON-NLS-1$ @@ -385,7 +385,7 @@ public final class LayoutDescriptors implements IDescriptorProvider { null, //nsUri new AttributeInfo( ATTR_LAYOUT, - new Format[] { Format.REFERENCE } ), + Format.REFERENCE_SET ), true, //required null); //overrides @@ -394,7 +394,7 @@ public final class LayoutDescriptors implements IDescriptorProvider { SdkConstants.NS_RESOURCES, //nsUri new AttributeInfo( "id", //$NON-NLS-1$ - new Format[] { Format.REFERENCE } ), + Format.REFERENCE_SET ), true, //required null); //overrides @@ -453,13 +453,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", - new AttributeInfo(ATTR_CLASS, new Format[] { Format.STRING}), - true /*mandatory*/); + ATTR_CLASS, null /* namespace */, + new AttributeInfo(ATTR_CLASS, Format.STRING_SET), + true /*mandatory*/) + .setTooltip("Supply the name of the fragment class to instantiate"); if (style != null) { descriptor = new ViewElementDescriptor( @@ -493,17 +493,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", - new AttributeInfo(ATTR_NAME, new Format[] { Format.STRING}), - true /*mandatory*/), + ATTR_NAME, ANDROID_URI, + new AttributeInfo(ATTR_NAME, Format.STRING_SET), + 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", - new AttributeInfo(ATTR_TAG, new Format[] { Format.STRING}), - true /*mandatory*/), + ATTR_TAG, ANDROID_URI, + new AttributeInfo(ATTR_TAG, Format.STRING_SET), + 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..e3b3aa6 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, Format.REFERENCE_SET)).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,12 +250,10 @@ 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 } ); + attrInfo = new AttributeInfo(xmlName, Format.STRING_SET ); } if (SdkConstants.CLASS_ACTIVITY.equals(className)) { @@ -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..e5fe678 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,10 +1482,8 @@ 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 - new AttributeInfo(xmlAttrLocalName, new Format[] { Format.STRING } ) + xmlNsUri, // ui name + new AttributeInfo(xmlAttrLocalName, Format.STRING_SET) ); UiAttributeNode uiAttr = desc.createUiNode(this); mUnknownUiAttributes.add(uiAttr); 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..e50c541 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 @@ -27,6 +27,8 @@ import com.android.ide.eclipse.adt.internal.editors.descriptors.TextAttributeDes import com.android.ide.eclipse.adt.internal.editors.descriptors.TextValueDescriptor; import com.android.resources.ResourceType; +import java.util.EnumSet; + /** * Complete description of the structure for resources XML files (under res/values/) @@ -81,7 +83,7 @@ public final class ValuesDescriptors implements IDescriptorProvider { // Elements - AttributeInfo nameAttrInfo = new AttributeInfo(NAME_ATTR, new Format[] { Format.STRING } ); + AttributeInfo nameAttrInfo = new AttributeInfo(NAME_ATTR, Format.STRING_SET); ElementDescriptor color_element = new ElementDescriptor( COLOR_ELEMENT, @@ -90,13 +92,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 +109,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,24 +126,19 @@ 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 } + EnumSet.of(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 } + EnumSet.of(Format.STRING, Format.FLAG) ).setFlagValues( new String[] { "boolean", //$NON-NLS-1$ @@ -155,7 +150,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 +165,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 +182,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 +199,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 })), + Format.STRING_SET)) + .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 +216,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 +235,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 +262,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/common/layout/LinearLayoutRuleTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java index a703a6f..cec3a9b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java @@ -175,7 +175,7 @@ public class LinearLayoutRuleTest extends LayoutTestBase { initialize(rule, "android.widget.LinearLayout"); TestNode node = TestNode.create("android.widget.LinearLayout").id("@+id/LinearLayout012"); node.putAttributeInfo(ANDROID_URI, "orientation", - new TestAttributeInfo(ATTR_ORIENTATION, new Format[] { Format.ENUM }, + new TestAttributeInfo(ATTR_ORIENTATION, Format.ENUM_SET, "android.widget.LinearLayout", new String[] {"horizontal", "vertical"}, null, null)); @@ -209,13 +209,13 @@ public class LinearLayoutRuleTest extends LayoutTestBase { initialize(rule, "android.widget.LinearLayout"); TestNode node = TestNode.create("android.widget.LinearLayout").id("@+id/LinearLayout012"); node.putAttributeInfo(ANDROID_URI, "orientation", - new TestAttributeInfo(ATTR_ORIENTATION, new Format[] { Format.ENUM }, + new TestAttributeInfo(ATTR_ORIENTATION, Format.ENUM_SET, "android.widget.LinearLayout", new String[] {"horizontal", "vertical"}, null, null)); node.setAttributeSources(Arrays.asList("android.widget.LinearLayout", "android.view.ViewGroup", "android.view.View")); node.putAttributeInfo(ANDROID_URI, "gravity", - new TestAttributeInfo("gravity", new Format[] { Format.INTEGER }, + new TestAttributeInfo("gravity", Format.INTEGER_SET, "android.widget.LinearLayout", null, null, null)); diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java index ee04260..f4f83c1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java @@ -17,10 +17,12 @@ package com.android.ide.common.layout; import com.android.ide.common.api.IAttributeInfo; +import java.util.EnumSet; + /** Test/mock implementation of {@link IAttributeInfo} */ public class TestAttributeInfo implements IAttributeInfo { private final String mName; - private final Format[] mFormats; + private final EnumSet<Format> mFormats; private final String mDefinedBy; private final String[] mEnumValues; private final String[] mFlagValues; @@ -30,7 +32,7 @@ public class TestAttributeInfo implements IAttributeInfo { this(name, null, null, null, null, null); } - public TestAttributeInfo(String name, Format[] formats, String definedBy, + public TestAttributeInfo(String name, EnumSet<Format> formats, String definedBy, String[] enumValues, String[] flagValues, String javadoc) { super(); this.mName = name; @@ -57,7 +59,7 @@ public class TestAttributeInfo implements IAttributeInfo { } @Override - public Format[] getFormats() { + public EnumSet<Format> getFormats() { return mFormats; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/resources/platform/AttrsXmlParserTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/resources/platform/AttrsXmlParserTest.java index 6b0ddd3..e57e5cd 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/resources/platform/AttrsXmlParserTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/resources/platform/AttrsXmlParserTest.java @@ -35,7 +35,7 @@ public class AttrsXmlParserTest extends TestCase { @Override public void setUp() throws Exception { - mFilePath = AdtTestData.getInstance().getTestFilePath(MOCK_DATA_PATH); //$NON-NLS-1$ + mFilePath = AdtTestData.getInstance().getTestFilePath(MOCK_DATA_PATH); mParser = new AttrsXmlParser(mFilePath, new TestLogger()); } @@ -65,8 +65,8 @@ public class AttrsXmlParserTest extends TestCase { AttributeInfo[] attrs = info.getAttributes(); assertEquals(1, attrs.length); assertEquals("scrollbarSize", info.getAttributes()[0].getName()); - assertEquals(1, info.getAttributes()[0].getFormats().length); - assertEquals(Format.DIMENSION, info.getAttributes()[0].getFormats()[0]); + assertEquals(1, info.getAttributes()[0].getFormats().size()); + assertEquals(Format.DIMENSION, info.getAttributes()[0].getFormats().iterator().next()); } public final void testEnumFlagValues() throws Exception { 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..5f01766 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,10 +44,8 @@ public class UiElementPullParserTest extends TestCase { private TextAttributeDescriptor createTextAttrDesc(String xmlName) { return new TextAttributeDescriptor( xmlName, // xmlLocalName - xmlName, // uiName - SdkConstants.NS_RESOURCES, // ns uri - "", // tooltip - new AttributeInfo(xmlName, new Format[] { Format.STRING }) + SdkConstants.NS_RESOURCES, + new AttributeInfo(xmlName, Format.STRING_SET) ); } diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh index b274ed3..25dce68 100755 --- a/eclipse/scripts/create_all_symlinks.sh +++ b/eclipse/scripts/create_all_symlinks.sh @@ -1,43 +1,81 @@ #!/bin/bash +# See usage() below for the description. + +function usage() { + cat <<EOF # This script copies the .jar files that each plugin depends on into the plugins libs folder. # By default, on Mac & Linux, this script creates symlinks from the libs folder to the jar file. # Since Windows does not support symlinks, the jar files are copied. -# Use option "-f" to copy files rather than creating symlinks on the Mac/Linux platforms. +# +# Options: +# -f : to copy files rather than creating symlinks on the Mac/Linux platforms. +# -d : print make dependencies instead of running make; doesn't copy files. +# -c : copy files expected after make dependencies (reported by -d) have been built. +# +# The purpose of -d/-c is to include the workflow in a make file: +# - the make rule should depend on \$(shell create_all_symlinks -d) +# - the rule body should perform \$(shell create_all_symlinks -c [-f]) +EOF +} -echo "## Running $0" # CD to the top android directory PROG_DIR=`dirname "$0"` cd "${PROG_DIR}/../../../" HOST=`uname` -USE_COPY="" # force copy dependent jar files rather than creating symlinks +USE_COPY="" # force copy dependent jar files rather than creating symlinks +ONLY_SHOW_DEPS="" # only report make dependencies but don't build them nor copy. +ONLY_COPY_DEPS="" # only copy dependencies built by make; uses -f as needed. function die() { - echo "Error: $*" + echo "Error: $*" >/dev/stderr exit 1 } +function warn() { + # Only print something if not in show-deps mode + if [[ -z $ONLY_SHOW_DEPS ]]; then + echo "$*" + fi +} + ## parse arguments while [ $# -gt 0 ]; do - if [ "$1" == "-f" ]; then - USE_COPY="1" - fi + case "$1" in + "-f" ) + USE_COPY="1" + ;; + "-d" ) + ONLY_SHOW_DEPS="1" + ;; + "-c" ) + ONLY_COPY_DEPS="1" + ;; + * ) + usage + exit 2 + esac shift done -if [ "$HOST" == "Linux" ]; then +warn "## Running $0" + +if [[ "${HOST:0:6}" == "CYGWIN" || "$USE_MINGW" == "1" ]]; then + # This is either Cygwin or Linux/Mingw cross-compiling to Windows. + PLATFORM="windows-x86" + if [[ "${HOST:0:6}" == "CYGWIN" ]]; then + # We can't use symlinks under Cygwin + USE_COPY="1" + fi +elif [[ "$HOST" == "Linux" ]]; then PLATFORM="linux-x86" -elif [ "$HOST" == "Darwin" ]; then +elif [[ "$HOST" == "Darwin" ]]; then PLATFORM="darwin-x86" -elif [ "${HOST:0:6}" == "CYGWIN" ]; then - USE_COPY="1" # We can't use symlinks under Cygwin - PLATFORM="windows-x86" else - echo "Unsupported platform ($HOST). Aborting." - exit 1 + die "Unsupported platform ($HOST). Aborting." fi -if [ "$USE_COPY" == "1" ]; then +if [[ "$USE_COPY" == "1" ]]; then function cpfile { # $1=source $2=dest cp -fv $1 $2/ } @@ -167,25 +205,32 @@ if [[ $PLATFORM != "windows-x86" ]]; then CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS $GLD_PREBUILTS" fi -# Make sure we have lunch sdk-<something> -if [[ ! "$TARGET_PRODUCT" ]]; then - echo "## TARGET_PRODUCT is not set, running build/envsetup.sh" - . build/envsetup.sh - echo "## lunch sdk-eng" - lunch sdk-eng +# In the mode to only echo dependencies, output them and we're done +if [[ -n $ONLY_SHOW_DEPS ]]; then + echo $LIBS + exit 0 fi -# Run make on all libs +if [[ -z $ONLY_COPY_DEPS ]]; then + # Make sure we have lunch sdk-<something> + if [[ ! "$TARGET_PRODUCT" ]]; then + warn "## TARGET_PRODUCT is not set, running build/envsetup.sh" + . build/envsetup.sh + warn "## lunch sdk-eng" + lunch sdk-eng + fi -J="4" -[[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ') -[[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l) + # Run make on all libs -echo "## Building libs: make -j$J $LIBS" -make -j${J} $LIBS + J="4" + [[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ') + [[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l) -# Copy resulting files + warn "## Building libs: make -j$J $LIBS" + make -j${J} $LIBS +fi +# Copy resulting files DEST="" for SRC in $CP_FILES; do if [[ "${SRC:0:2}" == "@:" ]]; then diff --git a/eclipse/scripts/rcp/Android.mk b/eclipse/scripts/rcp/Android.mk new file mode 100644 index 0000000..0fab0ed --- /dev/null +++ b/eclipse/scripts/rcp/Android.mk @@ -0,0 +1,41 @@ +# Copyright 2012 The Android Open Source Project + +#LOCAL_PATH := $(call my-dir) +#include $(CLEAR_VARS) +# +#LOCAL_MODULE := monitor +#LOCAL_MODULE_CLASS := EXECUTABLES +#LOCAL_MODULE_TAGS := optional +#LOCAL_IS_HOST_MODULE := true +#include $(BUILD_SYSTEM)/base_rules.mk +# +#RCP_MONITOR_DIR := $(TOPDIR)out/host/eclipse/rcp/build/I.RcpBuild +# +#define mk-rcp-monitor-atree-file +# srczip=$(RCP_MONITOR_DIR)/RcpBuild-$(1).$(2).zip && \ +# dstdir=$(HOST_OUT)/eclipse/monitor-$(1).$(2) && \ +# rm -rf $(V) $$dstdir && \ +# mkdir -p $$dstdir && \ +# unzip -q $$srczip -d $$dstdir +#endef +# +## The RCP monitor. It is referenced by build/target/products/sdk.mk +#$(LOCAL_BUILT_MODULE) : $(TOPDIR)sdk/eclipse/scripts/rcp/monitor \ +# $(TOPDIR)sdk/eclipse/scripts/rcp/build.xml \ +# $(TOPDIR)sdk/eclipse/scripts/rcp/build.properties \ +# $(shell $(TOPDIR)sdk/eclipse/scripts/create_all_symlinks.sh -d) +# @mkdir -p $(dir $@) +# $(hide)$(TOPDIR)sdk/eclipse/scripts/create_all_symlinks.sh -c +# $(hide)cd $(TOPDIR)sdk/eclipse/scripts/rcp && ant -DbuildFor=$(HOST_OS) +# $(hide)cp $(V) $(TOPDIR)sdk/eclipse/scripts/rcp/monitor $@ +# $(hide)if [[ $(HOST_OS) == "linux" ]]; then \ +# $(call mk-rcp-monitor-atree-file,linux.gtk,x86) ; \ +# $(call mk-rcp-monitor-atree-file,linux.gtk,x86_64) ; \ +# fi +# $(hide)if [[ $(HOST_OS) == "darwin" ]]; then \ +# $(call mk-rcp-monitor-atree-file,macosx.cocoa,x86_64) ; \ +# fi +# $(hide)if [[ $(HOST_OS) == "windows" ]]; then \ +# $(call mk-rcp-monitor-atree-file,win32.win32,x86) ; \ +# $(call mk-rcp-monitor-atree-file,win32.win32,x86_64) ; \ +# fi diff --git a/eclipse/scripts/rcp/monitor b/eclipse/scripts/rcp/monitor new file mode 100755 index 0000000..be4a1cd --- /dev/null +++ b/eclipse/scripts/rcp/monitor @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2012, The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Set up prog to be the path of this script, including following symlinks, +# and set up progdir to be the fully-qualified pathname of its directory. +prog="$0" +while [ -h "${prog}" ]; do + newProg=`/bin/ls -ld "${prog}"` + newProg=`expr "${newProg}" : ".* -> \(.*\)$"` + if expr "x${newProg}" : 'x/' >/dev/null; then + prog="${newProg}" + else + progdir=`dirname "${prog}"` + prog="${progdir}/${newProg}" + fi +done +oldwd=`pwd` +progdir=`dirname "${prog}"` +cd "${progdir}" + +javaCmd="java" + +vmarch=`${javaCmd} -jar tools/lib/archquery.jar` + +exec tools/lib/monitor-${vmarch}/monitor + diff --git a/eclipse/scripts/rcp/monitor.bat b/eclipse/scripts/rcp/monitor.bat new file mode 100755 index 0000000..bc69849 --- /dev/null +++ b/eclipse/scripts/rcp/monitor.bat @@ -0,0 +1,27 @@ +@echo off
+rem Copyright (C) 2012 The Android Open Source Project
+rem
+rem Licensed under the Apache License, Version 2.0 (the "License");
+rem you may not use this file except in compliance with the License.
+rem You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+rem don't modify the caller's environment
+setlocal
+
+rem Change current directory and drive to where the script is, to avoid
+rem issues with directories containing whitespaces.
+cd /d %~dp0
+
+:QueryArch
+for /f %%a in ('%java_exe% -jar tools\lib\archquery.jar') do set vmarch=%%a
+
+call tools\lib\monitor-%vmarch%\monitor
+
|