E
- the type of elements returned by the underlying column viewer.public abstract class IntEditingSupport<E> extends TextEditingSupport<E>
A TextEditingSupport
that further restricts its content to values
that can be converted to integers.
The underlying control does not constrain the user while typing, only when validating. Thus the user is free to type invalid characters (such as letters). The reason for not using verify listeners (that constrain the user while typing) is that, IMHO, it constrains the user without really helping her.
Constructor and Description |
---|
IntEditingSupport(ColumnViewer viewer,
Class<E> classOfElements) |
Modifier and Type | Method and Description |
---|---|
abstract int |
getIntValue(E element)
Get the value to set to the editor.
|
String |
getValueTyped(E element)
Get the value to set to the editor.
|
void |
setIntegerValidator(Function<Integer,String> valueToErrorMessage)
Sets the input validator for this cell editor.
|
abstract void |
setIntValue(E element,
int value)
Sets the new value on the given element.
|
void |
setValueTyped(E element,
String value)
Sets the new value on the given element.
|
getTextCellEditor
getCellEditor, getCellEditorTyped, setCellEditor, setFirstLevelValidator, setValidator
canEdit, canEditTyped, getCellEditor, getTypedElement, getTypedValue, getValue, setValue
getViewer, initializeCellEditorValue, saveCellEditorValue
public IntEditingSupport(ColumnViewer viewer, Class<E> classOfElements)
public abstract int getIntValue(E element)
Get the value to set to the editor.
This method is simply a better typed equivalent to TypedEditingSupport.getValue(Object)
.
element
- the model elementpublic String getValueTyped(E element)
TypedEditingSupport
Get the value to set to the editor.
This method is simply a better typed version of
TypedEditingSupport.getValue(Object)
.
getValueTyped
in class TypedEditingSupport<E,String>
element
- the model elementpublic void setIntegerValidator(Function<Integer,String> valueToErrorMessage)
Sets the input validator for this cell editor.
The validator is given the (integer) value to be validated, and must return a
string indicating whether the given value is valid; null
means
valid, and non-null
means invalid, with the result being the
error message to display to the end user.
This is simply a better-typed version of TypedEditingSupportConstantEditor.setValidator(Function)
.
valueToErrorMessage
- the input validator, or null
if nonepublic abstract void setIntValue(E element, int value)
Sets the new value on the given element. Note that implementers need to
ensure that getViewer().update(element, null)
or similar methods
are called, either directly or through some kind of listener mechanism on the
implementer's model, to cause the new value to appear in the viewer.
This method is simply a better typed equivalent to
TypedEditingSupport.setValue(Object, Object)
.
element
- the model elementvalue
- the new valuepublic void setValueTyped(E element, String value)
TypedEditingSupport
Sets the new value on the given element. Note that implementers need to
ensure that getViewer().update(element, null)
or similar
methods are called, either directly or through some kind of listener
mechanism on the implementer's model, to cause the new value to appear in
the viewer.
This method is simply a better typed version of
TypedEditingSupport.setValue(Object, Object)
.
setValueTyped
in class TypedEditingSupport<E,String>
element
- the model elementvalue
- the new valueCopyright © 2017. All rights reserved.