com.ibm.commons.swt.data.editors.api
Class AbstractComboEditor

java.lang.Object
  extended by com.ibm.commons.swt.data.editors.api.PropertyEditor
      extended by com.ibm.commons.swt.data.editors.api.AbstractComboEditor
All Implemented Interfaces:
IPropertyEditor
Direct Known Subclasses:
BooleanEditor, ComboLookupEditor

public abstract class AbstractComboEditor
extends PropertyEditor

An editor for a property which can be set via a Combo control. Typically this property will have at least two known values.


Constructor Summary
AbstractComboEditor()
          Constructs a new instance of this class.
AbstractComboEditor(ILookup lookup)
          Constructs a new instance of this class with the given lookup.
 
Method Summary
protected  void comboAdd(org.eclipse.swt.widgets.Control combo, java.lang.String value)
           
protected  void comboDeselectAll(org.eclipse.swt.widgets.Control combo)
           
protected  java.lang.String comboGetItem(org.eclipse.swt.widgets.Control combo, int index)
           
protected  int comboGetItemCount(org.eclipse.swt.widgets.Control combo)
           
protected  int comboGetSelectionIndex(org.eclipse.swt.widgets.Control combo)
           
 java.lang.String comboGetText(org.eclipse.swt.widgets.Control combo)
           
protected  void comboRemove(org.eclipse.swt.widgets.Control combo, int index)
           
protected  void comboRemoveAll(org.eclipse.swt.widgets.Control combo, java.lang.String oldVal)
           
protected  void comboSelect(org.eclipse.swt.widgets.Control combo, int index)
           
protected  void comboSetText(org.eclipse.swt.widgets.Control combo, java.lang.String text)
           
 org.eclipse.swt.widgets.Control createControl(CompositeEditor parent)
          This method is called by the PropertyEditor during initialization.
 void fillCombo(org.eclipse.swt.widgets.Control combo)
          Initializes the given combo with the model options and current value.
 java.lang.String getDefaultValue()
           
 java.lang.String getFirstLineTitle()
          Return the title for the first line.
 com.ibm.commons.swt.data.controls.IListActions getListActions()
           
 ILookup getLookup()
          Returns the lookup that is used to populate the contents of the control.
 java.lang.String getRenderedValue(java.lang.String value)
          Return the value shown for the given model value.
 void initControlValue(CompositeEditor parent, java.lang.String value)
          Set the given value into the control created for this property editor.
 boolean isEditable()
          Return true if the user can type into the combo, false if they can only select from the options.
 boolean isFirstBlankLine()
          Return true if the combo should contain a blank line (null/empty) option.
 boolean isImmediateUpdate()
           
 void setComboValue(org.eclipse.swt.widgets.Control combo, java.lang.String value)
          Set the given value into the combo.
 void setDefaultValue(java.lang.String defaultValue)
           
 void setFirstBlankLine(boolean firstBlankLine)
          Set if the combo should contain a blank line (null/empty) option.
 void setFirstLineTitle(java.lang.String firstLineTitle)
          Set the title for the first line.
 void setId(java.lang.String id)
          Allows the implementor to associate an ID attribute with this control.
 void setListActions(com.ibm.commons.swt.data.controls.IListActions listActions)
           
 void setLookup(org.eclipse.swt.widgets.Control combo, ILookup lookup)
          Sets the lookup used to populate the contents of the control.
 void setLookup(ILookup lookup)
          Deprecated.  
 boolean stopEdit(CompositeEditor parent)
          Called to tell the current editor to stop editing the associated attribute.
 
Methods inherited from class com.ibm.commons.swt.data.editors.api.PropertyEditor
addPropertyEditorUpdateListener, addValidator, callDialog, getContextAttribute, getContextObject, getDefaultEditor, getDialogButtonAltText, getDialogButtonImage, getDialogButtonText, getEditor, getScriptMode, getTextValidator, getValidator, getWorkBenchPart, hasDialogButton, isScriptModeFixed, postModelUpdate, preModelUpdate, removePropertyEditorUpdateListener, setContextAttribute, setContextObject, setScriptMode, setValidator, setWorkBenchPart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractComboEditor

public AbstractComboEditor()
Constructs a new instance of this class.


AbstractComboEditor

public AbstractComboEditor(ILookup lookup)
Constructs a new instance of this class with the given lookup.

See Also:
ILookup
Method Detail

createControl

public org.eclipse.swt.widgets.Control createControl(CompositeEditor parent)
Description copied from class: PropertyEditor
This method is called by the PropertyEditor during initialization. This method creates the control that is used by the PropertyEditor to edit the associated property.

Specified by:
createControl in class PropertyEditor
Parameters:
parent - - The parent of the control
Returns:
Control - The 'control' used to edit this property (control is used liberally here as a composite of controls could be returned).

setId

public void setId(java.lang.String id)
Description copied from class: PropertyEditor
Allows the implementor to associate an ID attribute with this control. This may be of use later when trying to identify the control.

Specified by:
setId in class PropertyEditor

fillCombo

public void fillCombo(org.eclipse.swt.widgets.Control combo)
Initializes the given combo with the model options and current value. Fills the combo based on the values in getFirstLineTitle(), isFirstBlankLine(), getLookup().

Parameters:
Control -
See Also:
ILookup

initControlValue

public void initControlValue(CompositeEditor parent,
                             java.lang.String value)
Description copied from class: PropertyEditor
Set the given value into the control created for this property editor.

Specified by:
initControlValue in class PropertyEditor
See Also:
CompositeEditor

setComboValue

public void setComboValue(org.eclipse.swt.widgets.Control combo,
                          java.lang.String value)
Set the given value into the combo.

Parameters:
Control - - the current combo box control
String - - the desired value of the control

stopEdit

public boolean stopEdit(CompositeEditor parent)
Description copied from class: PropertyEditor
Called to tell the current editor to stop editing the associated attribute. Typically this will be called when the current CompositeEditor has lost focus.

Specified by:
stopEdit in class PropertyEditor
Parameters:
parent - - CompositeEditor
Returns:
boolean - returns true if the operation succeeded, otherwise returns false.

getRenderedValue

public java.lang.String getRenderedValue(java.lang.String value)
Return the value shown for the given model value.

Overrides:
getRenderedValue in class PropertyEditor
Parameters:
value - - the String value stored in the associated model.
Returns:
String

getLookup

public ILookup getLookup()
Returns the lookup that is used to populate the contents of the control.

Returns:
ILookup
See Also:
ILookup

setLookup

public void setLookup(org.eclipse.swt.widgets.Control combo,
                      ILookup lookup)
Sets the lookup used to populate the contents of the control. A lookup is basically a simple model whereby the value of the data set by the control differs with what appears in the UI, analogous to a key-value pair.

Parameters:
lookup - - ILookup

setLookup

public void setLookup(ILookup lookup)
Deprecated. 

Should not be used at it doesn't take care of lookup listeners

See Also:
setLookup(Control, ILookup)

isImmediateUpdate

public boolean isImmediateUpdate()

isEditable

public boolean isEditable()
Return true if the user can type into the combo, false if they can only select from the options.


isFirstBlankLine

public boolean isFirstBlankLine()
Return true if the combo should contain a blank line (null/empty) option.

Returns:
boolean

setFirstBlankLine

public void setFirstBlankLine(boolean firstBlankLine)
Set if the combo should contain a blank line (null/empty) option.

Parameters:
firstLineBlank -

getFirstLineTitle

public java.lang.String getFirstLineTitle()
Return the title for the first line.

Returns:
String

setFirstLineTitle

public void setFirstLineTitle(java.lang.String firstLineTitle)
Set the title for the first line.

Parameters:
firstLineTitle -

getListActions

public com.ibm.commons.swt.data.controls.IListActions getListActions()

setListActions

public void setListActions(com.ibm.commons.swt.data.controls.IListActions listActions)

comboGetText

public final java.lang.String comboGetText(org.eclipse.swt.widgets.Control combo)

comboSetText

protected final void comboSetText(org.eclipse.swt.widgets.Control combo,
                                  java.lang.String text)

comboGetSelectionIndex

protected final int comboGetSelectionIndex(org.eclipse.swt.widgets.Control combo)

comboGetItemCount

protected final int comboGetItemCount(org.eclipse.swt.widgets.Control combo)

comboGetItem

protected final java.lang.String comboGetItem(org.eclipse.swt.widgets.Control combo,
                                              int index)

comboAdd

protected final void comboAdd(org.eclipse.swt.widgets.Control combo,
                              java.lang.String value)

comboRemove

protected final void comboRemove(org.eclipse.swt.widgets.Control combo,
                                 int index)

comboRemoveAll

protected final void comboRemoveAll(org.eclipse.swt.widgets.Control combo,
                                    java.lang.String oldVal)

comboSelect

protected final void comboSelect(org.eclipse.swt.widgets.Control combo,
                                 int index)

comboDeselectAll

protected final void comboDeselectAll(org.eclipse.swt.widgets.Control combo)

getDefaultValue

public java.lang.String getDefaultValue()
Returns:
the defaultValue

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Parameters:
defaultValue - the defaultValue to set