Package docking.widgets.textfield

# Class TextFieldLinker.LinkerState

java.lang.Object
docking.widgets.textfield.TextFieldLinker.LinkerState

Enclosing class:
  TextFieldLinker

protected class TextFieldLinker.LinkerState extends Object
A class to track the internal state gathered from the text fields

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `LinkerState()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TextFieldLinker.LinkerState`
  `copy()`
  Copy the state
  `boolean`
  `equals(Object o)`
  `int`
  `getGlobalCaret()`
  Get the composite caret location
  `int`
  `getGlobalCaret(int omitSep)`
  Get the composite caret location, omitting the given separator.
  `String`
  `getText()`
  Get the whole composite string
  `String`
  `getText(int omitSep)`
  Get the composite string, omitting the given separator.
  `String`
  `getTextBeforeCursor(int field)`
  Get the composite text preceding the caret in the given field
  `boolean`
  `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 fields
  `protected void`
  `removeSep(int sep)`
  Remove the given separator from the composite text.
  `void`
  `reset()`
  Erase the state
  `void`
  `setGlobalCaret(int caret)`
  Set the composite caret location
  `int`
  `setText(String text)`
  Set the composite text
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### LinkerState

    protected LinkerState()

- ## Method Details

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### copy

    public TextFieldLinker.LinkerState copy()
    Copy the state
    Returns:
      the copy

  - ### reset

    public void reset()
    Erase the state

    Blank all the fields, and put the caret at the front of the first field.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getText

    public String getText()
    Get the whole composite string
    Returns:
      the text

  - ### getText

    public String getText(int omitSep)
    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

    public String getTextBeforeCursor(int field)
    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.

  - ### navigateFieldLeft

    public void navigateFieldLeft(int field)
    Change focus to the given field as if navigating left.

    The caret will be moved to the rightmost position, because we're moving left from the leftmost position of the field to the right.

    Parameters:
      `field` - the field index to be given focus.

  - ### navigateFieldRight

    public void navigateFieldRight(int field)
    Change focus to the given field as if navigating right.

    The caret will be moved to the leftmost position, because we're moving right from the rightmost position of the field to the left.

    Parameters:
      `field` - the field index to be given focus.

  - ### removeSep

    protected void removeSep(int sep)
    Remove the given separator from the composite text.
    Parameters:
      `sep` - the separator to remove, by index

  - ### setText

    public int setText(String text)
    Set the composite text
    Parameters:
      `text` - the new text

  - ### setGlobalCaret

    public void setGlobalCaret(int caret) throws BadLocationException
    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