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

UiAbstractTextAttributeNode

public abstract class UiAbstractTextAttributeNode extends UiAttributeNode implements IUiSettableAttributeNode
Represents an XML attribute in that can be modified using a simple text field in the XML editor's user interface.

The XML attribute has no default value. When unset, the text field is blank. When updating the XML, if the field is empty, the attribute will be removed from the XML element.

See {@link UiAttributeNode} for more information.

Fields Summary
protected static final String
DEFAULT_VALUE
private boolean
mInternalTextModification
Prevent internal listener from firing when internally modifying the text
private String
mCurrentValue
Last value read from the XML model. Cannot be null.
Constructors Summary
public UiAbstractTextAttributeNode(com.android.ide.eclipse.editors.descriptors.AttributeDescriptor attributeDescriptor, UiElementNode uiParent)


      
              
        super(attributeDescriptor, uiParent);
    
Methods Summary
public voidcommit()

        UiElementNode parent = getUiParent();
        if (parent != null && isValid() && isDirty()) {
            String value = getTextWidgetValue();
            if (parent.commitAttributeToXml(this, value)) {
                mCurrentValue = value;
                setDirty(false);
            }
        }
    
public final java.lang.StringgetCurrentValue()
Returns the current value of the node.

        return mCurrentValue;
    
public abstract java.lang.StringgetTextWidgetValue()
Returns the text value present in the UI.

protected final booleanisInInternalTextModification()

        return mInternalTextModification;
    
public abstract booleanisValid()
Returns if the attribute node is valid, and its UI has been created.

public final voidsetCurrentValue(java.lang.String value)
Sets the current value of the node. Cannot be null (use an empty string).

        mCurrentValue = value;
    
protected final voidsetInInternalTextModification(boolean internalTextModification)

        mInternalTextModification = internalTextModification;
    
public abstract voidsetTextWidgetValue(java.lang.String value)
Sets the text value to be displayed in the UI.

public voidupdateValue(org.w3c.dom.Node xml_attribute_node)
Updates the current text field's value when the XML has changed.

The caller doesn't really know if attributes have changed, so it will call this to refresh the attribute anyway. The value is only set if it has changed.

This also resets the "dirty" flag.

        mCurrentValue = DEFAULT_VALUE;
        if (xml_attribute_node != null) {
            mCurrentValue = xml_attribute_node.getNodeValue();
        }

        if (isValid() && !getTextWidgetValue().equals(mCurrentValue)) {
            try {
                mInternalTextModification = true;
                setTextWidgetValue(mCurrentValue);
                setDirty(false);
            } finally {
                mInternalTextModification = false;
            }
        }