Runtime

org.eclipse.gmf.runtime.common.ui.preferences
Class ComboFieldEditor

java.lang.Object
  extended byorg.eclipse.jface.preference.FieldEditor
      extended byorg.eclipse.gmf.runtime.common.ui.preferences.ComboFieldEditor

public class ComboFieldEditor
extends FieldEditor

Constructs a field editor with a label and a drop down combo box.


Field Summary
 boolean autoStorage
          True for automatically loading and storing and false for manual loading and storing of values in the combo box.
protected  Combo combo
          The combo box control.
protected  int indent
          Indent of controls
protected  java.util.ArrayList indexToValue
          Index of list contains value of preference to store
static int INT_TYPE
          INT_TYPE saves the index.
static int INT_TYPE_INDEXED
          INT_TYPE_INDEXED saves an associated value for the index value
protected  boolean readOnly
          Whether you can type into the combo box
protected  boolean separateLine
          Whether the label and combo should be on separate lines
static int STRING_TYPE
          STRING_TYPE saves the actual string.
protected  int type
          The type that was chosen for saving preferences
protected  int width
          Width of combo box.
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
ComboFieldEditor(java.lang.String name, java.lang.String labelText, Composite parent)
          Constructor to create the combo field editor
ComboFieldEditor(java.lang.String name, java.lang.String labelText, Composite parent, int aType, boolean aSeparateLine, int anIndent, int aWidth, boolean aReadOnly)
          Constructor to create the combo field editor
 
Method Summary
 void addIndexedItemToCombo(java.lang.String stringValue, int storeValue)
          Adds an item to the combo.
protected  void adjustForNumColumns(int numColumns)
           
protected  void doFillIntoGrid(Composite parent, int numColumns)
           
protected  void doLoad()
           
protected  void doLoadDefault()
           
protected  void doStore()
           
 boolean existsInCombo(java.lang.String value)
          Returns whether or not the given string is already in the combo box.
 Combo getComboControl()
          Returns the actual combo box contained in the field editor.
 int getNumberOfControls()
          Returns the number of controls in this editor
 java.lang.String getStringValue()
          Returns this field editor's current value.
 void setAutoStorage(boolean anAutoStorage)
          Sets the automatic loading and storing of contents for the combo box.
 
Methods inherited from class org.eclipse.jface.preference.FieldEditor
applyFont, checkParent, clearErrorMessage, clearMessage, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, createControl, dispose, fillIntoGrid, fireStateChanged, fireValueChanged, getFieldEditorFontName, getLabelControl, getLabelControl, getLabelText, getPage, getPreferenceName, getPreferencePage, getPreferenceStore, init, isValid, load, loadDefault, presentsDefaultValue, refreshValidState, setButtonLayoutData, setEnabled, setFocus, setLabelText, setPage, setPreferenceName, setPreferencePage, setPreferenceStore, setPresentsDefaultValue, setPropertyChangeListener, showErrorMessage, showMessage, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

separateLine

protected boolean separateLine
Whether the label and combo should be on separate lines


readOnly

protected boolean readOnly
Whether you can type into the combo box


indent

protected int indent
Indent of controls


width

protected int width
Width of combo box.


combo

protected Combo combo
The combo box control.


STRING_TYPE

public static final int STRING_TYPE
STRING_TYPE saves the actual string.

See Also:
Constant Field Values

INT_TYPE

public static final int INT_TYPE
INT_TYPE saves the index.

See Also:
Constant Field Values

INT_TYPE_INDEXED

public static final int INT_TYPE_INDEXED
INT_TYPE_INDEXED saves an associated value for the index value

See Also:
Constant Field Values

type

protected int type
The type that was chosen for saving preferences


indexToValue

protected java.util.ArrayList indexToValue
Index of list contains value of preference to store


autoStorage

public boolean autoStorage
True for automatically loading and storing and false for manual loading and storing of values in the combo box.

Constructor Detail

ComboFieldEditor

public ComboFieldEditor(java.lang.String name,
                        java.lang.String labelText,
                        Composite parent)
Constructor to create the combo field editor

Parameters:
name - String containing unique name of field editor
labelText - String containing text to display
parent - Composite the parent composite that contains this field editor

ComboFieldEditor

public ComboFieldEditor(java.lang.String name,
                        java.lang.String labelText,
                        Composite parent,
                        int aType,
                        boolean aSeparateLine,
                        int anIndent,
                        int aWidth,
                        boolean aReadOnly)
Constructor to create the combo field editor

Parameters:
name - String containing unique name of field editor
labelText - String containing text to display
parent - Composite the parent composite that contains this field editor
aType - int, either INT_TYPE or STRING_TYPE which describes the way that we will be saving preferences. INT_TYPE will save according to the index and STRING_TYPE will save the actual string.
aSeparateLine - boolean. Set to true to make labelText and the combo appear on separate lines. Set to false to make labelText appear to the left of the combo box.
anIndent - How much to indent on the left side.
aWidth - is the width of the combo.
aReadOnly - true to be read only, false to be read write
Method Detail

adjustForNumColumns

protected void adjustForNumColumns(int numColumns)

doFillIntoGrid

protected void doFillIntoGrid(Composite parent,
                              int numColumns)

doLoad

protected void doLoad()

doLoadDefault

protected void doLoadDefault()

doStore

protected void doStore()

getStringValue

public java.lang.String getStringValue()
Returns this field editor's current value.

Returns:
the value of the combo box as a String

getNumberOfControls

public int getNumberOfControls()
Returns the number of controls in this editor

Returns:
int 2 since there's the combo and the label

getComboControl

public Combo getComboControl()
Returns the actual combo box contained in the field editor.

Returns:
combo which is the actual combo box.

existsInCombo

public boolean existsInCombo(java.lang.String value)
Returns whether or not the given string is already in the combo box. You could call this method to check to see if the string is already there before inserting if you do not want duplicates.

Parameters:
value - the String to check
Returns:
boolean true if it exists, false if it doesn't

setAutoStorage

public void setAutoStorage(boolean anAutoStorage)
Sets the automatic loading and storing of contents for the combo box. Default is true.

Parameters:
anAutoStorage - true for automatically loading and storing and false for manual loading and storing

addIndexedItemToCombo

public void addIndexedItemToCombo(java.lang.String stringValue,
                                  int storeValue)
Adds an item to the combo. Also stores the value to be saved to the preference store when the index is the selection. (As opposed to saving the index value.)

Parameters:
stringValue - String value of the item
storeValue - int value of the item

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.