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

UiAttributeNode

public abstract class UiAttributeNode extends Object
Represents an XML attribute that can be modified by the XML editor's user interface.

The characteristics of an {@link UiAttributeNode} are declared by a corresponding {@link AttributeDescriptor}.

This is an abstract class. Derived classes must implement the creation of the UI and manage its synchronization with the XML.

Fields Summary
private com.android.ide.eclipse.editors.descriptors.AttributeDescriptor
mDescriptor
private UiElementNode
mUiParent
private boolean
mIsDirty
private boolean
mHasError
Constructors Summary
public UiAttributeNode(com.android.ide.eclipse.editors.descriptors.AttributeDescriptor attributeDescriptor, UiElementNode uiParent)
Creates a new {@link UiAttributeNode} linked to a specific {@link AttributeDescriptor} and the corresponding runtine {@link UiElementNode} parent.

        mDescriptor = attributeDescriptor;
        mUiParent = uiParent;
    
Methods Summary
public abstract voidcommit()
Called by the user interface when the editor is saved or its state changed and the modified attributes must be committed (i.e. written) to the XML model.

Important behaviors:

  • The caller *must* have called IStructuredModel.aboutToChangeModel before. The implemented methods must assume it is safe to modify the XML model.
  • On success, the implementation *must* call setDirty(false).
  • On failure, the implementation can fail with an exception, which is trapped and logged by the caller, or do nothing, whichever is more appropriate.

public abstract voidcreateUiControl(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.forms.IManagedForm managedForm)
Called once by the parent user interface to creates the necessary user interface to edit this attribute.

This method can be called more than once in the life cycle of an UI node, typically when the UI is part of a master-detail tree, as pages are swapped.

param
parent The composite where to create the user interface.
param
managedForm The managed form owning this part.

public abstract java.lang.StringgetCurrentValue()
Returns the current value of the node.

public final com.android.ide.eclipse.editors.descriptors.AttributeDescriptorgetDescriptor()
Returns the {@link AttributeDescriptor} specific to this UI attribute node

        return mDescriptor;
    
public abstract java.lang.String[]getPossibleValues(java.lang.String prefix)
Used to get a list of all possible values for this UI attribute.

This is used, among other things, by the XML Content Assists to complete values for an attribute.

Implementations that do not have any known values should return null.

param
prefix An optional prefix string, which is whatever the user has already started typing. Can be null or an empty string. The implementation can use this to filter choices and only return strings that match this prefix. A lazy or default implementation can simply ignore this and return everything.
return
A list of possible completion values, and empty array or null.

public final UiElementNodegetUiParent()
Returns the {@link UiElementNode} that owns this {@link UiAttributeNode}

        return mUiParent;
    
public final booleanhasError()
Returns whether this node has errors.

        return mHasError;
    
public final booleanisDirty()

return
True if the attribute has been changed since it was last loaded from the XML model.

        return mIsDirty;
    
public voidsetDirty(boolean isDirty)
Sets whether the attribute is dirty and also notifies the editor some part's dirty flag as changed.

Subclasses should set the to true as a result of user interaction with the widgets in the section and then should set to false when the commit() method completed.

        boolean old_value = mIsDirty;
        mIsDirty = isDirty;
        // TODO: for unknown attributes, getParent() != null && getParent().getEditor() != null
        if (old_value != isDirty) {
            getUiParent().getEditor().editorDirtyStateChanged();
        }
    
public final voidsetHasError(boolean errorFlag)
Sets the error flag value.

param
errorFlag the error flag

        mHasError = errorFlag;
    
public abstract voidupdateValue(org.w3c.dom.Node xml_attribute_node)
Called when the XML is being loaded or has changed to update the value held by this user interface attribute node.

The XML Node may be null, which denotes that the attribute is not specified in the XML model. In general, this means the "default" value of the attribute should be used.

The caller doesn't really know if attributes have changed, so it will call this to refresh the attribute anyway. It's up to the UI implementation to minimize refreshes.

param
xml_attribute_node