net.sf.jguiraffe.gui.platform.swing.builder.components
Class SwingListModelHandler

java.lang.Object
  extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComponentHandler
      extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingListModelHandler
All Implemented Interfaces:
ListComponentHandler, ComponentHandler, SwingEventSource
Direct Known Subclasses:
SwingComboBoxHandler, SwingListBoxHandler

abstract class SwingListModelHandler
extends SwingComponentHandler
implements ListComponentHandler

An abstract base class for Swing component handlers that deal with list models.

This class provides basic functionality for managing a list model. It will act as the base class for specific handler implementations that wrap Swing list-like components like JList or JComboBox.

Version:
$Id: SwingListModelHandler.java 71 2007-06-16 20:47:48Z oheger $
Author:
Oliver Heger

Constructor Summary
protected SwingListModelHandler(javax.swing.JComponent component, ListModel listModel)
          Creates a new instance of SwingListModelHandler and sets the managed component and the original list model.
 
Method Summary
 void addItem(int index, java.lang.Object display, java.lang.Object value)
          Adds an item to the list model of this component.
protected  SwingListModel createSwingListModel(ListModel m)
          Creates the Swing specific list model from the given source model.
 ListModel getListModel()
          Returns the list model for this component.
 java.lang.Class getType()
          Returns this component's data type.
protected abstract  void initComponentModel(SwingListModel model)
          Initializes the list model for the managed component.
 void removeItem(int index)
          Removes the item with the given index from the list model of this component.
 
Methods inherited from class net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComponentHandler
addActionListener, addChangeListener, addFocusListener, fireChangeEvent, getComponent, getJComponent, getOuterComponent, isEnabled, registerChangeListener, removeActionListener, removeChangeListener, removeFocusListener, setEnabled, unregisterChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jguiraffe.gui.forms.ComponentHandler
getComponent, getData, getOuterComponent, isEnabled, setData, setEnabled
 

Constructor Detail

SwingListModelHandler

protected SwingListModelHandler(javax.swing.JComponent component,
                                ListModel listModel)
Creates a new instance of SwingListModelHandler and sets the managed component and the original list model.

Parameters:
component - the component to manage
listModel - the original list model; this class will copy this list model's data into a new list model that can also be used by Swing components
Method Detail

getListModel

public ListModel getListModel()
Returns the list model for this component.

Specified by:
getListModel in interface ListComponentHandler
Returns:
the list model

addItem

public void addItem(int index,
                    java.lang.Object display,
                    java.lang.Object value)
Adds an item to the list model of this component.

Specified by:
addItem in interface ListComponentHandler
Parameters:
index - the index of the new item
display - the display object
value - the value object

removeItem

public void removeItem(int index)
Removes the item with the given index from the list model of this component.

Specified by:
removeItem in interface ListComponentHandler
Parameters:
index - the index

getType

public java.lang.Class getType()
Returns this component's data type. This type is directly derived from the list model.

Specified by:
getType in interface ComponentHandler
Returns:
the data type of this component

createSwingListModel

protected SwingListModel createSwingListModel(ListModel m)
Creates the Swing specific list model from the given source model.

Parameters:
m - the original list model
Returns:
the new Swing specific list model

initComponentModel

protected abstract void initComponentModel(SwingListModel model)
Initializes the list model for the managed component. This method is called after the Swing specific list model has been created. Derived classes should initialize the managed component with this model.

Parameters:
model - the Swing list model


Copyright 2007 null. All Rights Reserved.