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

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
                      extended bycom.tensegrity.gui.swt.control.widgets.MetricExpressionTextField
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class MetricExpressionTextField
extends TextField

This TextField extension is used for editing MetricExpressions. When creating an instance of this class a MetricExpression must be passed into the constructor as initial value.
NOTE: getMetricExpression() creates a new instance of a MetricExpression.

Version:
$Id: MetricExpressionTextField.java,v 1.2 2005/10/05 13:35:35 ArndHouben Exp $
Author:
Arnd Houben

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
MetricExpressionTextField(org.eclipse.swt.widgets.Composite parent, int style, MetricExpression initialMetricExp)
          Creates a new MetricExpressionTextField displaying the given initial metric expression.
 
Method Summary
 MetricExpression getMetricExpression()
          Returns an instance of MetricExpression which is created from the current text field value.
protected  boolean isValid(char character)
           Checks if the given character is valid in the sense of an implementing class.
protected  boolean isValid(java.lang.String input)
           Checks if the given string is valid in the sense of an implementing class.
 void setMetricExpression(MetricExpression metricExp)
          Fills the text field with the string representation of the MetricExpression given by mexp.
 
Methods inherited from class com.tensegrity.gui.swt.control.widgets.TextField
addFocusListener, addInputChangedListener, addModifyListener, allowIsoControl, getCaretPosition, getText, removeFocusListener, removeInputChangedListener, removeModifyListener, setEnabled, setText, setTextLimit
 
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

MetricExpressionTextField

public MetricExpressionTextField(org.eclipse.swt.widgets.Composite parent,
                                 int style,
                                 MetricExpression initialMetricExp)
Creates a new MetricExpressionTextField displaying the given initial metric expression.

Parameters:
parent - the parent widget to add this text field to
style - the text field style defined by SWT constants
initialMetricExp - the initial MetricExpression value
Method Detail

setMetricExpression

public void setMetricExpression(MetricExpression metricExp)
Fills the text field with the string representation of the MetricExpression given by mexp.

Parameters:
metricExp - the MetricExpression who's string representation is used to fill the text field with

getMetricExpression

public MetricExpression getMetricExpression()
                                     throws MetricExpressionParserException
Returns an instance of MetricExpression which is created from the current text field value.

Returns:
MetricExpression an instance of a MetricExpression
Throws:
MetricExpressionParserException - is thrown when the current text within the text field is not a valid metric expression.

isValid

protected boolean isValid(char character)
Description copied from class: TextField

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).

Specified by:
isValid in class TextField
Returns:
true if character is valid, false otherwise

isValid

protected boolean isValid(java.lang.String input)
Description copied from class: TextField

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.

Specified by:
isValid in class TextField
Parameters:
input - the current text content of the textfield.
Returns:
true if the string is valid, false otherwise


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