com.ibm.editors.swt
Class VisualText

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.Text
                  extended bycom.ibm.editors.swt.VisualText
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class VisualText
extends org.eclipse.swt.widgets.Text

Instances of this class are selectable user interface objects that allow the user to enter and modify text in Visual or Logical mode. The visual editor supports visual data typing modes, such as: push, autopush, field reverse (familar to IBM host terminal users) that may be turned on/off by contextual menu or hot key combinations. The hot key combinations and corresponding text in contextual menu are customizable via public set methods. Depending on style being passed in second constructor's parameter, the editor will implement corresponding typing mode as follows: SWT.LEFT_TO_RIGHT - 'Visual Left-To-Right' typing mode SWT.RIGHT_TO_LEFT - 'Visual Right-To-Left' typing mode None of above - 'Regular Logical' typing mode The typing mode can be also changed dynamically for editor instance by calling 'setOrientation' method that excepts one of the following values: SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, SWT.NULL The visual editor supports overwrite mode, toggling between 'insert' and 'overwrite' mode could be enacted by pressing 'Insert' key.

Styles:
RIGHT_TO_LEFT,LEFT_TO_RIGHT CENTER, LEFT, MULTI, PASSWORD, SINGLE, RIGHT, READ_ONLY, WRAP
Events:
DefaultSelection, Modify, Verify

Note: Only one of the styles MULTI and SINGLE may be specified.

IMPORTANT: This class is not intended to be subclassed.


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
VisualText(org.eclipse.swt.widgets.Composite parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void append(java.lang.String str)
          Appends a string.
 boolean getAutoPush()
          Gets auto push mode
 int getCaretPosition()
          Gets the position of the caret.
 int getCharCount()
          Gets the number of characters.
 boolean getFieldReverse()
          Gets field reverse typing mode
 boolean getHindi()
          Gets hindi numbers typing mode
 int getOrientation()
          Returns the orientation of the receiver.
 boolean getOverWriteMode()
          Gets overwrite typing mode state
 boolean getPush()
          Gets push mode state
 org.eclipse.swt.graphics.Point getSelection()
          Gets the position of the selected text.
 int getSelectionCount()
          Gets the number of selected characters.
 java.lang.String getSelectionText()
          Gets the selected text.
 int getStyle()
          Gets the widget style.
 java.lang.String getText()
          Gets the widget text.
 java.lang.String getText(int start, int end)
          Gets a range of text.
 int getTextLimit()
          Returns the maximum number of characters that the receiver is capable of holding.
 void insert(java.lang.String str)
          Inserts a string.
 boolean isShapeNeeded()
          Queries shapeNeeded state
 void redefineHotKeyAutopush(int keyCode, int stateMask, java.lang.String hotKeyMenuText)
          Redefines the hot key setting for toggling auto-push mode
 void redefineHotKeyFieldReverse(int keyCode, int stateMask, java.lang.String hotKeyMenuText)
          Redefines the hot key setting for toggling field-reverse mode
 void redefineHotKeyHindi(int keyCode, int stateMask, java.lang.String hotKeyMenuText)
          Redefines the hot key setting for toggling hindi numbers typing mode
 void redefineHotKeyPushOff(int keyCode, int stateMask, java.lang.String hotKeyMenuText)
          Redefines the hot key setting for turning off push mode
 void redefineHotKeyPushOn(int keyCode, int stateMask, java.lang.String hotKeyMenuText)
          Redefines the hot key setting for turning on push mode
 void setCodePage(int codepage)
          sets code page for Widget
 boolean setFieldReverse(boolean fieldreverse, org.eclipse.swt.widgets.Text control)
          Sets field reverse typing mode
 boolean setHindi(boolean hindi)
          Sets hindi numbers typing mode
 void setOrientation(int orientation)
          Sets the logical orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
 void setOverWriteMode(boolean isOverWriteMode)
          Sets overwrite typing mode
 boolean setPush(boolean push)
          Sets push mode state
 void setSelection(int start)
          Sets the selection.
 void setSelection(int start, int end)
          Sets the selection.
 void setSelection(org.eclipse.swt.graphics.Point selection)
          Sets the selection.
 void setShapeNeeded(boolean shape)
          Indicates to call BIDI engine when pushing is ON or the field is reversed in order to shape Arabic characters.
 void setText(java.lang.String str)
          Sets the contents of the receiver to the given string.
 void setTextLimit(int limit)
          Sets the maximum number of characters that the receiver is capable of holding to be the argument.
 void setVisualOrientation(int orientation)
          Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT or SWT.NULL.
 
Methods inherited from class org.eclipse.swt.widgets.Text
addModifyListener, addSelectionListener, addVerifyListener, clearSelection, computeSize, computeTrim, copy, cut, getBorderWidth, getCaretLineNumber, getCaretLocation, getDoubleClickEnabled, getEchoChar, getEditable, getLineCount, getLineDelimiter, getLineHeight, getTabs, getTopIndex, getTopPixel, paste, removeModifyListener, removeSelectionListener, removeVerifyListener, selectAll, setDoubleClickEnabled, setEchoChar, setEditable, setFont, setRedraw, setTabs, setTopIndex, showSelection
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getClientArea, 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, setFocus, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, dispose, getData, getData, getDisplay, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VisualText

public VisualText(org.eclipse.swt.widgets.Composite parent,
                  int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
Throws:
java.lang.IllegalArgumentException -
org.eclipse.swt.SWTException -
See Also:
SWT.RIGHT_TO_LEFT, SWT.LEFT_TO_RIGHT, SWT.SINGLE, SWT.MULTI, SWT.READ_ONLY, SWT.WRAP
Method Detail

setVisualOrientation

public void setVisualOrientation(int orientation)
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT or SWT.NULL.

Parameters:
orientation - new orientation style SWT.LEFT_TO_RIGHT - 'Visual Left-To-Right' typing mode SWT.RIGHT_TO_LEFT - 'Visual Right-To-Left' typing mode SWT.NULL - 'Regular Logical' typing mode
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.1.2

setOrientation

public void setOrientation(int orientation)
Sets the logical orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.

Note: This operation is a hint and is not supported on platforms that do not have this concept.

Parameters:
orientation - new orientation style
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getOrientation

public int getOrientation()
Returns the orientation of the receiver.

Returns:
the orientation style
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.1.2

setText

public void setText(java.lang.String str)
Sets the contents of the receiver to the given string. If the receiver has style SINGLE and the argument contains multiple lines of text, the result of this operation is undefined and may vary from platform to platform.

Parameters:
str - - string the new text
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

append

public void append(java.lang.String str)
Appends a string.

The new text is appended to the text at the end of the widget.

Parameters:
str - - string the string to be appended
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

insert

public void insert(java.lang.String str)
Inserts a string.

The old selection is replaced with the new text.

Parameters:
str - - string the string
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getText

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

The text for a text widget is the characters in the widget.

Returns:
the widget text
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getText

public java.lang.String getText(int start,
                                int end)
Gets a range of text. Returns an empty string if the start of the range is greater than the end.

Indexing is zero based. The range of a selection is from 0..N-1 where N is the number of characters in the widget.

Parameters:
start - the start of the range
end - the end of the range
Returns:
the range of text
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getCharCount

public int getCharCount()
Gets the number of characters.

Returns:
number of characters in the widget
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setTextLimit

public void setTextLimit(int limit)
Sets the maximum number of characters that the receiver is capable of holding to be the argument.

Instead of trying to set the text limit to zero, consider creating a read-only text widget.

To reset this value to the default, use setTextLimit(Text.LIMIT).

Parameters:
limit - new text limit
Throws:
java.lang.IllegalArgumentException -
  • ERROR_CANNOT_BE_ZERO - if the limit is zero
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getTextLimit

public int getTextLimit()
Returns the maximum number of characters that the receiver is capable of holding.

If this has not been changed by setTextLimit(), it will be the constant Text.LIMIT.

Returns:
the text limit
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getCaretPosition

public int getCaretPosition()
Gets the position of the caret.

The character position of the caret is returned.

Returns:
the position of the caret
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getSelection

public org.eclipse.swt.graphics.Point getSelection()
Gets the position of the selected text.

Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.

Returns:
the start and end of the selection
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setSelection

public void setSelection(int start)
Sets the selection.

Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.

Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the regular array indexing rules.

Parameters:
start - new caret position
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setSelection

public void setSelection(int start,
                         int end)
Sets the selection.

Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.

Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the usual array indexing rules.

Parameters:
start - the start of the range
end - the end of the range
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setSelection

public void setSelection(org.eclipse.swt.graphics.Point selection)
Sets the selection.

Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.

Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the usual array indexing rules.

Parameters:
selection - the point
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the point is null
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getSelectionCount

public int getSelectionCount()
Gets the number of selected characters.

Returns:
the number of selected characters.
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getSelectionText

public java.lang.String getSelectionText()
Gets the selected text.

Returns:
the selected text
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setCodePage

public void setCodePage(int codepage)
sets code page for Widget

Parameters:
codepage - - BiDi codepage 424/420

getStyle

public int getStyle()
Gets the widget style.

Returns:
the widget style

setPush

public boolean setPush(boolean push)
Sets push mode state

Parameters:
push - mode state of widget "on - true/off - false"

getPush

public boolean getPush()
Gets push mode state

Returns:
push mode state of widget "on - true/off - false"

getAutoPush

public boolean getAutoPush()
Gets auto push mode

Returns:
auto push mode of widget "on - true/off - false"

setHindi

public boolean setHindi(boolean hindi)
Sets hindi numbers typing mode

Parameters:
hindi - numbers typing mode of widget "on - true/off - false" Numeral shapes designates whether the numbers being inserted have to be presented using the European digit shapes or Arabic-Indic digit shapes.

getHindi

public boolean getHindi()
Gets hindi numbers typing mode

Returns:
hindi numbers typing mode of widget "on - true/off - false" Numeral shapes designates whether the numbers being inserted have to be presented using the European digit shapes or Arabic-Indic digit shapes.

setFieldReverse

public boolean setFieldReverse(boolean fieldreverse,
                               org.eclipse.swt.widgets.Text control)
Sets field reverse typing mode

Parameters:
fieldreverse - - field reverse typing mode of widget "on - true/off - false"

getFieldReverse

public boolean getFieldReverse()
Gets field reverse typing mode

Returns:
field reverse typing mode of widget "on - true/off - false"

redefineHotKeyPushOn

public void redefineHotKeyPushOn(int keyCode,
                                 int stateMask,
                                 java.lang.String hotKeyMenuText)
Redefines the hot key setting for turning on push mode

Parameters:
keyCode - - redefined key code
stateMask - - redefined state mask
hotKeyMenuText - - redefined text for context menu hot key description

redefineHotKeyPushOff

public void redefineHotKeyPushOff(int keyCode,
                                  int stateMask,
                                  java.lang.String hotKeyMenuText)
Redefines the hot key setting for turning off push mode

Parameters:
keyCode - - redefined key code
stateMask - - redefined state mask
hotKeyMenuText - - redefined text for context menu hot key description

redefineHotKeyAutopush

public void redefineHotKeyAutopush(int keyCode,
                                   int stateMask,
                                   java.lang.String hotKeyMenuText)
Redefines the hot key setting for toggling auto-push mode

Parameters:
keyCode - - redefined key code
stateMask - - redefined state mask
hotKeyMenuText - - redefined text for context menu hot key description

redefineHotKeyFieldReverse

public void redefineHotKeyFieldReverse(int keyCode,
                                       int stateMask,
                                       java.lang.String hotKeyMenuText)
Redefines the hot key setting for toggling field-reverse mode

Parameters:
keyCode - - redefined key code
stateMask - - redefined state mask
hotKeyMenuText - - redefined text for context menu hot key description

redefineHotKeyHindi

public void redefineHotKeyHindi(int keyCode,
                                int stateMask,
                                java.lang.String hotKeyMenuText)
Redefines the hot key setting for toggling hindi numbers typing mode

Parameters:
keyCode - - redefined key code
stateMask - - redefined state mask
hotKeyMenuText - - redefined text for context menu hot key description

getOverWriteMode

public boolean getOverWriteMode()
Gets overwrite typing mode state

Returns:
overwrite typing mode of widget "on - true/off - false"

setOverWriteMode

public void setOverWriteMode(boolean isOverWriteMode)
Sets overwrite typing mode

Parameters:
isOverWriteMode - - typing mode of widget "on - true/off - false"

setShapeNeeded

public void setShapeNeeded(boolean shape)
Indicates to call BIDI engine when pushing is ON or the field is reversed in order to shape Arabic characters. shapeNeeded is a boolean to determine to perform shaping because in some environments the shaping is done externally not using the enclosed shaping engine. The default value is 'false'.

Parameters:
shape - - indicates if Arabic shaping is needed for typing in/pasting text

isShapeNeeded

public boolean isShapeNeeded()
Queries shapeNeeded state

Returns:
shapeNeeded state "on - true/off - false"