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.
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());