com.tensegrity.gui.swt.control.widgets
Class TextField

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended bycom.tensegrity.gui.swt.control.widgets.TextField
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
DoubleTextField, IntegerTextField, MetricExpressionTextField

public abstract class TextField
extends org.eclipse.swt.widgets.Composite

Abtract base class for all Tensegrity SWT textfield widgets

Version:
$Id: TextField.java,v 1.9 2005/11/10 15:27:16 ArndHouben Exp $
Author:
Arnd Houben

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
TextField(org.eclipse.swt.widgets.Composite parent, int style)
          Creates a new TextField instance with an empty initial value
TextField(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String initialInput)
          Constructor expecting initial input value
 
Method Summary
 void addFocusListener(org.eclipse.swt.events.FocusListener l)
           
 void addInputChangedListener(InputChangedListener l)
          Adds the given InputChangedListener to the list of all listeners
 void addModifyListener(org.eclipse.swt.events.ModifyListener l)
          Adds the specified listener to the list of listeners which gets notified when the text field value was modified.
 void allowIsoControl(boolean allowIsoControl)
          Defines the handling of so called iso control characters, such as backspace, cursor keys etc.
 int getCaretPosition()
          The current character position of the caret is returned.
 java.lang.String getText()
          Gets the text field text.
protected abstract  boolean isValid(char character)
           Checks if the given character is valid in the sense of an implementing class.
protected abstract  boolean isValid(java.lang.String input)
           Checks if the given string is valid in the sense of an implementing class.
 void removeFocusListener(org.eclipse.swt.events.FocusListener l)
           
 void removeInputChangedListener(InputChangedListener l)
          Removes the given InputChangedListener from the list of all listeners
 void removeModifyListener(org.eclipse.swt.events.ModifyListener l)
          Removes the specified listener from the list of listeners which gets notified on text field modifications
 void setEnabled(boolean enabled)
           
 void setText(java.lang.String input)
          Sets the specified input string if its valid.
 void setTextLimit(int limit)
          Sets the maximum number of characters that the text field will display.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextField

public TextField(org.eclipse.swt.widgets.Composite parent,
                 int style)
Creates a new TextField instance with an empty initial value

Parameters:
parent - the parent widget to add this TextField to
style - the TextField widget style defined by SWT constants

TextField

public TextField(org.eclipse.swt.widgets.Composite parent,
                 int style,
                 java.lang.String initialInput)
Constructor expecting initial input value

Parameters:
parent - the parent widget (cannot be null)
style - the widget style
initialInput - the initial string input
Method Detail

isValid

protected abstract boolean isValid(char character)

Checks if the given character is valid in the sense of an implementing class. This method is called after each key press. Invalid characters are not shown, i.e. if this method returns false, the last typed character is not displayed.

Note: by default iso control characters are allowed, i.e. backspace, cursor keys etc. If you do not want to support them you have to explicitly forbid them via allowIsoControl(false).

Returns:
true if character is valid, false otherwise

isValid

protected abstract boolean isValid(java.lang.String input)

Checks if the given string is valid in the sense of an implementing class. This method is called after the text input is finished. If this method returns false the input is not seen as to be completed.

Parameters:
input - the current text content of the textfield.
Returns:
true if the string is valid, false otherwise

setTextLimit

public void setTextLimit(int limit)
Sets the maximum number of characters that the text field will display.

Parameters:
limit - the new text limit

allowIsoControl

public void allowIsoControl(boolean allowIsoControl)
Defines the handling of so called iso control characters, such as backspace, cursor keys etc.

Parameters:
allowIsoControl - set to true to indicate that iso control characters should be allowed, false otherwise

getText

public java.lang.String getText()
Gets the text field text.

Returns:
the text input

setText

public final void setText(java.lang.String input)
Sets the specified input string if its valid. Which input is valid is defined by the isValid(String) method. If the input is not valid this method has no effect.

Parameters:
input - an arbitrary text

addInputChangedListener

public final void addInputChangedListener(InputChangedListener l)
Adds the given InputChangedListener to the list of all listeners

Parameters:
l - an InputChangedListener instance

removeInputChangedListener

public final void removeInputChangedListener(InputChangedListener l)
Removes the given InputChangedListener from the list of all listeners

Parameters:
l - an InputChangedListener instance

addFocusListener

public final void addFocusListener(org.eclipse.swt.events.FocusListener l)

removeFocusListener

public final void removeFocusListener(org.eclipse.swt.events.FocusListener l)

addModifyListener

public final void addModifyListener(org.eclipse.swt.events.ModifyListener l)
Adds the specified listener to the list of listeners which gets notified when the text field value was modified.

Parameters:
l - the listener which should be notified

removeModifyListener

public final void removeModifyListener(org.eclipse.swt.events.ModifyListener l)
Removes the specified listener from the list of listeners which gets notified on text field modifications

Parameters:
l - the listener which should no longer be notified

getCaretPosition

public final int getCaretPosition()
The current character position of the caret is returned.

Returns:
the position of the caret

setEnabled

public void setEnabled(boolean enabled)


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.