Package docking.widgets.textfield
Class TextFieldLinker.LinkerState
java.lang.Object
docking.widgets.textfield.TextFieldLinker.LinkerState
- Enclosing class:
TextFieldLinker
A class to track the internal state gathered from the text fields
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copy the stateboolean
int
Get the composite caret locationint
getGlobalCaret
(int omitSep) Get the composite caret location, omitting the given separator.getText()
Get the whole composite stringgetText
(int omitSep) Get the composite string, omitting the given separator.getTextBeforeCursor
(int field) Get the composite text preceding the caret in the given fieldboolean
isAfterSep
(int field) Figure out whether the caret in the given field immediately proceeds a separator.boolean
isBeforeSep
(int field) Figure out whether the caret in the given field immediately precedes a separator.void
navigateFieldLeft
(int field) Change focus to the given field as if navigating left.void
navigateFieldRight
(int field) Change focus to the given field as if navigating right.void
reformat()
Re-parse the composite string and place the components into their proper fieldsprotected void
removeSep
(int sep) Remove the given separator from the composite text.void
reset()
Erase the statevoid
setGlobalCaret
(int caret) Set the composite caret locationint
Set the composite texttoString()
-
Constructor Details
-
LinkerState
protected LinkerState()
-
-
Method Details
-
equals
-
copy
Copy the state- Returns:
- the copy
-
reset
public void reset()Erase the stateBlank all the fields, and put the caret at the front of the first field.
-
toString
-
getText
Get the whole composite string- Returns:
- the text
-
getText
Get the composite string, omitting the given separator.This is used as a helper to delete the separator when backspace/delete is pressed at a boundary.
- Parameters:
omitSep
- the separator to omit, or -1 to omit nothing- Returns:
- the text
-
getGlobalCaret
public int getGlobalCaret()Get the composite caret location- Returns:
- the location (including separators)
-
getGlobalCaret
public int getGlobalCaret(int omitSep) Get the composite caret location, omitting the given separator.- Parameters:
omitSep
- the separator to omit, or -1 to omit nothing- Returns:
- the location
-
getTextBeforeCursor
Get the composite text preceding the caret in the given field- Parameters:
field
- the field whose caret to use- Returns:
- the text
-
isAfterSep
public boolean isAfterSep(int field) Figure out whether the caret in the given field immediately proceeds a separator.In other words, the caret must be to the far left (position 0), and the given field must not be the first field. If true, the caret immediately follows separator index
field - 1
.- Parameters:
field
- the field index to check- Returns:
- true if the caret immediately follows a separator.
-
isBeforeSep
public boolean isBeforeSep(int field) Figure out whether the caret in the given field immediately precedes a separator.In other words, the caret must be to the far right, and the given field must not be the last field. If true, the caret immediately precedes separator index
field
.- Parameters:
field
- the field index to check- Returns:
- true if the caret immediately precedes a separator.
-
removeSep
protected void removeSep(int sep) Remove the given separator from the composite text.- Parameters:
sep
- the separator to remove, by index
-
setText
Set the composite text- Parameters:
text
- the new text
-
setGlobalCaret
Set the composite caret location- Parameters:
caret
- the new caret location- Throws:
BadLocationException
- if the location exceeds the text length
-
reformat
public void reformat()Re-parse the composite string and place the components into their proper fields
-