QJCC homepage

biz.chitec.quarterback.swing
Class TableHeaderConfigurationModel

java.lang.Object
  extended bybiz.chitec.quarterback.swing.TableHeaderConfigurationModel

public class TableHeaderConfigurationModel
extends java.lang.Object

Generalized table header configuration Stores all possible table columns and configurations of which columns should be shown. Allows to create new configurations and to change them. Manages all the configurations. The model manages several table header lists: One is the so-called current configuration which is the one actually used by the JTable. the other ones are named and stored seperately. They can be selected as current one by simple click. TableHeaderConfigurationModel supports persistance in an explicit way: Via getConfiguration and putConfiguration the complete configuration can be stored and read into and from a String. The stored information is independent from the actual set of possible headers. So, if programmatically new headers are added to the list (or some are removed), the stored persistance state will be evaluated in a sensible way, anyway. TableHeaderConfigurationModel communicates via PropertyChangeEvents with its environment. It does not feature any user interface. Normally, it is used in conjunction with a TableHeaderConfigurator instance.

Version:
$Id: c82ba8875ea00d8368a761482f11ef4b553b8bf6 $
Author:
Dirk Hillbrecht 2005
See Also:
TableHeaderConfigurator

Field Summary
private  java.lang.String[] allheaders
           
private  java.util.List configurations
           
private  java.util.List currentconfig
           
private  java.lang.String[] currentconfigasarray
           
private  java.util.Map currentlockedwidth
           
private  java.lang.String[] lastfiredconfig
           
private  java.util.Map lastfiredlockedwidth
           
private  java.beans.PropertyChangeSupport pcs
           
 
Constructor Summary
TableHeaderConfigurationModel(java.lang.String[] allheadersx)
          Initialize model with complete header list.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener.
 void addPropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener listener)
          Add a property change listener for a certain property.
protected  void fireCurrentConfiguration()
          fires a change event in case the current configuration changes
protected  void fireCurrentLockedWidth()
          fires a change event in case the current locked width changes
 java.lang.String[] getAllHeaders()
          Returns the complete header list as it has been passed during initialization
 java.lang.String getConfiguration()
          Create textual representation of complete inner state in a way feasible for object persistance
 java.util.Set getCurrentConfigAsSet()
          Returns the current configuration as Set
 java.lang.String[] getCurrentConfiguration()
          Returns the current configuration as array of Strings
 java.util.Map getCurrentLockedWidth()
          Returns the current configuration as array of Strings
private  java.lang.StringBuffer listToString(java.util.Collection config, java.util.Map cache, java.lang.StringBuffer sb)
          Creates textual representation of one header configuration.
private  java.lang.StringBuffer mapToString(java.util.Map config, java.util.Map cache, java.lang.StringBuffer sb)
          Creates textual representation of one header configuration.
 void moveCurrentColumn(int sourcecolumn, int targetcolumn)
          Moves one column in the current configuration from one position to another
 void putConfiguration(java.lang.String s)
          Create inner state from a persistance storage.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a property change listener.
 void removePropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener listener)
          Remove a property change listener for a certain property.
 void setInCurrentConfig(java.lang.String columnname, boolean selected)
          Adds or removes one column to or from the current configuration.
 void setInCurrentLockedWidth(java.lang.String columnname, int width)
           
private  java.util.List stringToList(java.util.StringTokenizer str, java.util.Map cache, java.util.Set allheaderset)
          Recreates one header configuration from persistance storage string
private  java.util.Map stringToMap(java.util.StringTokenizer str, java.util.Map cache, java.util.Set allheaderset)
          Recreates one header configuration from persistance storage string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allheaders

private java.lang.String[] allheaders

lastfiredconfig

private java.lang.String[] lastfiredconfig

lastfiredlockedwidth

private java.util.Map lastfiredlockedwidth

currentconfigasarray

private java.lang.String[] currentconfigasarray

currentconfig

private java.util.List currentconfig

currentlockedwidth

private java.util.Map currentlockedwidth

configurations

private java.util.List configurations

pcs

private java.beans.PropertyChangeSupport pcs
Constructor Detail

TableHeaderConfigurationModel

public TableHeaderConfigurationModel(java.lang.String[] allheadersx)
Initialize model with complete header list.

Parameters:
allheadersx - String array containing all headers with can possibly be shown.
Method Detail

listToString

private java.lang.StringBuffer listToString(java.util.Collection config,
                                            java.util.Map cache,
                                            java.lang.StringBuffer sb)
Creates textual representation of one header configuration.


mapToString

private java.lang.StringBuffer mapToString(java.util.Map config,
                                           java.util.Map cache,
                                           java.lang.StringBuffer sb)
Creates textual representation of one header configuration.


getConfiguration

public java.lang.String getConfiguration()
Create textual representation of complete inner state in a way feasible for object persistance


stringToList

private java.util.List stringToList(java.util.StringTokenizer str,
                                    java.util.Map cache,
                                    java.util.Set allheaderset)
Recreates one header configuration from persistance storage string


stringToMap

private java.util.Map stringToMap(java.util.StringTokenizer str,
                                  java.util.Map cache,
                                  java.util.Set allheaderset)
Recreates one header configuration from persistance storage string


putConfiguration

public void putConfiguration(java.lang.String s)
Create inner state from a persistance storage.

Parameters:
s - String containing the inner state, normally created via getConfiguration()

moveCurrentColumn

public void moveCurrentColumn(int sourcecolumn,
                              int targetcolumn)
Moves one column in the current configuration from one position to another

Parameters:
sourcecolumn -
targetcolumn -

setInCurrentConfig

public void setInCurrentConfig(java.lang.String columnname,
                               boolean selected)
Adds or removes one column to or from the current configuration. If a column is added, its position is determined with regard to the complete header list. It is always placed directly behind the rightmost already visible column before it in allheaders. Addition of an already visible or removement of an already invisible column does not perform any anction. It is not possible to remove the last visible column name from the list.

Parameters:
columnname - Name of the column to add or remove
selected - Flag to indicate addition or removal

setInCurrentLockedWidth

public void setInCurrentLockedWidth(java.lang.String columnname,
                                    int width)

getAllHeaders

public java.lang.String[] getAllHeaders()
Returns the complete header list as it has been passed during initialization


getCurrentConfiguration

public java.lang.String[] getCurrentConfiguration()
Returns the current configuration as array of Strings


getCurrentLockedWidth

public java.util.Map getCurrentLockedWidth()
Returns the current configuration as array of Strings


getCurrentConfigAsSet

public java.util.Set getCurrentConfigAsSet()
Returns the current configuration as Set


fireCurrentConfiguration

protected void fireCurrentConfiguration()
fires a change event in case the current configuration changes


fireCurrentLockedWidth

protected void fireCurrentLockedWidth()
fires a change event in case the current locked width changes


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.


addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String prop,
                                      java.beans.PropertyChangeListener listener)
Add a property change listener for a certain property.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener.


removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String prop,
                                         java.beans.PropertyChangeListener listener)
Remove a property change listener for a certain property.


QJCC homepage