Class JComboBoxConfigurableLookUp.PlainDocumentTextFormatter

java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp.PlainDocumentTextFormatter
All Implemented Interfaces:
Serializable, Document
Enclosing class:
JComboBoxConfigurableLookUp

public class JComboBoxConfigurableLookUp.PlainDocumentTextFormatter extends PlainDocument

Inner class that inherits of the class PlainDocument, and is used for manipulate the textWritten that has the document of the editor of this component.

This class is also optimized for items look up process.

Author:
Pablo Piqueras Bartolomé (p_queras@hotmail.com)
See Also:
  • Constructor Details

    • PlainDocumentTextFormatter

      public PlainDocumentTextFormatter()

      Default Constructor.

  • Method Details

    • initialize

      protected void initialize()

      This method makes some initialize operations.

    • setJComboBoxReference

      protected void setJComboBoxReference(JComboBoxConfigurableLookUp comboBox)

      Sets a reference of this component.

      Parameters:
      comboBox - A reference to the class that contains this.
    • insertString

      public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
      Specified by:
      insertString in interface Document
      Overrides:
      insertString in class PlainDocument
      Throws:
      BadLocationException
    • replace

      public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException
      Overrides:
      replace in class AbstractDocument
      Throws:
      BadLocationException
    • remove

      public void remove(int offs, int len) throws BadLocationException
      Specified by:
      remove in interface Document
      Overrides:
      remove in class AbstractDocument
      Throws:
      BadLocationException
    • updateTextColorAndRingBeep

      public void updateTextColorAndRingBeep()

      Updates the color of the text in the ComboBoxEditor of this component, and rings a beep if there is no item.

      • Text in red color: if no item matches with the text written according the ILookUp agent.
      • Text in black color: if there is at least one item matches with the text written according the ILookUp agent.
    • updateCaretPosition

      public void updateCaretPosition(int position)

      Updates the position of the caret in the ComboBoxEditor of this component.

      Parameters:
      position - the new position of the caret.
    • updateOnlyTextColor

      public void updateOnlyTextColor()

      Updates the color of the text in this document.

      Sets text to red color if there is no item in the visible list that the look up agent returned with that text and the items of the dataModel, and, being enabled the second color in the configuration the the JcomboBoxConfigurableLookUp agent. Otherwise, the foreground color of the text will be black.

      This method disables the beep during the process of updating the color of the text, and restores it after.