FileDocCategorySizeDatePackage
UiDocumentNode.javaAPI DocAndroid 1.5 API5009Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.uimodel

UiDocumentNode

public class UiDocumentNode extends UiElementNode
Represents an XML document node that can be modified by the user interface in the XML editor.

The structure of a given {@link UiDocumentNode} is declared by a corresponding {@link DocumentDescriptor}.

Fields Summary
Constructors Summary
public UiDocumentNode(com.android.ide.eclipse.editors.descriptors.DocumentDescriptor documentDescriptor)
Creates a new {@link UiDocumentNode} described by a given {@link DocumentDescriptor}.

param
documentDescriptor The {@link DocumentDescriptor} for the XML node. Cannot be null.

        super(documentDescriptor);
    
Methods Summary
public org.w3c.dom.NodecreateXmlNode()
This method throws an exception if there is no underlying XML document.

XML documents cannot be created per se -- they are a by-product of the StructuredEditor XML parser.

return
The current value of getXmlDocument().

        if (getXmlDocument() == null) {
            // By design, a document node cannot be created, it is owned by the XML parser.
            // By "design" this should never happen since the XML parser always creates an XML
            // document container, even for an empty file.
            throw new UnsupportedOperationException("Documents cannot be created"); //$NON-NLS-1$
        }
        return getXmlDocument();
    
public org.w3c.dom.NodedeleteXmlNode()
This method throws an exception and does not even try to delete the XML document.

XML documents cannot be deleted per se -- they are a by-product of the StructuredEditor XML parser.

return
The removed node or null if it didn't exist in the firtst place.

        // DEBUG. Change to log warning.
        throw new UnsupportedOperationException("Documents cannot be deleted"); //$NON-NLS-1$
    
public java.lang.StringgetBreadcrumbTrailDescription(boolean include_root)
Computes a "breadcrumb trail" description for this node.

param
include_root Whether to include the root (e.g. "Manifest") or not. Has no effect when called on the root node itself.
return
The "breadcrumb trail" description for this node.

        return "Document"; //$NON-NLS-1$
    
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.

        return "Document"; //$NON-NLS-1$
    
public booleanloadFromXmlNode(org.w3c.dom.Node xml_node)
Populate this element node with all values from the given XML node. This fails if the given XML node has a different element name -- it won't change the type of this ui node. This method can be both used for populating values the first time and updating values after the XML model changed.

param
xml_node The XML node to mirror
return
Returns true if the XML structure has changed (nodes added, removed or replaced)

        boolean structure_changed = (getXmlDocument() != xml_node);
        setXmlDocument((Document) xml_node);
        structure_changed |= super.loadFromXmlNode(xml_node);
        if (structure_changed) {
            invokeUiUpdateListeners(UiUpdateState.CHILDREN_CHANGED);
        }
        return structure_changed;
    
protected voidsetUiParent(UiElementNode parent)
This method throws an exception when attempted to assign a parent, since XML documents cannot have a parent. It is OK to assign null.

        if (parent != null) {
            // DEBUG. Change to log warning.
            throw new UnsupportedOperationException("Documents can't have UI parents"); //$NON-NLS-1$
        }
        super.setUiParent(null);