Package com._1c.g5.lwt.controls
Class LightText
- java.lang.Object
-
- com._1c.g5.lwt.AbstractLightControl
-
- com._1c.g5.lwt.controls.LightText
-
- All Implemented Interfaces:
IEditable
,ILightControl
- Direct Known Subclasses:
LightFormattedText
public class LightText extends AbstractLightControl implements IEditable
Light text box control.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
LightText.OverlayFocusListener
Focus listener for overlay.protected class
LightText.OverlayKeyListener
Key listener for overlay.protected class
LightText.OverlayModifyListener
Modify listener for overlay.protected class
LightText.OverlayTraverseListener
Traverse listener for overlay.protected class
LightText.OverlayVerifyKeyListener
Verify key listener for overlay.protected class
LightText.OverlayVerifyListener
Verify listener for overlay.
-
Field Summary
Fields Modifier and Type Field Description protected static String
EMPTY_STRING
Empty string.
-
Constructor Summary
Constructors Constructor Description LightText()
Instantiates a new light text.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addTextChangedListener(IChangedListener<LightText,String> listener)
Adds the text changed listener.void
addTextChangingListener(IChangingListener<LightText,String> listener)
Adds the text changing listener.void
clearSelection()
Clears the selection of this text box.org.eclipse.swt.graphics.Point
computeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache)
Computes the size of this control.protected void
createOverlay(org.eclipse.swt.widgets.Composite parent)
Creates overlayvoid
dispose()
Disposes this control.protected String
getDisplayText(boolean displayHint)
Returns displayed text.String
getHintText()
Returns the hint text of the text.protected String
getLastNotifiedText()
Returns last notified text.protected String
getOverlayText()
Returns overlay text.protected org.eclipse.swt.widgets.Control
getOverlayTextControl()
Returns overlay text control.String
getText()
Gets the current text value.int
getTextLimit()
Returns the maximum number of characters that the light text control is capable of holding.int
getVisibleLineCount()
Gets the visible line count.void
handleEvent(org.eclipse.swt.widgets.Event event)
Handles the SWT event, SWT events are pumped to this method if this control is active.boolean
isBorderVisible()
Checks if the border is visible.boolean
isEditable()
Returns control editable state.boolean
isLiveEditing()
Checks if this text is in live editing mode or not.boolean
isMultiline()
Checks if this text is multiline.boolean
isPasswordMode()
Checks whether password mode is on or off.boolean
isReadOnly()
Deprecated.useisEditable()
instead.void
paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
Paints the given rectangle of this control.void
removeTextChangedListener(IChangedListener<LightText,String> listener)
Removes the text changed listener.void
removeTextChangingListener(IChangingListener<LightText,String> listener)
Removes the text changing listener.protected void
resetOverlayTextControl()
Resets overlay text control.protected void
resetTextSize()
Resets text size.protected void
selectAllOverlayText()
Selects all overlay text.void
setBackgroundColor(org.eclipse.swt.graphics.Color backgroundColor)
Sets the background color.void
setBorderColor(org.eclipse.swt.graphics.Color borderColor)
Sets the border color.void
setBorderVisible(boolean borderVisible)
Sets the border visibility.void
setBounds(org.eclipse.swt.graphics.Rectangle bounds)
Sets the bounds of this control.void
setEditable(boolean isEditable)
Sets control editable state.void
setEnabled(boolean enabled)
Sets this control enablement.boolean
setFocus(FocusSource focusSource)
Sets the focus to this control.void
setHintColor(org.eclipse.swt.graphics.Color hintColor)
Sets the hint text color.void
setHintText(String hintText)
Set the hint text of the text.protected void
setLastNotifiedText(String lastNotifiedText)
Sets last notified text.void
setLiveEditing(boolean liveEditing)
Sets the live editing mode on or off.void
setMultiline(boolean multiline)
Sets the multiline mode on or off.protected void
setOverlayText(String text)
Sets overlay text.void
setPasswordMode(boolean passwordMode)
Sets password mode on or off.void
setReadOnly(boolean readOnly)
Deprecated.usesetEditable(boolean)
instaed.void
setText(String text)
Sets the text.void
setTextColor(org.eclipse.swt.graphics.Color textColor)
Sets the text color.protected void
setTextInternal(String text)
Sets text without checking it.void
setTextLimit(int textLimit)
Sets the text limit to the specified number of characters.protected void
setUndoRedoText(String undoRedoText)
Sets undo redo text.void
setVisible(boolean value)
Sets this control visibility.void
setVisibleLineCount(int visibleLineCount)
Sets the visible line count.-
Methods inherited from class com._1c.g5.lwt.AbstractLightControl
addControlListener, getBounds, getCursor, getData, getLayoutData, getOverlay, getParent, getTooltip, getVisibleBounds, invalidate, invalidate, isDisposed, isEnabled, isFocused, isVisible, removeControlListener, setCursor, setData, setFocusable, setLayoutData, setOverlay, setParent, setTooltip
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com._1c.g5.lwt.ILightControl
initialize
-
-
-
-
Field Detail
-
EMPTY_STRING
protected static final String EMPTY_STRING
Empty string.- See Also:
- Constant Field Values
-
-
Method Detail
-
isMultiline
public boolean isMultiline()
Checks if this text is multiline.- Returns:
true
if it is multiline,false
otherwise.
-
setMultiline
public void setMultiline(boolean multiline)
Sets the multiline mode on or off.- Parameters:
multiline
-true
to turn the multiline mode on,false
to turn off.
-
getVisibleLineCount
public int getVisibleLineCount()
Gets the visible line count.- Returns:
- the visible line count,
-1
if no limit set.
-
setVisibleLineCount
public void setVisibleLineCount(int visibleLineCount)
Sets the visible line count.- Parameters:
visibleLineCount
- the new visible line count,-1
to clear the limit.
-
isLiveEditing
public boolean isLiveEditing()
Checks if this text is in live editing mode or not. In live editing mode text change listeners are notified immediately after the change. If live editing mode is off, change listeners are notified when a user hits the return key or this text box losses the focus.- Returns:
true
if live editing is on,false
otherwise.
-
setLiveEditing
public void setLiveEditing(boolean liveEditing)
Sets the live editing mode on or off.- Parameters:
liveEditing
-true
to turn the live editing mode on,false
otherwise.- See Also:
isLiveEditing()
-
isBorderVisible
public boolean isBorderVisible()
Checks if the border is visible.- Returns:
true
if border is visible,false
if not.
-
setBorderVisible
public void setBorderVisible(boolean borderVisible)
Sets the border visibility.- Parameters:
borderVisible
-true
to show the border,false
to hide it.
-
setEditable
public void setEditable(boolean isEditable)
Description copied from interface:IEditable
Sets control editable state.- Specified by:
setEditable
in interfaceIEditable
- Parameters:
isEditable
- -true
if control can be edited.
-
isEditable
public boolean isEditable()
Description copied from interface:IEditable
Returns control editable state.- Specified by:
isEditable
in interfaceIEditable
- Returns:
true
if control can be edited.
-
isReadOnly
@Deprecated public boolean isReadOnly()
Deprecated.useisEditable()
instead.Checks if this text is read only or not.- Returns:
true
if text is in read-only mode,false
otherwise.
-
setReadOnly
@Deprecated public void setReadOnly(boolean readOnly)
Deprecated.usesetEditable(boolean)
instaed.Sets the read only mode on or off.- Parameters:
readOnly
-true
to turn read-only mode on,false
to turn it off.
-
isPasswordMode
public boolean isPasswordMode()
Checks whether password mode is on or off.- Returns:
true
if text is in password mode,false
otherwise.
-
setPasswordMode
public void setPasswordMode(boolean passwordMode)
Sets password mode on or off. If password mode is set, text will hide all entered chars.- Parameters:
passwordMode
-true
to turn password mode on,false
to turn it off.
-
setBorderColor
public void setBorderColor(org.eclipse.swt.graphics.Color borderColor)
Sets the border color.- Parameters:
borderColor
- the new border color.
-
setTextColor
public void setTextColor(org.eclipse.swt.graphics.Color textColor)
Sets the text color.- Parameters:
textColor
- the new text color.
-
setBackgroundColor
public void setBackgroundColor(org.eclipse.swt.graphics.Color backgroundColor)
Sets the background color.- Parameters:
backgroundColor
- the new background color.
-
setHintColor
public void setHintColor(org.eclipse.swt.graphics.Color hintColor)
Sets the hint text color.- Parameters:
hintColor
- the new hint text color, cannot benull
-
getText
public String getText()
Gets the current text value.- Returns:
- the text.
-
getHintText
public String getHintText()
Returns the hint text of the text. Can returnnull
if none hint is set.- Returns:
- the hint text of the text or
null
if none hint is set.
-
setHintText
public void setHintText(String hintText)
Set the hint text of the text. Hint will be displayed when no text is entered.- Parameters:
hintText
- - the hint text, cannote benull
-
setText
public void setText(String text)
Sets the text.- Parameters:
text
- the new text.
-
setTextLimit
public void setTextLimit(int textLimit)
Sets the text limit to the specified number of characters.
The text limit specifies the amount of text that the user can type into the light text control.- Parameters:
textLimit
- the new text limit.
-
getTextLimit
public int getTextLimit()
Returns the maximum number of characters that the light text control is capable of holding.- Returns:
- the textLimit the text limit
-
addTextChangedListener
public void addTextChangedListener(IChangedListener<LightText,String> listener)
Adds the text changed listener.- Parameters:
listener
- the listener.
-
removeTextChangedListener
public void removeTextChangedListener(IChangedListener<LightText,String> listener)
Removes the text changed listener.- Parameters:
listener
- the listener.
-
addTextChangingListener
public void addTextChangingListener(IChangingListener<LightText,String> listener)
Adds the text changing listener.- Parameters:
listener
- the listener.
-
removeTextChangingListener
public void removeTextChangingListener(IChangingListener<LightText,String> listener)
Removes the text changing listener.- Parameters:
listener
- the listener.
-
clearSelection
public void clearSelection()
Clears the selection of this text box.
-
setBounds
public void setBounds(org.eclipse.swt.graphics.Rectangle bounds)
Description copied from interface:ILightControl
Sets the bounds of this control.- Specified by:
setBounds
in interfaceILightControl
- Overrides:
setBounds
in classAbstractLightControl
- Parameters:
bounds
- the new bounds.
-
paint
public void paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
Description copied from interface:ILightControl
Paints the given rectangle of this control.- Specified by:
paint
in interfaceILightControl
- Parameters:
gc
- theGC
to paint on.rectangle
- the rectangle to paint.
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache)
Description copied from interface:ILightControl
Computes the size of this control.- Specified by:
computeSize
in interfaceILightControl
- Overrides:
computeSize
in classAbstractLightControl
- Parameters:
gc
- the GC to do measurements with.width
- the width hint,SWT.DEFAULT
to compute the preferred width.height
- the height hint,SWT.DEFAULT
to compute the preferred height.flushCache
- the flush cache flag, instructs the associated layout to reset all its caches, if any.- Returns:
- the computed size.
-
handleEvent
public void handleEvent(org.eclipse.swt.widgets.Event event)
Description copied from interface:ILightControl
Handles the SWT event, SWT events are pumped to this method if this control is active.- Specified by:
handleEvent
in interfaceILightControl
- Overrides:
handleEvent
in classAbstractLightControl
- Parameters:
event
- the event to handle.- See Also:
ILightComposite.setActiveControl(ILightControl)
-
setFocus
public boolean setFocus(FocusSource focusSource)
Description copied from interface:ILightControl
Sets the focus to this control.- Specified by:
setFocus
in interfaceILightControl
- Overrides:
setFocus
in classAbstractLightControl
- Parameters:
focusSource
- the focus request source.- Returns:
true
if focus was set,false
otherwise.
-
dispose
public void dispose()
Description copied from interface:ILightControl
Disposes this control.- Specified by:
dispose
in interfaceILightControl
- Overrides:
dispose
in classAbstractLightControl
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:ILightControl
Sets this control enablement.- Specified by:
setEnabled
in interfaceILightControl
- Overrides:
setEnabled
in classAbstractLightControl
-
setVisible
public void setVisible(boolean value)
Description copied from interface:ILightControl
Sets this control visibility.- Specified by:
setVisible
in interfaceILightControl
- Overrides:
setVisible
in classAbstractLightControl
- Parameters:
value
- the new visibility value.
-
getOverlayTextControl
protected org.eclipse.swt.widgets.Control getOverlayTextControl()
Returns overlay text control.- Returns:
- overlay text control. Returns
null
if there is no overlay at the moment.
-
resetOverlayTextControl
protected void resetOverlayTextControl()
Resets overlay text control.
-
createOverlay
protected void createOverlay(org.eclipse.swt.widgets.Composite parent)
Creates overlay- Parameters:
parent
- - overlay parent. can't benull
.
-
setOverlayText
protected void setOverlayText(String text)
Sets overlay text.- Parameters:
text
- - text to set. Can't benull
.
-
getOverlayText
protected String getOverlayText()
Returns overlay text.- Returns:
- overlay text. Can't return
null
.
-
selectAllOverlayText
protected void selectAllOverlayText()
Selects all overlay text.
-
getDisplayText
protected String getDisplayText(boolean displayHint)
Returns displayed text.- Parameters:
displayHint
- -true
if should return hint if it is displaying.- Returns:
- displayed text. Can't return
null
.
-
getLastNotifiedText
protected String getLastNotifiedText()
Returns last notified text.- Returns:
- last notified text. Can't return
null
.
-
setLastNotifiedText
protected void setLastNotifiedText(String lastNotifiedText)
Sets last notified text.- Parameters:
lastNotifiedText
- - last notified text to set. Can't benull
.
-
resetTextSize
protected void resetTextSize()
Resets text size.
-
setTextInternal
protected void setTextInternal(String text)
Sets text without checking it.- Parameters:
text
- - text to set. Can't benull
.
-
setUndoRedoText
protected void setUndoRedoText(String undoRedoText)
Sets undo redo text.- Parameters:
undoRedoText
- - undo redo text to set. Can't benull
.
-
-