com.sas.swing.models
Class MapToListModelAdapter

com.sas.swing.models.MapToListModelAdapter
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, java.io.Serializable, javax.swing.ListModel
Direct Known Subclasses:
MapToComboBoxModelAdapter

public class MapToListModelAdapter
implements com.sas.beans.PropertyChangeSource

The MapToListModelAdapter allows Maps that implement java.util.Map to be used as the model for a javax.swing.JList. The Map must be set as the model for the adapter, which can then used as the model for the viewer.

By default, all entries will be displayed. In order to show only the keys, you must set showKeysOnly to true.

See Also:
Serialized Form

Field Summary
protected  java.util.List delegate
          Internal storage of data from Map
protected  java.util.Map model
          Model for the adapter
protected  boolean showKeysOnly
          Display mode for the adapter
protected  javax.swing.event.SwingPropertyChangeSupport spcs
          Used to support property changes in the webAF customizer
 
Constructor Summary
MapToListModelAdapter()
          Default constructor
MapToListModelAdapter(int size)
          Overloaded constructor that initializes the delegate to be of given size
MapToListModelAdapter(java.util.Map m)
          Overloaded constructor that intializes the adapter with the entire entrySet given by the Map
MapToListModelAdapter(java.util.Map m, boolean showKeysOnly)
          Overloaded constructor that intializes the adapter with the data given by the Map and whether to display only the keys of the map or all entries
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
protected  void createDelegate()
          Create the delegate object
 java.lang.Object getElementAt(int i)
          Returns the value at the specified index.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 java.util.Map getModel()
          Returns the model of the adapter
 boolean getShowKeysOnly()
          Returns whether only the keys of the map are displayed
 int getSize()
          Returns the length of the list.
 void refresh()
          Force a refresh on the adapter
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setModel(java.util.Map model)
          Sets the model of the adapter to the given Map
 void setShowKeysOnly(boolean showKeysOnly)
          Sets the display mode of the adapter to either all entries when false or keys only when true
 

Field Detail

delegate

protected java.util.List delegate
Internal storage of data from Map


model

protected java.util.Map model
Model for the adapter


showKeysOnly

protected boolean showKeysOnly
Display mode for the adapter


spcs

protected javax.swing.event.SwingPropertyChangeSupport spcs
Used to support property changes in the webAF customizer

Constructor Detail

MapToListModelAdapter

public MapToListModelAdapter()
Default constructor


MapToListModelAdapter

public MapToListModelAdapter(int size)
Overloaded constructor that initializes the delegate to be of given size

Parameters:
size - Initial size of the delegate representing the Map

MapToListModelAdapter

public MapToListModelAdapter(java.util.Map m)
Overloaded constructor that intializes the adapter with the entire entrySet given by the Map

Parameters:
m - Map whose data will be used within the adapter

MapToListModelAdapter

public MapToListModelAdapter(java.util.Map m,
                             boolean showKeysOnly)
Overloaded constructor that intializes the adapter with the data given by the Map and whether to display only the keys of the map or all entries

Parameters:
m - Map whose data will be used within the adapter
showKeysOnly - display all entries when false or keys only when true
Method Detail

getSize

public int getSize()
Returns the length of the list.

Specified by:
getSize in interface javax.swing.ListModel

getElementAt

public java.lang.Object getElementAt(int i)
Returns the value at the specified index.

Specified by:
getElementAt in interface javax.swing.ListModel

setModel

public void setModel(java.util.Map model)
Sets the model of the adapter to the given Map

Parameters:
model - Map whose data will be used within the adapter

getModel

public java.util.Map getModel()
Returns the model of the adapter


setShowKeysOnly

public void setShowKeysOnly(boolean showKeysOnly)
Sets the display mode of the adapter to either all entries when false or keys only when true


getShowKeysOnly

public boolean getShowKeysOnly()
Returns whether only the keys of the map are displayed


createDelegate

protected void createDelegate()
Create the delegate object


refresh

public void refresh()
Force a refresh on the adapter


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface com.sas.beans.PropertyChangeSource

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface com.sas.beans.PropertyChangeSource

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.