org.opensubsystems.patterns.thickclient.application.swt
Class NumberPad

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.Composite
                  extended by org.opensubsystems.patterns.thickclient.application.swt.NumberPad
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, ModificationListener

public class NumberPad
extends org.eclipse.swt.widgets.Composite
implements ModificationListener

Control, which allows user to type numbers using mouse or finger on a screen.

Version:
$Id: NumberPad.java,v 1.5 2007/01/07 06:14:15 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.3 2006/04/05 05:32:51 bastafidli

Field Summary
protected static int BASE_HEIGHT
          Base (smallest) control height constant.
protected  boolean m_bDecimalDot
          If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).
protected  java.util.Date m_lastModified
          Date when the content was last modified.
protected  NumericText m_numberText
          Field which collects typed numbers.
protected  org.eclipse.swt.graphics.Point m_preferredSize
          Preferred size of this control based on the specified parameters.
protected  java.util.Set m_setListeners
          Set where all listeners listening to the event notifications specific to this object are stored.
protected  java.lang.String m_strCancelConfirmation
          Text to display to confirm canceling of the operation using cancel button.
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
NumberPad(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String strSetButtonText, boolean bBigButtons, boolean bDecimalDot)
          Construct new instance of the number pad control.
NumberPad(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String strSetButtonText, java.lang.String strCancelButtonText, java.lang.String strCancelConfirmation, boolean bBigButtons, boolean bDecimalDot)
          Construct new instance
 
Method Summary
 void addNumberPadListener(NumberPadListener listener)
          Add listener for this number pad.
protected  void createButton(java.lang.String strText, boolean bBigButtons, org.eclipse.swt.events.SelectionListener listener)
          Create new button for this number pad.
 java.lang.String formatText(java.lang.String inputText)
          Format text to represent a number, e.g.
 java.util.Date getLastModified()
           
 org.eclipse.swt.graphics.Point getPreferredSize()
          Get preferred size of this control based on the specified parameters.
 java.lang.String getText()
          Get text typed in the numeric text field.
 void modified()
          This method is called when some modification has happened.
protected  void notifyNumberPadListeners()
          Notify all listeners about event.
 void removeNumberPadListener(NumberPadListener listener)
          Remove listener from this number pad.
 void setText(java.lang.String text)
          Set text in the numeric text field.
 boolean setTextLimit(int iLimit)
          This function sets maximal nuber of characters typed
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, 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, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, 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
 

Field Detail

BASE_HEIGHT

protected static final int BASE_HEIGHT
Base (smallest) control height constant.

See Also:
Constant Field Values

m_preferredSize

protected org.eclipse.swt.graphics.Point m_preferredSize
Preferred size of this control based on the specified parameters.


m_setListeners

protected java.util.Set m_setListeners
Set where all listeners listening to the event notifications specific to this object are stored.


m_numberText

protected NumericText m_numberText
Field which collects typed numbers.


m_lastModified

protected java.util.Date m_lastModified
Date when the content was last modified. TODO: Improve: Shouldn't this be timestamp?


m_strCancelConfirmation

protected java.lang.String m_strCancelConfirmation
Text to display to confirm canceling of the operation using cancel button. If null, no confirmation is displayed.


m_bDecimalDot

protected boolean m_bDecimalDot
If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).

Constructor Detail

NumberPad

public NumberPad(org.eclipse.swt.widgets.Composite parent,
                 int style,
                 java.lang.String strSetButtonText,
                 boolean bBigButtons,
                 boolean bDecimalDot)
Construct new instance of the number pad control.

Parameters:
parent - - who is parent of this control.
style - - what style to use
strSetButtonText - - text to display in button when the user wants to finish typing number, if null, the button won't be displayed
bBigButtons - - if true then the buttons will be displayed using large fonts otherwise they will be displayed middle size
bDecimalDot - - if true extra line of buttons with decimal dot will be added to dialog. If bDecimalDot id true, number of decimal places can be set

NumberPad

public NumberPad(org.eclipse.swt.widgets.Composite parent,
                 int style,
                 java.lang.String strSetButtonText,
                 java.lang.String strCancelButtonText,
                 java.lang.String strCancelConfirmation,
                 boolean bBigButtons,
                 boolean bDecimalDot)
Construct new instance

Parameters:
parent - - who is parent of this screen
style - - what style to use
strSetButtonText - - text to display in button which user uses to finish typing number, if null, the button won't be displayed
strCancelButtonText - - text to display in button to cancel the operation, if null, the button won't be displayed
strCancelConfirmation - - text to display to confirm canceling of the operation using cancel button. If null, no confirmation is displayed.
bBigButtons - - if true then the buttons will be displayed using large fonts otherwise they will be displayed middle size
bDecimalDot - - if true extra line of buttons with decimal dot will be added to dialog. If bDecimalDot id true, number of decimal places can be set
Method Detail

getPreferredSize

public org.eclipse.swt.graphics.Point getPreferredSize()
Get preferred size of this control based on the specified parameters.

Returns:
Point

addNumberPadListener

public void addNumberPadListener(NumberPadListener listener)
Add listener for this number pad.

Parameters:
listener - - listener to add

removeNumberPadListener

public void removeNumberPadListener(NumberPadListener listener)
Remove listener from this number pad.

Parameters:
listener - - listener to remove

modified

public void modified()
This method is called when some modification has happened.

Specified by:
modified in interface ModificationListener

getLastModified

public java.util.Date getLastModified()
Returns:
Date - time of the last selection of the item.

getText

public java.lang.String getText()
Get text typed in the numeric text field.

Returns:
String - text typed in the numeric text field

setText

public void setText(java.lang.String text)
Set text in the numeric text field.

Parameters:
text - - text typed in the numeric text field

setTextLimit

public boolean setTextLimit(int iLimit)
This function sets maximal nuber of characters typed

Parameters:
iLimit - - maximal number of chracters
Returns:
boolean - sucess flag

formatText

public java.lang.String formatText(java.lang.String inputText)
Format text to represent a number, e.g. remove leading 0 etc.

Parameters:
inputText - - text to format
Returns:
String formatted string

notifyNumberPadListeners

protected void notifyNumberPadListeners()
Notify all listeners about event.


createButton

protected void createButton(java.lang.String strText,
                            boolean bBigButtons,
                            org.eclipse.swt.events.SelectionListener listener)
Create new button for this number pad.

Parameters:
strText - - text to display on the button
bBigButtons - - if true then the buttons will be displayed large otherwise they will be displayed middle size
listener - - listener processing events from the button


Copyright © 2003 - 2006 OpenSubsystems s.r.o.