QJCC homepage

biz.chitec.quarterback.swing
Class MapListModelHelper

java.lang.Object
  extended bybiz.chitec.quarterback.swing.MapListModelHelper
All Implemented Interfaces:
DefaultLocaleChangeReceiver

public class MapListModelHelper
extends java.lang.Object
implements DefaultLocaleChangeReceiver

Common helper class for Table and TreeTable models of List of Maps. The helper knows about title conversion, being given columns from outside, and how to collect columns from given Maps. There is, however no real storage for the data and none of the usual access methods for each of the models. This class is therefore not derived from the models themselves.

Version:
$Id: 696a055f54410819a4eb62be12475e6269137a64 $
Author:
chitec/Dirk Hillbrecht 2002. Distributed under the terms of the GNU LGPL.
See Also:
MapListTableModel

Field Summary
private static java.lang.Object CCDUMMY
           
private  java.util.List colclasses
           
private  boolean colclassincomplete
           
private  int colcount
           
private  java.util.List coledit
           
private  java.util.List coleditorname
           
private  java.util.List colentries
           
private  java.util.List colname
           
private  java.util.List colrenderername
           
private  java.util.List colsortreplaces
           
private  boolean evaluatecolonset
           
private  java.util.ResourceBundle rb
           
private  java.lang.String rbprefix
           
private  boolean structurechanged
           
 
Constructor Summary
MapListModelHelper()
          Standard empty constructor.
MapListModelHelper(java.util.ResourceBundle rbx)
          Constructor passing a ResourceBundle.
MapListModelHelper(java.util.ResourceBundle rbx, java.lang.String[] hdr)
          Constructor with a ResourceBundle and the column titles.
MapListModelHelper(java.util.ResourceBundle rbx, java.lang.String prefix, java.lang.String[] hdr)
          Constructor with a ResourceBundle, a prefix and the column titles.
MapListModelHelper(java.lang.String[] hdr)
          Constructor with column titles setting.
 
Method Summary
private  void appendNewKey(java.lang.Object thiskey, java.lang.Object defaultclass)
          Appends new column data.
private  void checkCCIncompl()
          Checks whether all column object classes are known or not.
 void clearHeader()
          Clears the header completely.
 void defaultLocaleChanged()
          Called if any locale changes.
private  void evalRB(boolean full)
           
private  java.lang.Object getColclassWithRB(java.lang.Object okey, java.lang.Object defaultobj)
          Get column class.
private  java.lang.Boolean getColeditWithRB(java.lang.Object okey)
          Get the editability.
private  java.lang.String getColnameWithRB(java.lang.Object okey)
          Get column name (= header).
private  java.lang.String getColRendererOrEditorWithRB(java.lang.Object okey, boolean editor)
          Returns class name for cell renderer or cell editor for a certain column key from the resources.
private  java.lang.String getColsortreplaceWithRB(java.lang.Object okey)
          Get sorting key for column.
 java.lang.Class getColumnClass(int column)
          Return column class.
 int getColumnCount()
          Return number of columns known to the model helper
 java.lang.String getColumnEditorClassName(int column)
          Returns the column editor class for a certain column.
 int getColumnIndex(java.lang.String name)
          Return index of column with given name.
 int getColumnIndexBySortReplace(java.lang.String sortkey)
          Get a column index by the sortreplace key value.
 java.lang.String getColumnKey(int index)
          Return key of colunm with given index.
 java.lang.String getColumnName(int column)
          Return symbolic name of a column
 java.lang.String getColumnRendererClassName(int column)
          Returns the column renderer class for a certain column.
 java.lang.String getColumnSortReplace(int column)
          Return column's sort replace value.
 java.lang.Object getColumnValue(java.util.Map m, int column)
          Return content of specific column for a Map
 java.util.ResourceBundle getResourceBundle()
          Returns the ResourceBundle used by the ModelHelper
 java.lang.String getResourcePrefix()
          Returns the keys' prefix used for all resources read from the ResourceBundle
 void handleNewMap(java.util.Map m)
          Works on new Maps as they arrive in the model.
 boolean isColumnEditable(int column)
          Return whether column is editable
 boolean isHeaderSet()
          Returns whether the header has been set.
 void resetStructureChange()
          Forget all structure changes
 boolean setColumnValue(java.lang.Object value, java.util.Map m, int column)
          Set content of specific column for a Map and return whether something has changed
 void setHeader(java.lang.Object[] hdr)
          Set header.
 void setResourceBundle(java.util.ResourceBundle rbx)
          Sets ResourceBundle from which column titles are acquired without changing the prefix.
 void setResourceBundle(java.util.ResourceBundle rbx, java.lang.String prefix)
          Sets ResourceBundle from which column titles are acquired.
 boolean structureChanged()
          Return if any structure changes occured.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CCDUMMY

private static java.lang.Object CCDUMMY

colcount

private int colcount

colclassincomplete

private boolean colclassincomplete

colentries

private java.util.List colentries

colname

private java.util.List colname

coledit

private java.util.List coledit

colclasses

private java.util.List colclasses

colsortreplaces

private java.util.List colsortreplaces

colrenderername

private java.util.List colrenderername

coleditorname

private java.util.List coleditorname

evaluatecolonset

private boolean evaluatecolonset

rb

private java.util.ResourceBundle rb

rbprefix

private java.lang.String rbprefix

structurechanged

private boolean structurechanged
Constructor Detail

MapListModelHelper

public MapListModelHelper()
Standard empty constructor. No data. No bundle. No titles.


MapListModelHelper

public MapListModelHelper(java.util.ResourceBundle rbx)
Constructor passing a ResourceBundle.


MapListModelHelper

public MapListModelHelper(java.lang.String[] hdr)
Constructor with column titles setting.


MapListModelHelper

public MapListModelHelper(java.util.ResourceBundle rbx,
                          java.lang.String[] hdr)
Constructor with a ResourceBundle and the column titles.


MapListModelHelper

public MapListModelHelper(java.util.ResourceBundle rbx,
                          java.lang.String prefix,
                          java.lang.String[] hdr)
Constructor with a ResourceBundle, a prefix and the column titles.

Method Detail

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle rbx,
                              java.lang.String prefix)
Sets ResourceBundle from which column titles are acquired.

Parameters:
rbx - The ResourceBundle to read column titles from
prefix - Prefix prepended to each Map key name

evalRB

private void evalRB(boolean full)

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle rbx)
Sets ResourceBundle from which column titles are acquired without changing the prefix.


getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Returns the ResourceBundle used by the ModelHelper


getResourcePrefix

public java.lang.String getResourcePrefix()
Returns the keys' prefix used for all resources read from the ResourceBundle


setHeader

public void setHeader(java.lang.Object[] hdr)
Set header. These headers are used to obtain the correct field from the map. For customized header representation on screen, use ResourceBundle.


clearHeader

public void clearHeader()
Clears the header completely.


isHeaderSet

public boolean isHeaderSet()
Returns whether the header has been set.


resetStructureChange

public void resetStructureChange()
Forget all structure changes


structureChanged

public boolean structureChanged()
Return if any structure changes occured.


handleNewMap

public void handleNewMap(java.util.Map m)
Works on new Maps as they arrive in the model. Every new content of the model should be passed to this method. It does two checks:


getColnameWithRB

private java.lang.String getColnameWithRB(java.lang.Object okey)
Get column name (= header). Either ResourceBundle content or String form of the Map key (which is the Property name, also).


getColclassWithRB

private java.lang.Object getColclassWithRB(java.lang.Object okey,
                                           java.lang.Object defaultobj)
Get column class. Searches for class through ResourceBundle. If no ResourceBundle is available or no data is given, it returns the passed default value.


getColeditWithRB

private java.lang.Boolean getColeditWithRB(java.lang.Object okey)
Get the editability. Columns can be made editable only by ResourceBundle. By default, nothing is editable. It is however possible to give an entry
<prefix><columnname>.edit=true

in the resource bundle to allow editing of this column.


getColsortreplaceWithRB

private java.lang.String getColsortreplaceWithRB(java.lang.Object okey)
Get sorting key for column. Returns which column should be taken for sorting if a certain column is selected. This can be useful if the selected column contains only an enhanced version of another (not shown) column that has the real value in it.


getColRendererOrEditorWithRB

private java.lang.String getColRendererOrEditorWithRB(java.lang.Object okey,
                                                      boolean editor)
Returns class name for cell renderer or cell editor for a certain column key from the resources. If no widgets class name has been put in the resources or any other problem occurs, null is returned.

Parameters:
okey - Key, i.e. map key name
editor - Flag whether the editor widget name or the renderer widget name should be returned
Returns:
Class name of editor or renderer widget.

appendNewKey

private void appendNewKey(java.lang.Object thiskey,
                          java.lang.Object defaultclass)
Appends new column data. The key is added to the colentries list, the name for the header is added to the names list and the class is added to the classes list.


checkCCIncompl

private void checkCCIncompl()
Checks whether all column object classes are known or not.


getColumnIndex

public int getColumnIndex(java.lang.String name)
Return index of column with given name.


getColumnKey

public java.lang.String getColumnKey(int index)
Return key of colunm with given index.


getColumnCount

public int getColumnCount()
Return number of columns known to the model helper


getColumnValue

public java.lang.Object getColumnValue(java.util.Map m,
                                       int column)
Return content of specific column for a Map


setColumnValue

public boolean setColumnValue(java.lang.Object value,
                              java.util.Map m,
                              int column)
Set content of specific column for a Map and return whether something has changed

Parameters:
value - New value to set
m - Map to operate on
column - numeric index of the column to change
Returns:
true if change operation really changed the value, false if not

getColumnName

public java.lang.String getColumnName(int column)
Return symbolic name of a column


getColumnClass

public java.lang.Class getColumnClass(int column)
Return column class. Object.class if unknown.


isColumnEditable

public boolean isColumnEditable(int column)
Return whether column is editable


getColumnSortReplace

public java.lang.String getColumnSortReplace(int column)
Return column's sort replace value.


getColumnRendererClassName

public java.lang.String getColumnRendererClassName(int column)
Returns the column renderer class for a certain column. If no explicit column renderer has been set for the column, null is returned.

Parameters:
column - Index of the column in question
Returns:
Name of the renderer class.

getColumnEditorClassName

public java.lang.String getColumnEditorClassName(int column)
Returns the column editor class for a certain column. If no explicit column editor has been set for the column, null is returned.

Parameters:
column - Index of the column in question
Returns:
Name of the editor class.

getColumnIndexBySortReplace

public int getColumnIndexBySortReplace(java.lang.String sortkey)
Get a column index by the sortreplace key value.


defaultLocaleChanged

public void defaultLocaleChanged()
Description copied from interface: DefaultLocaleChangeReceiver
Called if any locale changes.

Specified by:
defaultLocaleChanged in interface DefaultLocaleChangeReceiver

QJCC homepage