Class DefaultComboBoxConfigurableLookUpModel
- All Implemented Interfaces:
Serializable,ComboBoxModel,ListModel,MutableComboBoxModel,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
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
ILookUpagent.
+ 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 theILookUpagent. - LanguageRules: language rules (es_ES, en_US, fr_FR, ...)
- CaseSensitive: consider or ignore the case sensitive looking up the items with the
ILookUpagent.
+ 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassNew functionality to work with vectors (of elements). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final booleanstatic final booleanstatic final booleanstatic final intstatic final Stringstatic final booleanstatic final intstatic final intstatic final booleanstatic final booleanFields inherited from class javax.swing.AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElement(Object object) getData()Returns all elements stored in this model, according the order they were added.Gets the data stored in this model according the criterion of the itemsOrder parameter.getElementAt(int index) booleanGets if the notification of events in this model is enabled.intgetIndexOf(Object object) intReturns the 'itemsOrder' configuration value of this component.Returns the 'localeRules' configuration value of this component.Gets the agent used with the logic for looking up the items of this model, considering the text written.intgetSize()protected voidInitializes some attributes.voidinsertElementAt(Object object, int index) booleanReturns the 'caseSensitive' configuration value of this component.booleanReturns the 'showAllItemsInListBox' configuration value of this component.lookUp()Invokes the agent to execute its search on all items alphabetically sort ordered, considering the text written and the case sensitive configuration.voidvoidremoveElement(Object object) voidremoveElementAt(int index) voidsetCaseSensitive(boolean caseSensitive) Sets the 'caseSensitive' configuration value for this component.protected voidSets the default values of the flags.voidsetEventNotificationEnabled(boolean b) Sets enabled or disabled the notification of events in this model.voidsetItemsOrder(int itemsOrder) Sets the 'itemsOrder' configuration value for this component.voidsetLocaleRules(String localeRules) Sets the 'localeRules' configuration value for this component.voidsetLookUpAgent(ILookUp agent) Sets the agent with the logic for looking up the items of this model, considering the text written.voidsetSelectedItem(Object anObject) voidsetShowAllItemsInListBox(boolean itemsShownInListBox) Sets the 'showAllItemsInListBox' configuration value for this component.voidsetTextWritten(String text) Sets the text for search items.protected voidUpdates the list with the results of the look up by the agent, and its configuration.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
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
- See Also:
-
DEFAULT_CASE_SENSITIVE_CONFIGURATION
public static final boolean DEFAULT_CASE_SENSITIVE_CONFIGURATION- See Also:
-
-
Constructor Details
-
DefaultComboBoxConfigurableLookUpModel
public DefaultComboBoxConfigurableLookUpModel()- See Also:
-
DefaultComboBoxConfigurableLookUpModel
- See Also:
-
DefaultComboBoxConfigurableLookUpModel
- See Also:
-
-
Method Details
-
addElement
- Specified by:
addElementin interfaceMutableComboBoxModel- See Also:
-
removeElementAt
public void removeElementAt(int index) - Specified by:
removeElementAtin interfaceMutableComboBoxModel- See Also:
-
insertElementAt
- Specified by:
insertElementAtin interfaceMutableComboBoxModel- See Also:
-
removeElement
- Specified by:
removeElementin interfaceMutableComboBoxModel- See Also:
-
removeAllElements
public void removeAllElements()- See Also:
-
getSize
public int getSize() -
setSelectedItem
- Specified by:
setSelectedItemin interfaceComboBoxModel- See Also:
-
getSelectedItem
- Specified by:
getSelectedItemin interfaceComboBoxModel- See Also:
-
getElementAt
- Specified by:
getElementAtin interfaceListModel- See Also:
-
getIndexOf
- 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
ILookUpagent.
- 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
ILookUpagent.
- Parameters:
A- boolean value for 'showAllItemsInListBox' configuration flag
-
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
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
Returns all elements stored in this model, according the order they were added.
- Returns:
- data stored in this model.
-
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
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
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
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-trueto enable,falseto disable
-
getEventNotificationEnabled
public boolean getEventNotificationEnabled()Gets if the notification of events in this model is enabled.
- Returns:
trueis its enabled;falseotherwise
-
setTextWritten
Description copied from interface:IComboBoxLookUpSets the text for search items.
- Specified by:
setTextWrittenin interfaceIComboBoxLookUp
-