Methods Summary |
---|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | convertPref(com.android.ide.eclipse.common.resources.ViewClassInfo info)Creates an element descriptor from a given {@link ViewClassInfo}.
String xml_name = info.getShortClassName();
String tooltip = info.getJavaDoc();
// Process all Preference attributes
ArrayList<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>();
DescriptorsUtils.appendAttributes(attributes,
null, // elementName
SdkConstants.NS_RESOURCES,
info.getAttributes(),
null, // requiredAttributes
null); // overrides
for (ViewClassInfo link = info.getSuperClass();
link != null;
link = link.getSuperClass()) {
AttributeInfo[] attrList = link.getAttributes();
if (attrList.length > 0) {
attributes.add(new SeparatorAttributeDescriptor(
String.format("Attributes from %1$s", link.getShortClassName())));
DescriptorsUtils.appendAttributes(attributes,
null, // elementName
SdkConstants.NS_RESOURCES,
attrList,
null, // requiredAttributes
null); // overrides
}
}
return new ViewElementDescriptor(xml_name,
xml_name, // ui_name
info.getCanonicalClassName(),
tooltip,
null, // sdk_url
attributes.toArray(new AttributeDescriptor[attributes.size()]),
null,
null, // children
false /* mandatory */);
|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | createAppWidgetProviderInfo(java.util.Map appWidgetStyleMap, com.android.ide.eclipse.editors.descriptors.XmlnsAttributeDescriptor xmlns)Returns the new ElementDescriptor for
if (appWidgetStyleMap == null) {
return null;
}
ElementDescriptor appWidget = createElement(appWidgetStyleMap,
"AppWidgetProviderInfo", //$NON-NLS-1$ styleName
"appwidget-provider", //$NON-NLS-1$ xmlName
"AppWidget Provider", // uiName
null, // sdk url
xmlns, // extraAttribute
null, // childrenElements
false /* mandatory */ );
return appWidget;
|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | createElement(java.util.Map styleMap, java.lang.String styleName, java.lang.String xmlName, java.lang.String uiName, java.lang.String sdkUrl, com.android.ide.eclipse.editors.descriptors.AttributeDescriptor extraAttribute, com.android.ide.eclipse.editors.descriptors.ElementDescriptor[] childrenElements, boolean mandatory)Returns a new ElementDescriptor constructed from the information given here
and the javadoc & attributes extracted from the style map if any.
ElementDescriptor element = new ElementDescriptor(xmlName, uiName, null, sdkUrl,
null, childrenElements, mandatory);
return updateElement(element, styleMap, styleName, extraAttribute);
|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | createPreference(com.android.ide.eclipse.common.resources.ViewClassInfo[] prefs, com.android.ide.eclipse.common.resources.ViewClassInfo[] prefGroups, com.android.ide.eclipse.editors.descriptors.XmlnsAttributeDescriptor xmlns)Returns the new ElementDescriptor for
ArrayList<ElementDescriptor> newPrefs = new ArrayList<ElementDescriptor>();
if (prefs != null) {
for (ViewClassInfo info : prefs) {
ElementDescriptor desc = convertPref(info);
newPrefs.add(desc);
}
}
ElementDescriptor topPreferences = null;
ArrayList<ElementDescriptor> newGroups = new ArrayList<ElementDescriptor>();
if (prefGroups != null) {
for (ViewClassInfo info : prefGroups) {
ElementDescriptor desc = convertPref(info);
newGroups.add(desc);
if (info.getCanonicalClassName() == AndroidConstants.CLASS_PREFERENCES) {
topPreferences = desc;
}
}
}
ArrayList<ElementDescriptor> everything = new ArrayList<ElementDescriptor>();
everything.addAll(newGroups);
everything.addAll(newPrefs);
ElementDescriptor[] newArray = everything.toArray(new ElementDescriptor[everything.size()]);
// Link all groups to everything else here.. recursively
for (ElementDescriptor layoutDesc : newGroups) {
layoutDesc.setChildren(newArray);
}
// The "top" element to be returned corresponds to the class "Preferences".
// Its descriptor has already been created. However the root one also needs
// the hidden xmlns:android definition..
if (topPreferences != null) {
AttributeDescriptor[] attrs = topPreferences.getAttributes();
AttributeDescriptor[] newAttrs = new AttributeDescriptor[attrs.length + 1];
System.arraycopy(attrs, 0, newAttrs, 0, attrs.length);
newAttrs[attrs.length] = xmlns;
return new ElementDescriptor(
topPreferences.getXmlName(),
topPreferences.getUiName(),
topPreferences.getTooltip(),
topPreferences.getSdkUrl(),
newAttrs,
topPreferences.getChildren(),
false /* mandatory */);
} else {
return null;
}
|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | createSearchable(java.util.Map searchableStyleMap, com.android.ide.eclipse.editors.descriptors.XmlnsAttributeDescriptor xmlns)Returns the new ElementDescriptor for
ElementDescriptor action_key = createElement(searchableStyleMap,
"SearchableActionKey", //$NON-NLS-1$ styleName
"actionkey", //$NON-NLS-1$ xmlName
"Action Key", // uiName
null, // sdk url
null, // extraAttribute
null, // childrenElements
false /* mandatory */ );
ElementDescriptor searchable = createElement(searchableStyleMap,
"Searchable", //$NON-NLS-1$ styleName
"searchable", //$NON-NLS-1$ xmlName
"Searchable", // uiName
null, // sdk url
xmlns, // extraAttribute
new ElementDescriptor[] { action_key }, // childrenElements
false /* mandatory */ );
return searchable;
|
public com.android.ide.eclipse.editors.descriptors.DocumentDescriptor | getAppWidgetDescriptor()
return mAppWidgetDescriptor;
|
public com.android.ide.eclipse.editors.descriptors.IDescriptorProvider | getAppWidgetProvider()
return new IDescriptorProvider() {
public ElementDescriptor getDescriptor() {
return mAppWidgetDescriptor;
}
public ElementDescriptor[] getRootElementDescriptors() {
return mAppWidgetDescriptor.getChildren();
}
};
|
public com.android.ide.eclipse.editors.descriptors.DocumentDescriptor | getDescriptor() //$NON-NLS-1$
return mDescriptor;
|
public com.android.ide.eclipse.editors.descriptors.DocumentDescriptor | getPreferencesDescriptor()
return mPrefDescriptor;
|
public com.android.ide.eclipse.editors.descriptors.IDescriptorProvider | getPreferencesProvider()
return new IDescriptorProvider() {
public ElementDescriptor getDescriptor() {
return mPrefDescriptor;
}
public ElementDescriptor[] getRootElementDescriptors() {
return mPrefDescriptor.getChildren();
}
};
|
public com.android.ide.eclipse.editors.descriptors.ElementDescriptor[] | getRootElementDescriptors()
return mDescriptor.getChildren();
|
public com.android.ide.eclipse.editors.descriptors.DocumentDescriptor | getSearchableDescriptor()
return mSearchDescriptor;
|
public com.android.ide.eclipse.editors.descriptors.IDescriptorProvider | getSearchableProvider()
return new IDescriptorProvider() {
public ElementDescriptor getDescriptor() {
return mSearchDescriptor;
}
public ElementDescriptor[] getRootElementDescriptors() {
return mSearchDescriptor.getChildren();
}
};
|
public synchronized void | updateDescriptors(java.util.Map searchableStyleMap, java.util.Map appWidgetStyleMap, com.android.ide.eclipse.common.resources.ViewClassInfo[] prefs, com.android.ide.eclipse.common.resources.ViewClassInfo[] prefGroups)Updates the document descriptor.
It first computes the new children of the descriptor and then updates them
all at once.
XmlnsAttributeDescriptor xmlns = new XmlnsAttributeDescriptor(
"android", //$NON-NLS-1$
SdkConstants.NS_RESOURCES);
ElementDescriptor searchable = createSearchable(searchableStyleMap, xmlns);
ElementDescriptor appWidget = createAppWidgetProviderInfo(appWidgetStyleMap, xmlns);
ElementDescriptor preferences = createPreference(prefs, prefGroups, xmlns);
ArrayList<ElementDescriptor> list = new ArrayList<ElementDescriptor>();
if (searchable != null) {
list.add(searchable);
mSearchDescriptor.setChildren(new ElementDescriptor[]{ searchable });
}
if (appWidget != null) {
list.add(appWidget);
mAppWidgetDescriptor.setChildren(new ElementDescriptor[]{ appWidget });
}
if (preferences != null) {
list.add(preferences);
mPrefDescriptor.setChildren(new ElementDescriptor[]{ preferences });
}
if (list.size() > 0) {
mDescriptor.setChildren(list.toArray(new ElementDescriptor[list.size()]));
}
|
private com.android.ide.eclipse.editors.descriptors.ElementDescriptor | updateElement(com.android.ide.eclipse.editors.descriptors.ElementDescriptor element, java.util.Map styleMap, java.lang.String styleName, com.android.ide.eclipse.editors.descriptors.AttributeDescriptor extraAttribute)Updates an ElementDescriptor with the javadoc & attributes extracted from the style
map if any.
ArrayList<AttributeDescriptor> descs = new ArrayList<AttributeDescriptor>();
DeclareStyleableInfo style = styleMap != null ? styleMap.get(styleName) : null;
if (style != null) {
DescriptorsUtils.appendAttributes(descs,
null, // elementName
SdkConstants.NS_RESOURCES,
style.getAttributes(),
null, // requiredAttributes
null); // overrides
element.setTooltip(style.getJavaDoc());
}
if (extraAttribute != null) {
descs.add(extraAttribute);
}
element.setAttributes(descs.toArray(new AttributeDescriptor[descs.size()]));
return element;
|