|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.preference.FieldEditor | +--org.eclipse.jface.preference.StringFieldEditor
A field editor for a string type preference.
This class may be used as is, or subclassed as required.
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 |
StringFieldEditor()
Creates a new string field editor |
|
StringFieldEditor(String name,
String labelText,
Composite parent)
Creates a string field editor of unlimited width. |
|
StringFieldEditor(String name,
String labelText,
int width,
Composite parent)
Creates a string field editor. |
|
StringFieldEditor(String name,
String labelText,
int width,
int strategy,
Composite parent)
Creates a string field editor. |
Method Summary | |
protected void |
adjustForNumColumns(int numColumns)
Adjusts the horizontal span of this field editor's basic controls |
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(Composite parent,
int numColumns)
Fills this field editor's basic controls into the given parent. |
protected void |
doLoad()
Initializes this field editor with the preference value from the preference store. |
protected void |
doLoadDefault()
Initializes this field editor with the default preference value from the preference store. |
protected void |
doStore()
Stores the preference value from this field editor into the preference store. |
String |
getErrorMessage()
Returns the error message that will be displayed when and if an error occurs. |
int |
getNumberOfControls()
Returns the number of basic controls this field editor consists of. |
String |
getStringValue()
Returns the field editor's value. |
protected Text |
getTextControl()
Returns this field editor's text control. |
Text |
getTextControl(Composite parent)
Returns this field editor's text control. |
boolean |
isEmptyStringAllowed()
Returns whether an empty string is a valid value. |
boolean |
isValid()
Returns whether this field editor contains a valid value. |
protected void |
refreshValidState()
Refreshes this field editor's valid state after a value change and fires an IS_VALID property change event if
warranted. |
void |
setEmptyStringAllowed(boolean b)
Sets whether the empty string is a valid value or not. |
void |
setErrorMessage(String message)
Sets the error message that will be displayed when and if an error occurs. |
void |
setFocus()
Sets the focus to this field editor. |
void |
setStringValue(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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int VALIDATE_ON_KEY_STROKE
0
) indicating that
the editor should perform validation after every key stroke.
setValidateStrategy(int)
,
Constant Field Valuespublic static final int VALIDATE_ON_FOCUS_LOST
1
) indicating that
the editor should perform validation only when the text widget
loses focus.
setValidateStrategy(int)
,
Constant Field Valuespublic static int UNLIMITED
-1
) indicating unlimited
text limit and width.
Constructor Detail |
protected StringFieldEditor()
public StringFieldEditor(String name, String labelText, int width, int strategy, Composite parent)
setTextLimit
to limit the text.
name
- the name of the preference this field editor works onlabelText
- the label text of the field editorwidth
- the width of the text input field in characters,
or UNLIMITED
for no limitstrategy
- 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 inparent
- the parent of the field editor's controlpublic StringFieldEditor(String name, String labelText, int width, Composite parent)
setTextLimit
to limit the text.
name
- the name of the preference this field editor works onlabelText
- the label text of the field editorwidth
- the width of the text input field in characters,
or UNLIMITED
for no limitparent
- the parent of the field editor's controlpublic StringFieldEditor(String name, String labelText, Composite parent)
setTextLimit
to limit the text.
name
- the name of the preference this field editor works onlabelText
- the label text of the field editorparent
- the parent of the field editor's controlMethod Detail |
protected void adjustForNumColumns(int numColumns)
FieldEditor
Subclasses must implement this method to adjust the horizontal span of controls so they appear correct in the given number of columns.
The number of columns will always be equal to or greater than the
value returned by this editor's getNumberOfControls
method.
adjustForNumColumns
in class FieldEditor
numColumns
- the number of columnsprotected boolean checkState()
true
if the field value is valid,
and false
if invalidprotected boolean doCheckState()
The default implementation of this framework method does
nothing and returns true
. Subclasses should
override this method to specific state checks.
true
if the field value is valid,
and false
if invalidprotected void doFillIntoGrid(Composite parent, int numColumns)
The string field implementation of this FieldEditor
framework method contributes the text field. Subclasses may override
but must call super.doFillIntoGrid
.
doFillIntoGrid
in class FieldEditor
parent
- the composite used as a parent for the basic controls;
the parent's layout must be a GridLayout
numColumns
- the number of columnsprotected void doLoad()
FieldEditor
Subclasses must implement this method to properly initialize the field editor.
doLoad
in class FieldEditor
protected void doLoadDefault()
FieldEditor
Subclasses must implement this method to properly initialize the field editor.
doLoadDefault
in class FieldEditor
protected void doStore()
FieldEditor
Subclasses must implement this method to save the entered value into the preference store.
doStore
in class FieldEditor
public String getErrorMessage()
null
if nonepublic int getNumberOfControls()
FieldEditor
getNumberOfControls
in class FieldEditor
public String getStringValue()
protected Text getTextControl()
null
if no
text field is created yetpublic Text getTextControl(Composite parent)
The control is created if it does not yet exist
parent
- the parent
public boolean isEmptyStringAllowed()
true
if an empty string is a valid value, and
false
if an empty string is invalidsetEmptyStringAllowed(boolean)
public boolean isValid()
FieldEditor
The default implementation of this framework method
returns true
. Subclasses wishing to perform
validation should override both this method and
refreshValidState
.
isValid
in class FieldEditor
true
if the field value is valid,
and false
if invalidFieldEditor.refreshValidState()
protected void refreshValidState()
FieldEditor
IS_VALID
property change event if
warranted.
The default implementation of this framework method does
nothing. Subclasses wishing to perform validation should override
both this method and isValid
.
refreshValidState
in class FieldEditor
FieldEditor.isValid()
public void setEmptyStringAllowed(boolean b)
b
- true
if the empty string is allowed,
and false
if it is considered invalidpublic void setErrorMessage(String message)
message
- the error messagepublic void setFocus()
FieldEditor
The default implementation of this framework method does nothing. Subclasses may reimplement.
setFocus
in class FieldEditor
public void setStringValue(String value)
value
- the new value, or null
meaning the empty stringpublic void setTextLimit(int limit)
limit
- the limit on the number of character in the text
input field, or UNLIMITED
for no limitpublic void setValidateStrategy(int value)
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.
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 inpublic void showErrorMessage()
setErrorMessage
.
protected void valueChanged()
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.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |