FileDocCategorySizeDatePackage
UiColorValueNode.javaAPI DocAndroid 1.5 API3174Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.resources.uimodel

UiColorValueNode

public class UiColorValueNode extends com.android.ide.eclipse.editors.uimodel.UiTextValueNode
Displays and edits a color XML element value with a custom validator.

See {@link UiAttributeNode} for more information.

Fields Summary
private static final Pattern
RGBA_REGEXP
Accepted RGBA formats are one of #RGB, #ARGB, #RRGGBB or #AARRGGBB.
Constructors Summary
public UiColorValueNode(com.android.ide.eclipse.editors.descriptors.TextValueDescriptor attributeDescriptor, com.android.ide.eclipse.editors.uimodel.UiElementNode uiParent)

 //$NON-NLS-1$
    
         
        super(attributeDescriptor, uiParent);
    
Methods Summary
protected voidonAddValidators(org.eclipse.swt.widgets.Text text)

        ModifyListener listener = new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                String color = text.getText();
                if (RGBA_REGEXP.matcher(color).matches()) {
                    getManagedForm().getMessageManager().removeMessage(text, text);
                } else {
                    getManagedForm().getMessageManager().addMessage(text,
                            "Accepted color formats are one of #RGB, #ARGB, #RRGGBB or #AARRGGBB.",
                            null /* data */, IMessageProvider.ERROR, text);
                }
            }
        };

        text.addModifyListener(listener);

        // Make sure the validator removes its message(s) when the widget is disposed
        text.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                getManagedForm().getMessageManager().removeMessage(text, text);
            }
        });

        // Finally call the validator once to make sure the initial value is processed
        listener.modifyText(null);