FileDocCategorySizeDatePackage
ListValueCellEditor.javaAPI DocAndroid 1.5 API2531Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.ui

ListValueCellEditor

public class ListValueCellEditor extends org.eclipse.jface.viewers.ComboBoxCellEditor
ComboBoxCellEditor able to receive a {@link UiListAttributeNode} in the {@link #setValue(Object)} method, and returning a {@link String} in {@link #getValue()} instead of an {@link Integer}.

Fields Summary
private String[]
mItems
private org.eclipse.swt.custom.CCombo
mCombo
Constructors Summary
public ListValueCellEditor(org.eclipse.swt.widgets.Composite parent)

        super(parent, new String[0], SWT.DROP_DOWN);
    
Methods Summary
protected org.eclipse.swt.widgets.ControlcreateControl(org.eclipse.swt.widgets.Composite parent)

        mCombo = (CCombo) super.createControl(parent);
        return mCombo;
    
protected java.lang.ObjectdoGetValue()

        String comboText = mCombo.getText();
        if (comboText == null) {
            return ""; //$NON-NLS-1$
        }
        return comboText;
    
protected voiddoSetValue(java.lang.Object value)

        if (value instanceof UiListAttributeNode) {
            UiListAttributeNode uiListAttribute = (UiListAttributeNode)value;
            
            // set the possible values in the combo
            String[] items = uiListAttribute.getPossibleValues(null);
            mItems = new String[items.length];
            System.arraycopy(items, 0, mItems, 0, items.length);
            setItems(mItems);
            
            // now edit the current value of the attribute
            String attrValue = uiListAttribute.getCurrentValue();
            mCombo.setText(attrValue);
            
            return;
        }
        
        // default behavior
        super.doSetValue(value);