Class DefaultComboBoxConfigurableLookUpModel

java.lang.Object
javax.swing.AbstractListModel
org.gvsig.gui.beans.comboboxconfigurablelookup.DefaultComboBoxConfigurableLookUpModel
All Implemented Interfaces:
Serializable, ComboBoxModel, ListModel, MutableComboBoxModel, IComboBoxLookUp

public class DefaultComboBoxConfigurableLookUpModel extends AbstractListModel implements ComboBoxModel, MutableComboBoxModel, Serializable, IComboBoxLookUp

Re-implementation of DefaultComboBoxModel adapted for the behavior needed to look up items.

This model has configurable behaviour using flags.

DefaultComboBoxConfigurableLookUpModel represents the model used by a

invalid reference
JComboBoxLookUpConfigurable
, according the MVC (Model-View-Controller) pattern.

Flags:

  • ItemsOrder: order in which items will be showed: maintain position (according the items were introduced); alphabetical order (according the local rules); or disordered.
    + MAINTAIN_POSITION: in the same position as they are stored.
    + ALPHABETICAL_ORDERED: in alphabetical order (according a local language rules).
    + MAINTAIN_AGENT_POSITIONS: in the same position as the are returned by the look up agent.
  • ShowAllItemsInListBox: show all items in list box always, or only items that match with the text written according the ILookUp agent.
    + SHOW_ALL_ITEMS: shows all items of the model always.
    + SHOW_ONLY_MATCHES: shows only the items , or only items that match with the text written according the ILookUp agent.
  • LanguageRules: language rules (es_ES, en_US, fr_FR, ...)
  • CaseSensitive: consider or ignore the case sensitive looking up the items with the ILookUp agent.
    + CASE_SENSITIVE: discriminates between lower and upper cases.
    + CASE_INSENSITIVE: doesn't discriminate between lower and upper cases.

Default flag values are:

  • ItemsOrder: MAINTAIN_AGENT_POSITIONS.
  • ShowAllItemsInListBox: false (that's equal to ''SHOW_ONLY_MATCHES'').
  • LanguageRules: en_EN (English from England).
  • CaseSensitive: true (that's equal to ''CASE_SENSITIVE'').

Version:
07/02/2008
Author:
Pablo Piqueras Bartolomé (pablo.piqueras@iver.es)
See Also:
  • Field Details

    • MAINTAIN_POSITION

      public static final int MAINTAIN_POSITION
      See Also:
    • ALPHABETICAL_ORDERED

      public static final int ALPHABETICAL_ORDERED
      See Also:
    • MAINTAIN_AGENT_POSITIONS

      public static final int MAINTAIN_AGENT_POSITIONS
      See Also:
    • SHOW_ALL_ITEMS

      public static final boolean SHOW_ALL_ITEMS
      See Also:
    • SHOW_ONLY_MATCHES

      public static final boolean SHOW_ONLY_MATCHES
      See Also:
    • CASE_SENSITIVE

      public static final boolean CASE_SENSITIVE
      See Also:
    • CASE_INSENSITIVE

      public static final boolean CASE_INSENSITIVE
      See Also:
    • DEFAULT_ITEMS_ORDER_CONFIGURATION

      public static final int DEFAULT_ITEMS_ORDER_CONFIGURATION
      See Also:
    • DEFAULT_SHOW_ALL_ITEMS_IN_LIST_BOX_CONFIGURATION

      public static final boolean DEFAULT_SHOW_ALL_ITEMS_IN_LIST_BOX_CONFIGURATION
      See Also:
    • DEFAULT_LANGUAGE_RULES_CONFIGURATION

      public static final String DEFAULT_LANGUAGE_RULES_CONFIGURATION
      See Also:
    • DEFAULT_CASE_SENSITIVE_CONFIGURATION

      public static final boolean DEFAULT_CASE_SENSITIVE_CONFIGURATION
      See Also:
  • Constructor Details

  • Method Details

    • addElement

      public void addElement(Object object)
      Specified by:
      addElement in interface MutableComboBoxModel
      See Also:
    • removeElementAt

      public void removeElementAt(int index)
      Specified by:
      removeElementAt in interface MutableComboBoxModel
      See Also:
    • insertElementAt

      public void insertElementAt(Object object, int index)
      Specified by:
      insertElementAt in interface MutableComboBoxModel
      See Also:
    • removeElement

      public void removeElement(Object object)
      Specified by:
      removeElement in interface MutableComboBoxModel
      See Also:
    • removeAllElements

      public void removeAllElements()
      See Also:
    • getSize

      public int getSize()
      Specified by:
      getSize in interface ListModel
      See Also:
    • setSelectedItem

      public void setSelectedItem(Object anObject)
      Specified by:
      setSelectedItem in interface ComboBoxModel
      See Also:
    • getSelectedItem

      public Object getSelectedItem()
      Specified by:
      getSelectedItem in interface ComboBoxModel
      See Also:
    • getElementAt

      public Object getElementAt(int index)
      Specified by:
      getElementAt in interface ListModel
      See Also:
    • getIndexOf

      public int getIndexOf(Object object)
      See Also:
    • getItemsOrder

      public int getItemsOrder()

      Returns the 'itemsOrder' configuration value of this component. Configuration values are:

      • MAINTAIN_POSITION: all items will be shown in the order programmer did.
      • ALPHABETICAL_ORDERED: all items will be shown in alphabetical order.
      • MAINTAIN_AGENT_POSITIONS: all items will be shown in the order the look up agent did.

      Returns:
      'itemsOrder' configuration
    • setItemsOrder

      public void setItemsOrder(int itemsOrder)

      Sets the 'itemsOrder' configuration value for this component. Configuration values are:

      • MAINTAIN_POSITION: all items will be shown in the order programmer did.
      • ALPHABETICAL_ORDERED: all items will be shown in alphabetical order.
      • MAINTAIN_AGENT_POSITIONS: all items will be shown in the order the look up agent did.

      Parameters:
      An - integer value for 'itemsOrder' configuration flag
    • isShowAllItemsInListBox

      public boolean isShowAllItemsInListBox()

      Returns the 'showAllItemsInListBox' configuration value of this component. Configuration values are:

      • SHOW_ALL_ITEMS: shows all items in the list box.
      • SHOW_ONLY_MATCHES: shows only the items that match with the text written according the ILookUp agent.

      Returns:
      'showAllItemsInListBox' configuration
    • setShowAllItemsInListBox

      public void setShowAllItemsInListBox(boolean itemsShownInListBox)

      Sets the 'showAllItemsInListBox' configuration value for this component. Configuration values are:

      • SHOW_ALL_ITEMS: shows all items in the list box.
      • SHOW_ONLY_MATCHES: shows only the items that match with the text written according the ILookUp agent.

      Parameters:
      A - boolean value for 'showAllItemsInListBox' configuration flag
    • getLocaleRules

      public String getLocaleRules()

      Returns the 'localeRules' configuration value of this component. The language code values could be consulted at:
      http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
      http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html

      Returns:
      'localeRules' configuration
    • setLocaleRules

      public void setLocaleRules(String localeRules)

      Sets the 'localeRules' configuration value for this component. Configuration values are:
      http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
      http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html

      Parameters:
      An - String value for 'localeRules' configuration flag
    • isCaseSensitive

      public boolean isCaseSensitive()

      Returns the 'caseSensitive' configuration value of this component. Configuration values are:

      • CASE_SENSITIVE: discriminates between small letters and capital letters.
      • CASE_INSENSITIVE: doesn't discriminates between small letters and capital letters.

      Returns:
      'caseSensitive' configuration
    • setCaseSensitive

      public void setCaseSensitive(boolean caseSensitive)

      Sets the 'caseSensitive' configuration value for this component. Configuration values are:

      • CASE_SENSITIVE: discriminates between small letters and capital letters.
      • CASE_INSENSITIVE: doesn't discriminates between small letters and capital letters.

      Parameters:
      A - boolean value for 'caseSensitive' configuration flag
    • initialize

      protected void initialize()

      Initializes some attributes.

    • setDefaultBehaviorFlagsConfiguration

      protected void setDefaultBehaviorFlagsConfiguration()

      Sets the default values of the flags.

    • getData

      public Vector<Object> getData()

      Returns all elements stored in this model, according the order they were added.

      Returns:
      data stored in this model.
    • getDataAccordingItemsOrder

      public Vector<Object> getDataAccordingItemsOrder()

      Gets the data stored in this model according the criterion of the itemsOrder parameter.

      Always returns all items stored.

      Returns:
      data stored in this model according the criterion of the itemsOrder parameter
    • updateVisibleList

      protected void updateVisibleList()

      Updates the list with the results of the look up by the agent, and its configuration.

    • lookUp

      protected List<Object> lookUp()

      Invokes the agent to execute its search on all items alphabetically sort ordered, considering the text written and the case sensitive configuration. The agent will use a

      Comparator

      that includes the locale language rules and the case sensitive in the rule that uses to compare.

      .
      Returns:
      java.util.List
    • getLookUpAgent

      public ILookUp getLookUpAgent()

      Gets the agent used with the logic for looking up the items of this model, considering the text written.

      Returns:
      the agent used with the logic for looking up the items of this model
    • setLookUpAgent

      public void setLookUpAgent(ILookUp agent)

      Sets the agent with the logic for looking up the items of this model, considering the text written.

      Parameters:
      agent - the agent used with the logic for looking up the items of this model
    • setEventNotificationEnabled

      public void setEventNotificationEnabled(boolean b)

      Sets enabled or disabled the notification of events in this model.

      Parameters:
      b - true to enable, false to disable
    • getEventNotificationEnabled

      public boolean getEventNotificationEnabled()

      Gets if the notification of events in this model is enabled.

      Returns:
      true is its enabled; false otherwise
    • setTextWritten

      public void setTextWritten(String text)
      Description copied from interface: IComboBoxLookUp

      Sets the text for search items.

      Specified by:
      setTextWritten in interface IComboBoxLookUp