com.ibm.commons.swt.controls.custom
Class CustomText

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Text
                  extended by com.ibm.commons.swt.controls.custom.CustomText
All Implemented Interfaces:
ICustomControl, org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
DCText

public class CustomText
extends org.eclipse.swt.widgets.Text
implements ICustomControl

An extension of the standard SWT Text class. For convenience numberous utility methods and behaviors have been attached to this implementation, such as input validation, tab handling and autosizing.
For convenience this widget also allows the user to associate an ID with the widget.


Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Text
DELIMITER, LIMIT
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CustomText(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String id)
          Constructs a new instance of the class given the parent Composite, a style value describing its behavior and appearance, and id which can be used to later identify this control.
 
Method Summary
protected  void checkSubclass()
           
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
           
 int getCols()
          Returns the width of the widget in columns.
 double getDoubleValue()
          Utility method that will return the double value of the current widget.
 java.lang.String getId()
          Returns a string identifier associated with the current widget/control
 int getIntValue()
          Utility method that will return the integer value of the current widget.
 long getLongValue()
          Utility method that will return the long value of the current widget.
 int getRows()
          Returns the height of the widget in rows.
 IValidator getValidator()
          Returns the validator associated with this text field.
 boolean isWantTabs()
          Returns a boolean value that specifies whether or not focus will move from the widget when tab is pressed.
protected  void resetTextToPriorValue(java.lang.String value)
           
 void setCols(int cols)
          Sets the width of the widget in columns.
 void setDoubleValue(double value)
          Utility method that allows the caller to set the value of the text field to be an double value.
 void setId(java.lang.String id)
          Sets a string identifier on the current widget/control.
 void setIntValue(int value)
          Utility method that allows the caller to set the value of the text field to be an int value.
 void setLongValue(long value)
          Utility method that allows the caller to set the value of the text field to be an long value.
 void setRows(int rows)
          Sets the height of the widget in rows.
 void setValidator(IValidator validator)
          Sets a validator which is used to make sure that user input conforms to certain predefined criteria.
 void setWantTabs(boolean wantTabs)
          A utility feature that allows the user to set whether or not tabs will be 'swallowed' by the widget.
protected  boolean validate()
           
 
Methods inherited from class org.eclipse.swt.widgets.Text
addModifyListener, addSelectionListener, addVerifyListener, append, clearSelection, computeTrim, copy, cut, getBorderWidth, getCaretLineNumber, getCaretLocation, getCaretPosition, getCharCount, getDoubleClickEnabled, getEchoChar, getEditable, getLineCount, getLineDelimiter, getLineHeight, getMessage, getOrientation, getSelection, getSelectionCount, getSelectionText, getTabs, getText, getText, getTextChars, getTextLimit, getTopIndex, getTopPixel, insert, paste, removeModifyListener, removeSelectionListener, removeVerifyListener, selectAll, setDoubleClickEnabled, setEchoChar, setEditable, setMessage, setOrientation, setSelection, setSelection, setSelection, setTabs, setText, setTextChars, setTextLimit, setTopIndex, showSelection
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFocus, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CustomText

public CustomText(org.eclipse.swt.widgets.Composite parent,
                  int style,
                  java.lang.String id)
Constructs a new instance of the class given the parent Composite, a style value describing its behavior and appearance, and id which can be used to later identify this control.

Parameters:
parent - - a Composite control which will be the parent of the new instance (CANNOT be null).
style - - the style of the control to construct.
id - - the programmatic ID of the control once constructed.
Method Detail

checkSubclass

protected void checkSubclass()
Overrides:
checkSubclass in class org.eclipse.swt.widgets.Widget

isWantTabs

public boolean isWantTabs()
Returns a boolean value that specifies whether or not focus will move from the widget when tab is pressed.

Returns:
false if tab will cause focus to move to another control.

setWantTabs

public void setWantTabs(boolean wantTabs)
A utility feature that allows the user to set whether or not tabs will be 'swallowed' by the widget. If set to true the the tab character will be INSERTED as a character in the text control. If set to false then focus will shift to the next control when tab is pressed.

Parameters:
wantTabs - - boolean parameter that sets whether focus will change when 'tab' is pressed.

getIntValue

public int getIntValue()
Utility method that will return the integer value of the current widget. If the widget contains a value that cannot be parsed then zero (0) will be returned.

Returns:

setIntValue

public void setIntValue(int value)
Utility method that allows the caller to set the value of the text field to be an int value. This method converts the int value to a String and sets it as the value of the text field.

Parameters:
value - - int

getLongValue

public long getLongValue()
Utility method that will return the long value of the current widget. If the widget contains a value that cannot be parsed then zero (0) will be returned.

Returns:

setLongValue

public void setLongValue(long value)
Utility method that allows the caller to set the value of the text field to be an long value. This method converts the long value to a String and sets it as the value of the text field.

Parameters:
value - - long

getDoubleValue

public double getDoubleValue()
Utility method that will return the double value of the current widget. If the widget contains a value that cannot be parsed then zero (0.0) will be returned.

Returns:

setDoubleValue

public void setDoubleValue(double value)
Utility method that allows the caller to set the value of the text field to be an double value. This method converts the double value to a String and sets it as the value of the text field.

Parameters:
value - - double

computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint,
                                                  boolean changed)
Overrides:
computeSize in class org.eclipse.swt.widgets.Text

getCols

public int getCols()
Returns the width of the widget in columns. A column is defined as the average width of a character as defined by SWT's FontMetrics class.

Returns:
An int value representing the column width of this control
See Also:
org.eclipse.swt.graphics.FontMetrics}

setCols

public void setCols(int cols)
Sets the width of the widget in columns. A column is defined as the average width of a character as defined by SWT's FontMetrics class.

Parameters:
numberOfCols - An int value, representing the number of columns
See Also:
org.eclipse.swt.graphics.FontMetrics}

getRows

public int getRows()
Returns the height of the widget in rows. A row is defined as the average height of a character as defined by SWT's FontMetrics class.

Returns:
An int value representing the row height of this control
See Also:
org.eclipse.swt.graphics.FontMetrics}

setRows

public void setRows(int rows)
Sets the height of the widget in rows. A row is defined as the average height of a character as defined by SWT's FontMetrics class.

Parameters:
numOfRows - An int value, representing the number of rows
See Also:
org.eclipse.swt.graphics.FontMetrics}

getValidator

public IValidator getValidator()
Returns the validator associated with this text field. Can be null.

Returns:

setValidator

public void setValidator(IValidator validator)
Sets a validator which is used to make sure that user input conforms to certain predefined criteria. If the criteria is not met the user will be notified via a message box.

Parameters:
validator -

validate

protected boolean validate()

getId

public java.lang.String getId()
Description copied from interface: ICustomControl
Returns a string identifier associated with the current widget/control

Specified by:
getId in interface ICustomControl
Returns:
String

setId

public void setId(java.lang.String id)
Description copied from interface: ICustomControl
Sets a string identifier on the current widget/control.

Specified by:
setId in interface ICustomControl

resetTextToPriorValue

protected void resetTextToPriorValue(java.lang.String value)