FileDocCategorySizeDatePackage
UiManifestElementNode.javaAPI DocAndroid 1.5 API4084Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.manifest.model

UiManifestElementNode

public final class UiManifestElementNode extends com.android.ide.eclipse.editors.uimodel.UiElementNode
Represents an XML node that can be modified by the user interface in the XML editor.

Each tree viewer used in the application page's parts needs to keep a model representing each underlying node in the tree. This interface represents the base type for such a node.

Each node acts as an intermediary model between the actual XML model (the real data support) and the tree viewers or the corresponding page parts.

Element nodes don't contain data per se. Their data is contained in their attributes as well as their children's attributes, see {@link UiAttributeNode}.

The structure of a given {@link UiElementNode} is declared by a corresponding {@link ElementDescriptor}.

Fields Summary
Constructors Summary
public UiManifestElementNode(com.android.ide.eclipse.editors.manifest.descriptors.ManifestElementDescriptor elementDescriptor)
Creates a new {@link UiElementNode} described by a given {@link ElementDescriptor}.

param
elementDescriptor The {@link ElementDescriptor} for the XML node. Cannot be null.

        super(elementDescriptor);
    
Methods Summary
public java.lang.StringgetShortDescription()
Computes a short string describing the UI node suitable for tree views. Uses the element's attribute "android:name" if present, or the "android:label" one followed by the element's name.

return
A short string describing the UI node suitable for tree views.

        if (getXmlNode() != null &&
                getXmlNode() instanceof Element &&
                getXmlNode().hasAttributes()) {

            AndroidManifestDescriptors manifestDescriptors =
                    getAndroidTarget().getManifestDescriptors();
            
            // Application and Manifest nodes have a special treatment: they are unique nodes
            // so we don't bother trying to differentiate their strings and we fall back to
            // just using the UI name below.
            ElementDescriptor desc = getDescriptor();
            if (desc != manifestDescriptors.getManifestElement() &&
                    desc != manifestDescriptors.getApplicationElement()) {
                Element elem = (Element) getXmlNode();
                String attr = elem.getAttributeNS(SdkConstants.NS_RESOURCES,
                                                  AndroidManifestDescriptors.ANDROID_NAME_ATTR);
                if (attr == null || attr.length() == 0) {
                    attr = elem.getAttributeNS(SdkConstants.NS_RESOURCES,
                                               AndroidManifestDescriptors.ANDROID_LABEL_ATTR);
                }
                if (attr != null && attr.length() > 0) {
                    return String.format("%1$s (%2$s)", attr, getDescriptor().getUiName());
                }
            }
        }

        return String.format("%1$s", getDescriptor().getUiName());