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

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.eclipse.swt.widgets.Canvas
                      extended by org.opensubsystems.patterns.thickclient.application.swt.CharacterPad
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, EventProcessor, ModificationListener, TextProcessor

public class CharacterPad
extends org.eclipse.swt.widgets.Canvas
implements ModificationListener, TextProcessor, EventProcessor

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

Version:
$Id: CharacterPad.java,v 1.6 2007/01/07 06:14:15 bastafidli Exp $
Author:
Martin Cerba
Code reviewer:
Miro Halas
Code reviewed:
1.4 2006/04/05 05:31:04 bastafidli

Nested Class Summary
static class CharacterPad.CharacterPadLayout
          Structure defining what keys should appear in the keyboard pad and what is the width of the pad.
 
Field Summary
protected static int BASE_DIALOG_HEIGHT
          Base (smallest) dialog height constant.
static int CAPSLOCK_WIDTH
          Width of capslock button
static int CHP_HIDECAPSLOCK
          hide caps lock button
static int CHP_NONE
          special flag for character pad
static int CHP_SWITCHTOLOWERCASE
          if CHP_UPPERCASE switch to loweracse after first chracter
static int CHP_UPPERCASE
          set caps lock to uppercase on beginnig
static java.lang.String[] ENTER_BUTTON
          Button used to enter values
static CharacterPad.CharacterPadLayout KEY_LAYOUT_123
          constant for all numeric characters
static CharacterPad.CharacterPadLayout KEY_LAYOUT_123_QWERTY
          constant for all numeric characters
static CharacterPad.CharacterPadLayout KEY_LAYOUT_123_QWERTY_SPECIAL
          constant for all numeric characters
static CharacterPad.CharacterPadLayout KEY_LAYOUT_QWERTY
          constant for all numeric characters
protected  boolean m_bHideCapsLock
          Should we hide the capslock flag?
protected  boolean m_bToLowercase
          Switch to lower case after characeter will be entered
protected  org.eclipse.swt.widgets.Button m_capsLock
          Caps lock button
protected  java.lang.String m_initialText
          Initial text for CharacterPad
protected  java.util.Date m_lastModified
          Date when the content was last modified.
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  int m_specialFlags
          Variable for special flags
protected  org.eclipse.swt.widgets.Text m_text
          Field which collects typed characters.
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
CharacterPad(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String[] specialButtons, CharacterPad.CharacterPadLayout keyboardLayout, int specialFlags, boolean bBigButtons)
          Constructor.
 
Method Summary
 void addCharacterPadListener(CharacterPadListener listener)
          Add listener for this character pad.
protected  void createButton(java.lang.String strText, org.eclipse.swt.events.SelectionListener listener, boolean bBigButtons)
          Create new button for this character pad.
 org.eclipse.swt.graphics.Point getPreferredSize()
          Get preferred size of this control based on the specified parameters.
 java.lang.String getText()
          Get text from CharacterPad.
 void modified()
          This method is called when some modification has happened.
protected  boolean notifyCharacterPadListeners(int intValue, java.lang.String strEvent)
          Notify all listeners about event.
 void processEvent(java.lang.String strEventName, java.lang.Integer intEventId)
          This metod receives event notification
 java.lang.String processText(java.lang.String text)
          This method receives a string representing the modification (such as the character or text typed by the user) and applies modification (if any, such as uppercase of the text) and returns the modified text.
 void removeCharacterPadListener(CharacterPadListener listener)
          Remove listener from this character pad.
 void setInitialText(java.lang.String initialText)
          Set initial text in the CharacterPad
 boolean setTextLimit(int iLimit)
          This function sets maximal nuber of characters typed
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
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, 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_DIALOG_HEIGHT

protected static final int BASE_DIALOG_HEIGHT
Base (smallest) dialog height constant.

See Also:
Constant Field Values

CHP_NONE

public static final int CHP_NONE
special flag for character pad

See Also:
Constant Field Values

CHP_UPPERCASE

public static final int CHP_UPPERCASE
set caps lock to uppercase on beginnig

See Also:
Constant Field Values

CHP_HIDECAPSLOCK

public static final int CHP_HIDECAPSLOCK
hide caps lock button

See Also:
Constant Field Values

CHP_SWITCHTOLOWERCASE

public static final int CHP_SWITCHTOLOWERCASE
if CHP_UPPERCASE switch to loweracse after first chracter

See Also:
Constant Field Values

KEY_LAYOUT_123

public static final CharacterPad.CharacterPadLayout KEY_LAYOUT_123
constant for all numeric characters


KEY_LAYOUT_123_QWERTY

public static final CharacterPad.CharacterPadLayout KEY_LAYOUT_123_QWERTY
constant for all numeric characters


KEY_LAYOUT_QWERTY

public static final CharacterPad.CharacterPadLayout KEY_LAYOUT_QWERTY
constant for all numeric characters


KEY_LAYOUT_123_QWERTY_SPECIAL

public static final CharacterPad.CharacterPadLayout KEY_LAYOUT_123_QWERTY_SPECIAL
constant for all numeric characters


ENTER_BUTTON

public static final java.lang.String[] ENTER_BUTTON
Button used to enter values


CAPSLOCK_WIDTH

public static final int CAPSLOCK_WIDTH
Width of capslock button

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_text

protected org.eclipse.swt.widgets.Text m_text
Field which collects typed characters.


m_lastModified

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


m_bHideCapsLock

protected boolean m_bHideCapsLock
Should we hide the capslock flag?


m_bToLowercase

protected boolean m_bToLowercase
Switch to lower case after characeter will be entered


m_initialText

protected java.lang.String m_initialText
Initial text for CharacterPad


m_specialFlags

protected int m_specialFlags
Variable for special flags


m_capsLock

protected org.eclipse.swt.widgets.Button m_capsLock
Caps lock button

Constructor Detail

CharacterPad

public CharacterPad(org.eclipse.swt.widgets.Composite parent,
                    int style,
                    java.lang.String[] specialButtons,
                    CharacterPad.CharacterPadLayout keyboardLayout,
                    int specialFlags,
                    boolean bBigButtons)
Constructor.

Parameters:
parent - - parent of character pad
style - - combination of SWT.xxx values
specialButtons - - array of strings for special action buttons displayed on the bottom of the dialog
keyboardLayout - - layout of keys for the keyboard pad, see the KEY_LAYOUT_XXX constants
specialFlags - - special styles for character pad, combination of CHP_XXX values
bBigButtons - - if true then the buttons will be displayed large otherwise they will be displayed middle size
Method Detail

getPreferredSize

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

Returns:
Point

modified

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

Specified by:
modified in interface ModificationListener

processText

public java.lang.String processText(java.lang.String text)
This method receives a string representing the modification (such as the character or text typed by the user) and applies modification (if any, such as uppercase of the text) and returns the modified text. If no modification is required, just return the received text.

Specified by:
processText in interface TextProcessor
Parameters:
text - - text for modification
Returns:
String with modified text

setTextLimit

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

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

processEvent

public void processEvent(java.lang.String strEventName,
                         java.lang.Integer intEventId)
This metod receives event notification

Specified by:
processEvent in interface EventProcessor
Parameters:
strEventName - - name of the event which will be sent to listener when widget is selected.
intEventId - - Integer value representing the event. It will be sent to listener when widget is selected.

addCharacterPadListener

public void addCharacterPadListener(CharacterPadListener listener)
Add listener for this character pad.

Parameters:
listener - - listener to add

removeCharacterPadListener

public void removeCharacterPadListener(CharacterPadListener listener)
Remove listener from this character pad.

Parameters:
listener - - listener to remove

getText

public java.lang.String getText()
Get text from CharacterPad.

Returns:
String

setInitialText

public void setInitialText(java.lang.String initialText)
Set initial text in the CharacterPad

Parameters:
initialText - - text for CharacterPad

createButton

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

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

notifyCharacterPadListeners

protected boolean notifyCharacterPadListeners(int intValue,
                                              java.lang.String strEvent)
Notify all listeners about event.

Parameters:
intValue - - int offset of special button text in original String[]
strEvent - - button text
Returns:
boolen - if true dialog will by closed


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