|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.AbstractListModel
com.ccg.values.ValuesConfigModel
public class ValuesConfigModel
A standard ComboBoxModel which is associated with a set
of configurations for a particular ValuesConfig class.
This method makes it easy to create and maintain Swing list and combobox models which reflect a set of available configurations. It works in the following manner:
ValuesConfig implementation which it is associated with.
_MyModel = new ValuesConfigModel();
_MyModel.setValuesConfigClass(MailerConfig.class);
JList _MyList = new JList(_MyModel);
JComboBox _MyComboBox = new JComboBox(_MyModel);
Object selected = _MyModel.getSelectedItem();
if (selected != null) {
ValuesConfig vc = _MyModel.createValuesConfig();
vc.load(selected.toString());
vc.toObject(_MyMailer);
}
reload method.
| Field Summary |
|---|
| Fields inherited from class javax.swing.AbstractListModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
ValuesConfigModel()
|
|
| Method Summary | |
|---|---|
ValuesConfig |
createValuesConfig()
Create a new ValuesConfig object of the appropriate
type. |
Object |
getElementAt(int i)
Get the name of a particular configuration. |
Object |
getSelectedItem()
Get the selected item. |
int |
getSize()
Get number of configurations which are available. |
Class |
getValuesConfigClass()
Get the ValuesConfig class which this
list model will support. |
void |
reload()
Reloads set of available configurations. |
void |
setSelectedItem(Object val)
Set the selected item. |
void |
setValuesConfigClass(Class val)
Set the ValuesConfig class which this
list model will support. |
| Methods inherited from class javax.swing.AbstractListModel |
|---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.swing.ListModel |
|---|
addListDataListener, removeListDataListener |
| Constructor Detail |
|---|
public ValuesConfigModel()
| Method Detail |
|---|
public void setValuesConfigClass(Class val)
ValuesConfig class which this
list model will support.
When you invoke this method, you will reload the data in the list model
(possibly notifying those monitoring the model). NOTE: This only works if
your ValuesConfig has a public default constructor
(as we use the newInstance() method from the
class you pass to create these objects as we need them.
val - Class description of the ValuesConfig object to associate with
the list model (must not be null).getValuesConfigClass()public Class getValuesConfigClass()
ValuesConfig class which this
list model will support.
setValuesConfigClass(java.lang.Class)public void reload()
This method fetches the list of all available configurations and then reloads the internal list model to match. NOTE: Do not invoke until you've set a non-null ValuesConfig object.
public int getSize()
getSize in interface ListModelpublic Object getElementAt(int i)
getElementAt in interface ListModelidx - Index to retrieve name of config (in range of [0,getSize()-1].
public ValuesConfig createValuesConfig()
ValuesConfig object of the appropriate
type.
This method creates a new ValuesConfig object of the
appropriate type. You can only use this method AFTER you've
setValuesConfigClass(java.lang.Class) specified the appropriate class associated
with the list model.
IllegalStateException - If model hasn't been initialized with a proper ValuesConfig class.public void setSelectedItem(Object val)
setSelectedItem in interface ComboBoxModelval - New Object value to assign.getSelectedItem()public Object getSelectedItem()
getSelectedItem in interface ComboBoxModelsetSelectedItem(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||