com.aptana.ide.core.ui.widgets
Class TextFieldEditor

java.lang.Object
  extended by org.eclipse.jface.preference.FieldEditor
      extended by com.aptana.ide.core.ui.widgets.TextFieldEditor

public class TextFieldEditor
extends org.eclipse.jface.preference.FieldEditor

TextFieldEditor. This would extend StringFieldEditor if the API developers had decided to make textField _protected_ or at least allow me to set it!

Author:
Ingo Muschenetz

Field Summary
static int UNLIMITED
          Text limit constant (value -1) indicating unlimited text limit and width.
static int VALIDATE_ON_FOCUS_LOST
          Validation strategy constant (value 1) indicating that the editor should perform validation only when the text widget loses focus.
static int VALIDATE_ON_KEY_STROKE
          Validation strategy constant (value 0) indicating that the editor should perform validation after every key stroke.
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
protected TextFieldEditor()
          Creates a new string field editor
  TextFieldEditor(java.lang.String name, java.lang.String labelText, org.eclipse.swt.widgets.Composite parent)
          Creates a string field editor of unlimited width.
  TextFieldEditor(java.lang.String name, java.lang.String labelText, int width, org.eclipse.swt.widgets.Composite parent)
          Creates a string field editor.
  TextFieldEditor(java.lang.String name, java.lang.String labelText, int width, int strategy, org.eclipse.swt.widgets.Composite parent, int swtStyle)
          Creates a string field editor.
 
Method Summary
protected  void adjustForNumColumns(int numColumns)
          (non-Javadoc) Method declared on FieldEditor.
protected  boolean checkState()
          Checks whether the text input field contains a valid value or not.
protected  boolean doCheckState()
          Hook for subclasses to do specific state checks.
protected  void doFillIntoGrid(org.eclipse.swt.widgets.Composite parent, int numColumns)
          Fills this field editor's basic controls into the given parent.
protected  void doLoad()
          (non-Javadoc) Method declared on FieldEditor.
protected  void doLoadDefault()
          (non-Javadoc) Method declared on FieldEditor.
protected  void doStore()
          (non-Javadoc) Method declared on FieldEditor.
 java.lang.String getErrorMessage()
          Returns the error message that will be displayed when and if an error occurs.
 int getNumberOfControls()
          (non-Javadoc) Method declared on FieldEditor.
 java.lang.String getStringValue()
          Returns the field editor's value.
 org.eclipse.swt.widgets.Text getTextControl()
          Returns this field editor's text control.
 org.eclipse.swt.widgets.Text getTextControl(org.eclipse.swt.widgets.Composite parent)
          Returns this field editor's text control.
 boolean isEmptyStringAllowed()
          Returns whether an empty string is a valid value.
 boolean isValid()
          (non-Javadoc) Method declared on FieldEditor.
protected  void refreshValidState()
          (non-Javadoc) Method declared on FieldEditor.
 void setEmptyStringAllowed(boolean b)
          Sets whether the empty string is a valid value or not.
 void setEnabled(boolean enabled, org.eclipse.swt.widgets.Composite parent)
           
 void setErrorMessage(java.lang.String message)
          Sets the error message that will be displayed when and if an error occurs.
 void setFocus()
          (non-Javadoc) Method declared on FieldEditor.
 void setStringValue(java.lang.String value)
          Sets this field editor's value.
 void setTextLimit(int limit)
          Sets this text field's text limit.
 void setValidateStrategy(int value)
          Sets the strategy for validating the text.
 void showErrorMessage()
          Shows the error message set via setErrorMessage.
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, load, loadDefault, presentsDefaultValue, setButtonLayoutData, 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

VALIDATE_ON_KEY_STROKE

public static final int VALIDATE_ON_KEY_STROKE
Validation strategy constant (value 0) indicating that the editor should perform validation after every key stroke.

See Also:
setValidateStrategy(int), Constant Field Values

VALIDATE_ON_FOCUS_LOST

public static final int VALIDATE_ON_FOCUS_LOST
Validation strategy constant (value 1) indicating that the editor should perform validation only when the text widget loses focus.

See Also:
setValidateStrategy(int), Constant Field Values

UNLIMITED

public static int UNLIMITED
Text limit constant (value -1) indicating unlimited text limit and width.

Constructor Detail

TextFieldEditor

protected TextFieldEditor()
Creates a new string field editor


TextFieldEditor

public TextFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       int width,
                       int strategy,
                       org.eclipse.swt.widgets.Composite parent,
                       int swtStyle)
Creates a string field editor. Use the method setTextLimit to limit the text.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
width - the width of the text input field in characters, or UNLIMITED for no limit
strategy - either VALIDATE_ON_KEY_STROKE to perform on the fly checking (the default), or VALIDATE_ON_FOCUS_LOST to perform validation only after the text has been typed in
parent - the parent of the field editor's control
swtStyle - The SWT text style commands
Since:
2.0

TextFieldEditor

public TextFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       int width,
                       org.eclipse.swt.widgets.Composite parent)
Creates a string field editor. Use the method setTextLimit to limit the text.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
width - the width of the text input field in characters, or UNLIMITED for no limit
parent - the parent of the field editor's control

TextFieldEditor

public TextFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       org.eclipse.swt.widgets.Composite parent)
Creates a string field editor of unlimited width. Use the method setTextLimit to limit the text.

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
Method Detail

adjustForNumColumns

protected void adjustForNumColumns(int numColumns)
(non-Javadoc) Method declared on FieldEditor.

Specified by:
adjustForNumColumns in class org.eclipse.jface.preference.FieldEditor
Parameters:
numColumns -

checkState

protected boolean checkState()
Checks whether the text input field contains a valid value or not.

Returns:
true if the field value is valid, and false if invalid

doCheckState

protected boolean doCheckState()
Hook for subclasses to do specific state checks.

The default implementation of this framework method does nothing and returns true. Subclasses should override this method to specific state checks.

Returns:
true if the field value is valid, and false if invalid

doFillIntoGrid

protected void doFillIntoGrid(org.eclipse.swt.widgets.Composite parent,
                              int numColumns)
Fills this field editor's basic controls into the given parent.

The string field implementation of this FieldEditor framework method contributes the text field. Subclasses may override but must call super.doFillIntoGrid.

Specified by:
doFillIntoGrid in class org.eclipse.jface.preference.FieldEditor
Parameters:
parent -
numColumns -

doLoad

protected void doLoad()
(non-Javadoc) Method declared on FieldEditor.

Specified by:
doLoad in class org.eclipse.jface.preference.FieldEditor

doLoadDefault

protected void doLoadDefault()
(non-Javadoc) Method declared on FieldEditor.

Specified by:
doLoadDefault in class org.eclipse.jface.preference.FieldEditor

doStore

protected void doStore()
(non-Javadoc) Method declared on FieldEditor.

Specified by:
doStore in class org.eclipse.jface.preference.FieldEditor

getErrorMessage

public java.lang.String getErrorMessage()
Returns the error message that will be displayed when and if an error occurs.

Returns:
the error message, or null if none

getNumberOfControls

public int getNumberOfControls()
(non-Javadoc) Method declared on FieldEditor.

Specified by:
getNumberOfControls in class org.eclipse.jface.preference.FieldEditor
Returns:
the number of controls in this editor

getStringValue

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

Returns:
the current value

getTextControl

public org.eclipse.swt.widgets.Text getTextControl()
Returns this field editor's text control.

Returns:
the text control, or null if no text field is created yet

getTextControl

public org.eclipse.swt.widgets.Text getTextControl(org.eclipse.swt.widgets.Composite parent)
Returns this field editor's text control.

The control is created if it does not yet exist

Parameters:
parent - the parent
Returns:
the text control

isEmptyStringAllowed

public boolean isEmptyStringAllowed()
Returns whether an empty string is a valid value.

Returns:
true if an empty string is a valid value, and false if an empty string is invalid
See Also:
setEmptyStringAllowed(boolean)

isValid

public boolean isValid()
(non-Javadoc) Method declared on FieldEditor.

Overrides:
isValid in class org.eclipse.jface.preference.FieldEditor
Returns:
is the control valid

refreshValidState

protected void refreshValidState()
(non-Javadoc) Method declared on FieldEditor.

Overrides:
refreshValidState in class org.eclipse.jface.preference.FieldEditor

setEmptyStringAllowed

public void setEmptyStringAllowed(boolean b)
Sets whether the empty string is a valid value or not.

Parameters:
b - true if the empty string is allowed, and false if it is considered invalid

setErrorMessage

public void setErrorMessage(java.lang.String message)
Sets the error message that will be displayed when and if an error occurs.

Parameters:
message - the error message

setFocus

public void setFocus()
(non-Javadoc) Method declared on FieldEditor.

Overrides:
setFocus in class org.eclipse.jface.preference.FieldEditor

setStringValue

public void setStringValue(java.lang.String value)
Sets this field editor's value.

Parameters:
value - the new value, or null meaning the empty string

setTextLimit

public void setTextLimit(int limit)
Sets this text field's text limit.

Parameters:
limit - the limit on the number of character in the text input field, or UNLIMITED for no limit

setValidateStrategy

public void setValidateStrategy(int value)
Sets the strategy for validating the text.

Calling this method has no effect after createPartControl is called. Thus this method is really only useful for subclasses to call in their constructor. However, it has public visibility for backward compatibility.

Parameters:
value - either VALIDATE_ON_KEY_STROKE to perform on the fly checking (the default), or VALIDATE_ON_FOCUS_LOST to perform validation only after the text has been typed in

showErrorMessage

public void showErrorMessage()
Shows the error message set via setErrorMessage.


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 text is initialized (or reset to the default value) from the preference store.


setEnabled

public void setEnabled(boolean enabled,
                       org.eclipse.swt.widgets.Composite parent)
Overrides:
setEnabled in class org.eclipse.jface.preference.FieldEditor
Parameters:
enabled -
parent -
See Also:
FieldEditor.setEnabled(boolean,Composite)