001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.comp;
015:
016: import org.itsnat.comp.ui.ItsNatComboBoxUI;
017: import java.awt.ItemSelectable;
018: import java.awt.event.ItemListener;
019: import javax.swing.ComboBoxModel;
020:
021: /**
022: * Is the base interface of combo box components.
023: *
024: * <p>Items of combo boxes are not editable "in place", for instance a call
025: * to {@link #setItsNatListCellEditor(ItsNatListCellEditor)} throws an
026: * {@link org.itsnat.core.ItsNatException}.
027: * </p>
028: *
029: * <p>By default this component type uses a <code>javax.swing.DefaultComboBoxModel</code>
030: * data model.</p>
031: *
032: * <p>When the selection item changes the component notifies to all
033: * <code>java.awt.event.ItemListener</code> listeners registered (this component
034: * implements <code>java.awt.ItemSelectable</code>).</p>
035: *
036: * @author Jose Maria Arranz Santamaria
037: */
038: public interface ItsNatComboBox extends ItsNatList, ItemSelectable {
039: /**
040: * Returns the current data model of this component.
041: *
042: * @return the current data model
043: * @see #setComboBoxModel(javax.swing.ComboBoxModel)
044: */
045: public ComboBoxModel getComboBoxModel();
046:
047: /**
048: * Changes the data model of this component.
049: *
050: * @param dataModel the new data model.
051: * @see #getComboBoxModel()
052: * @see #setListModel(javax.swing.ListModel)
053: */
054: public void setComboBoxModel(ComboBoxModel dataModel);
055:
056: /**
057: * Adds a new value to the list model.
058: *
059: * <p>This method only works if the data model is a
060: * <code>javax.swing.MutableComboBoxModel</code>.</p>
061: *
062: * @param anObject the value to add at the end of the list.
063: */
064: public void addElement(Object anObject);
065:
066: /**
067: * Inserts a new value in the list model at the specified position.
068: *
069: * <p>This method only works if the data model is a
070: * <code>javax.swing.MutableComboBoxModel</code>.</p>
071: *
072: * @param index index of the new list item.
073: * @param anObject the value to add at the end of the list.
074: */
075: public void insertElementAt(int index, Object anObject);
076:
077: /**
078: * Removes the specified value from the list model.
079: *
080: * <p>This method only works if the data model is a
081: * <code>javax.swing.MutableComboBoxModel</code>.</p>
082: *
083: * @param anObject the value to remove.
084: */
085: public void removeElement(Object anObject);
086:
087: /**
088: * Removes a list item at the specified index.
089: *
090: * <p>This method only works if the data model is a
091: * <code>javax.swing.MutableComboBoxModel</code>.</p>
092: *
093: * @param index index of the item to remove.
094: */
095: public void removeElementAt(int index);
096:
097: /**
098: * Removes all items.
099: *
100: * <p>This method only works if the data model is a
101: * <code>javax.swing.MutableComboBoxModel</code>.</p>
102: */
103: public void removeAllElements();
104:
105: /**
106: * Returns the current selected item.
107: *
108: * <p>This method delegates to <code>ComboBoxModel.getSelectedItem()</code>.</p>
109: *
110: * @return the current selected item or null if none is selected.
111: */
112: public Object getSelectedItem();
113:
114: /**
115: * Sets the current selected item.
116: *
117: * <p>This method delegates to <code>ComboBoxModel.setSelectedItem(Object)</code>.</p>
118: *
119: * @param anObject the item value to select.
120: */
121: public void setSelectedItem(Object anObject);
122:
123: /**
124: * Returns the user interface manager of this component.
125: *
126: * @return the user interface manager.
127: */
128: public ItsNatComboBoxUI getItsNatComboBoxUI();
129:
130: /**
131: * Returns all <code>ItemListener</code> objects registered.
132: *
133: * @return an array with the registered listeners.
134: */
135: public ItemListener[] getItemListeners();
136: }
|