net.sourceforge.java.util.gui.jface.preference
Class SpinnerFieldEditor

java.lang.Object
  extended byorg.eclipse.jface.preference.FieldEditor
      extended bynet.sourceforge.java.util.gui.jface.preference.SpinnerFieldEditor

public class SpinnerFieldEditor
extends FieldEditor

Allows editing of a numeric value in a Spinner component.

Author:
Sebastian Machhausen

Field Summary
private  int digits
           
private  int oldValue
           
private  Spinner spinnerCtrl
           
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
SpinnerFieldEditor(String name, String labelText, Composite parent)
           Creates a new SpinnerFieldEditor instance.
SpinnerFieldEditor(String name, String labelText, Composite parent, int digits)
           Creates a new SpinnerFieldEditor instance.
 
Method Summary
protected  void adjustForNumColumns(int numColumns)
           Adjusts the horizontal span of this SpinnerFieldEditor's basic controls.
protected  void doFillIntoGrid(Composite parent, int numColumns)
           Fills this SpinnerFieldEditor's basic controls into the given parent.
protected  void doLoad()
           Initializes this SpinnerFieldEditor with the preference value from the preference store.
protected  void doLoadDefault()
           Initializes this SpinnerFieldEditor with the default preference value from the preference store.
protected  void doStore()
           Stores the preference value from this SpinnerFieldEditor into the preference store.
 int getIncrement()
           Gets the amount that this SpinnerFieldEditor's value will be modified by when the up/down arrows are pressed to the argument.
 int getIntValue()
           Returns this SpinnerFieldEditor's current value as an integer.
 int getMaximum()
           Gets the maximum value that this this SpinnerFieldEditor allows.
 int getMinimum()
           Gets the minimum value that this this SpinnerFieldEditor allows.
 int getNumberOfControls()
           Returns the number of controls in this SpinnerFieldEditor.
 int getPageIncrement()
           Gets the amount that this SpinnerFieldEditor's value will be modified by when the page up/down arrows are pressed to the argument.
 void setEnabled(boolean enabled, Composite parent)
           Sets the enabled status of this SpinnerFieldEditor.
 void setIncrement(int increment)
           Sets the amount that this SpinnerFieldEditor's value will be modified by when the up/down arrows are pressed to the argument, which must be at least one.
 void setMaximum(int maximum)
           Sets the maximum value that this this SpinnerFieldEditor will allow.
 void setMinimum(int minimum)
           Sets the minimum value that this SpinnerFieldEditor will allow.
 void setPageIncrement(int increment)
           Sets the amount that this SpinnerFieldEditor's position will be modified by when the page up/down keys are pressed to the argument, which must be at least one.
protected  void valueChanged()
           Informs this field editor's listener, if it has one, about a change to the value (VALUE property) provided that the old and new values are different.
 
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, 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

spinnerCtrl

private Spinner spinnerCtrl

digits

private int digits

oldValue

private int oldValue
Constructor Detail

SpinnerFieldEditor

public SpinnerFieldEditor(String name,
                          String labelText,
                          Composite parent)

Creates a new SpinnerFieldEditor instance.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
parent - the parent of the field editor's control

SpinnerFieldEditor

public SpinnerFieldEditor(String name,
                          String labelText,
                          Composite parent,
                          int digits)

Creates a new SpinnerFieldEditor instance.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
parent - the parent of the field editor's control
digits - the number of decimal places; The digit setting is used to allow for floating point values in the receiver.
Method Detail

valueChanged

protected void valueChanged()

Informs this field editor's listener, if it has one, about a change to the value (VALUE property) provided that the old and new values are different. This hook is not called when the value is initialized (or reset to the default value) from the preference store.


adjustForNumColumns

protected void adjustForNumColumns(int numColumns)

Adjusts the horizontal span of this SpinnerFieldEditor's basic controls. The number of columns will always be equal to or greater than the value returned by this editor's getNumberOfControls method.

Parameters:
numColumns - the number of columns
See Also:
FieldEditor.adjustForNumColumns(int)

doFillIntoGrid

protected void doFillIntoGrid(Composite parent,
                              int numColumns)

Fills this SpinnerFieldEditor's basic controls into the given parent.

Parameters:
parent - the composite used as a parent for the basic controls; the parent's layout must be a GridLayout
numColumns - the number of columns
See Also:
FieldEditor.doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)

doLoad

protected void doLoad()

Initializes this SpinnerFieldEditor with the preference value from the preference store.

See Also:
FieldEditor.doLoad()

doLoadDefault

protected void doLoadDefault()

Initializes this SpinnerFieldEditor with the default preference value from the preference store.

See Also:
FieldEditor.doLoadDefault()

doStore

protected void doStore()

Stores the preference value from this SpinnerFieldEditor into the preference store.

See Also:
FieldEditor.doStore()

getNumberOfControls

public int getNumberOfControls()

Returns the number of controls in this SpinnerFieldEditor. Returns 1 as the Spinner is the only control.

Returns:
1
See Also:
FieldEditor.getNumberOfControls()

setIncrement

public void setIncrement(int increment)

Sets the amount that this SpinnerFieldEditor's value will be modified by when the up/down arrows are pressed to the argument, which must be at least one.

Parameters:
increment - the new increment (must be greater than zero)

getIncrement

public int getIncrement()

Gets the amount that this SpinnerFieldEditor's value will be modified by when the up/down arrows are pressed to the argument.

Returns:
the increment value

setPageIncrement

public void setPageIncrement(int increment)

Sets the amount that this SpinnerFieldEditor's position will be modified by when the page up/down keys are pressed to the argument, which must be at least one.

Parameters:
increment - the new page increment (must be greater than zero)

getPageIncrement

public int getPageIncrement()

Gets the amount that this SpinnerFieldEditor's value will be modified by when the page up/down arrows are pressed to the argument.

Returns:
the page increment value

setMaximum

public void setMaximum(int maximum)

Sets the maximum value that this this SpinnerFieldEditor will allow. This new value will be ignored if it is not greater than this SpinnerFieldEditor's current minimum value. If the new maximum is applied then this this SpinnerFieldEditor's selection value will be adjusted if necessary to fall within its new range.

Parameters:
maximum - the new maximum, which must be greater than the current minimum

getMaximum

public int getMaximum()

Gets the maximum value that this this SpinnerFieldEditor allows.

Returns:
the maximum value

setMinimum

public void setMinimum(int minimum)

Sets the minimum value that this SpinnerFieldEditor will allow. This new value will be ignored if it is negative or is not less than this SpinnerFieldEditor's current maximum value. If the new minimum is applied then this SpinnerFieldEditor's selection value will be adjusted if necessary to fall within its new range.

Parameters:
minimum - the new minimum, which must be nonnegative and less than the current maximum

getMinimum

public int getMinimum()

Gets the minimum value that this this SpinnerFieldEditor allows.

Returns:
the minimum value

getIntValue

public int getIntValue()

Returns this SpinnerFieldEditor's current value as an integer.

Returns:
the value

setEnabled

public void setEnabled(boolean enabled,
                       Composite parent)

Sets the enabled status of this SpinnerFieldEditor.

Parameters:
enabled - true to enable, false to disable this SpinnerFieldEditor
parent - the parent Composite
See Also:
FieldEditor.setEnabled(boolean, Composite)