public class DynamicComboFieldEditor
extends org.eclipse.jface.preference.FieldEditor
Combo
.
The major difference between this class and the default JFace
ComboFieldEditor
is that this editor provides hooks to update the
current value and the allowed values for the editor. This is important if the
preference page needs to update a list of allowed preference values when some
other preference changes.
Constructor and Description |
---|
DynamicComboFieldEditor(java.lang.String name,
java.lang.String labelText,
org.eclipse.swt.widgets.Composite parent,
java.util.List<java.lang.String> allowedValues)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getIndex()
Gets the index of the currently selected value from the field editor.
|
int |
getNumberOfControls() |
java.lang.String |
getValue()
Gets the currently selected value from the field editor.
|
void |
setAllowedValues(java.util.List<java.lang.String> newValues)
Sets the allowed values displayed in the underlying
combo . |
void |
setValue(int index)
Sets the currently selected value in the field editor.
|
void |
setValue(java.lang.String value)
Sets the currently selected value in the field editor.
|
dispose, fillIntoGrid, getFieldEditorFontName, getLabelControl, getLabelText, getPreferenceName, getPreferenceStore, isValid, load, loadDefault, presentsDefaultValue, setEnabled, setFocus, setLabelText, setPage, setPreferenceName, setPreferencePage, setPreferenceStore, setPropertyChangeListener, store
public DynamicComboFieldEditor(java.lang.String name, java.lang.String labelText, org.eclipse.swt.widgets.Composite parent, java.util.List<java.lang.String> allowedValues)
name
- The name of the preference this field editor works on.labelText
- The label text of the field editor (seen by the user).parent
- The parent Control
for this field editor.allowedValues
- The current list of allowed values displayed in the
combo
.public int getIndex()
Note:This value may not yet be in the preference store.
public int getNumberOfControls()
getNumberOfControls
in class org.eclipse.jface.preference.FieldEditor
public java.lang.String getValue()
Note:This value may not yet be in the preference store.
public void setAllowedValues(java.util.List<java.lang.String> newValues)
combo
.newValues
- The new list of values. If null
, nothing is done.public void setValue(int index)
Note:This value will not be put in the preference store from this operation.
index
- The index of the new value. Nothing is done if the index is
invalid.public void setValue(java.lang.String value)
Note:This value will not be put in the preference store from this operation.
value
- The new value. Nothing is done if the value cannot be found in
the allowed values
.