JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.higrid
Class HiGridData

java.lang.Object
  |
  +--com.klg.jclass.higrid.HiGridData
All Implemented Interfaces:
DataModel, Serializable

public class HiGridData
extends Object
implements DataModel, Serializable

HiGridData includes support for the footer, before details, and after details records.

See Also:
Serialized Form

Field Summary
static int AFTER_DETAILS
           
static int BEFORE_DETAILS
           
protected  com.klg.jclass.datasource.DataModel dataModel
           
static int FOOTER
           
static int SUMMARY_ROWS
           
 
Constructor Summary
protected HiGridData()
          Constructors.
  HiGridData(com.klg.jclass.datasource.DataModel dataModel)
           
 
Method Summary
 void addDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
          Register a listener for this Data Model.
 void cancelAll(com.klg.jclass.datasource.DataModelListener originator)
          Cancel all pending changes in all DataTables.
 void clearCurrentPath(com.klg.jclass.datasource.MetaDataModel parentMeta)
          Clear the current path of all children of this MetaDataModel.
 void clearDataTableTreeInternalData(Object user)
          For internal use only.
 void clearDataTableTreeUserData(Object user)
          Clears all user data.
protected  void createAfterDetailsMetaTree()
          Create the after details meta tree with the same hierarchy as the meta tree for the record type.
protected  void createBeforeDetailsMetaTree()
          Create the before details meta tree with the same hierarchy as the meta tree for the record type.
protected  void createFooterMetaTree()
          Create the footer meta tree with the same hierarchy as the meta tree for the record type.
protected  void createSummaryDataTable(com.klg.jclass.higrid.HiGrid grid, com.klg.jclass.datasource.DataTableModel recordData, com.klg.jclass.higrid.FormatNode node)
          Create the summary data table for the given data table model.
protected  com.klg.jclass.datasource.MetaDataModel createSummaryMetaData(int summary, int metaID)
          Create a new summary meta data object.
protected  void createSummaryMetaTree()
          Create the summary meta trees with the same hierarchy as the meta tree for the record type.
protected  com.klg.jclass.datasource.DataSourceTreeModel createSummaryMetaTree(com.klg.jclass.datasource.DataSourceTreeModel summaryTree, int summary)
          Create a summary meta tree with the same hierarchy as the meta tree for the record type.
protected  void createSummaryMetaTreeFromNode(com.klg.jclass.datasource.DataSourceTreeModel summaryTree, com.klg.jclass.datasource.MetaDataModel rootMetaData, com.klg.jclass.datasource.MetaDataModel rootSummary, int summary)
          Recursive helper routine to create the summary meta tree.
 void enableDataModelEvents(boolean value)
          Enable or disable data model events.
 boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event)
          Pass event on to listeners of this DataModel.
 boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event, com.klg.jclass.datasource.DataModelListener listener)
          Pass event on to listeners of this DataModel.
 TreeModel getAfterDetailsMetaTree()
          Retrieves the after details meta tree.
 TreeModel getBeforeDetailsMetaTree()
          Retrieves the before details meta tree.
 Object getCurrentDataItem(com.klg.jclass.datasource.DataModelListener originator, com.klg.jclass.datasource.MetaDataModel myLevel, String column)
          Returns the data item at the specified MetaData level and column for the current row.
 com.klg.jclass.datasource.DataTableModel getCurrentDataTable(com.klg.jclass.datasource.DataModelListener originator, com.klg.jclass.datasource.MetaDataModel myLevel)
          Returns the DataTable at the specified MetaData level based on the current bookmark.
 long getCurrentGlobalBookmark()
          Return the bookmark of the row which has the global cursor's focus.
 com.klg.jclass.datasource.DataTableModel getCurrentGlobalTable()
          Return the DataTableModel currently in focus.
 TreeModel getDataTableTree()
          Return a handle to the DataTree.
 boolean getEventsEnabled()
          Return true if events are enabled, false otherwise.
 TreeModel getFooterMetaTree()
          Retrieves the footer meta tree.
 Object getListeners()
          Return a list of listeners on this DataModel.
 com.klg.jclass.datasource.MetaDataModel getMetaData(String metaDataName)
          Get a MetaDataModel instance by name, or null if not found.
 TreeModel getMetaDataTree()
          Return a handle to the MetaTree.
 String getModelName()
          Get this model's name.
 boolean isModified()
          Are there any pending modifications in any rows in this entire data model?
 boolean moveToRow(com.klg.jclass.datasource.DataModelListener originator, com.klg.jclass.datasource.DataTableModel data_table, long bookmark)
          Called by observers to tell this data model to which row it should move.
 boolean moveToRow(com.klg.jclass.datasource.DataModelListener originator, com.klg.jclass.datasource.DataTableModel data_table, long bookmark, boolean moveIdeCursor)
          For internal use only.
 void removeDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
          Remove a listener of this Data Model.
 void requeryAll(com.klg.jclass.datasource.DataModelListener originator)
          Requery all DataTables.
protected  void resetSummaryDataTables(com.klg.jclass.higrid.HiGrid grid, boolean clearCachedData)
          Reset the summary data tables of all cached data.
protected  void resetSummaryDataTables(com.klg.jclass.higrid.HiGrid grid, com.klg.jclass.datasource.DataTableModel rootTable, boolean clearCachedData)
          Helper method to reset the summary data tables.
 void setModelName(String modelName)
          Set this model's name.
protected  void setSummaryDataRoot(com.klg.jclass.higrid.HiGrid grid, com.klg.jclass.datasource.DataTableModel recordData)
          Set the root for the summary data model.
 void updateAll(com.klg.jclass.datasource.DataModelListener originator)
          Write all pending changes in all DataTables to the data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOOTER

public static final int FOOTER
See Also:
Constant Field Values

BEFORE_DETAILS

public static final int BEFORE_DETAILS
See Also:
Constant Field Values

AFTER_DETAILS

public static final int AFTER_DETAILS
See Also:
Constant Field Values

SUMMARY_ROWS

public static final int SUMMARY_ROWS
See Also:
Constant Field Values

dataModel

protected com.klg.jclass.datasource.DataModel dataModel
Constructor Detail

HiGridData

protected HiGridData()
Constructors.


HiGridData

public HiGridData(com.klg.jclass.datasource.DataModel dataModel)
Method Detail

getMetaDataTree

public TreeModel getMetaDataTree()
Return a handle to the MetaTree.

Specified by:
getMetaDataTree in interface DataModel
Returns:
a MetaDataTableTreeModel which can be traversed to determine the hierarchy of the data.

getDataTableTree

public TreeModel getDataTableTree()
Return a handle to the DataTree.

Specified by:
getDataTableTree in interface DataModel
Returns:
a DataTableTreeModel which can be traversed to the hierarchy of DataTables

addDataModelListener

public void addDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
Register a listener for this Data Model.

Specified by:
addDataModelListener in interface DataModel
See Also:
DataModelListener

removeDataModelListener

public void removeDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
Remove a listener of this Data Model.

Specified by:
removeDataModelListener in interface DataModel
See Also:
DataModelListener

moveToRow

public boolean moveToRow(com.klg.jclass.datasource.DataModelListener originator,
                         com.klg.jclass.datasource.DataTableModel data_table,
                         long bookmark)
                  throws DataModelException
Called by observers to tell this data model to which row it should move. Depending on the commit policy, moving the internal cursor may automatically commit changes to the originating data source.

Specified by:
moveToRow in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
data_table - the DataTable to which the cursor should be moved
bookmark - a long uniquely identify to which row the cursor should move
Returns:
true if move succeeds, false otherwise
Throws:
DataModelException - If move to row fails.

moveToRow

public boolean moveToRow(com.klg.jclass.datasource.DataModelListener originator,
                         com.klg.jclass.datasource.DataTableModel data_table,
                         long bookmark,
                         boolean moveIdeCursor)
                  throws DataModelException
For internal use only. Called by observers to tell this data model to which row it should move. Depending on the commit policy, moving the internal cursor may automatically commit changes to the originating data source.

Specified by:
moveToRow in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
data_table - the DataTable to which the cursor should be moved
bookmark - a long uniquely identify to which row the cursor should move
moveIdeCursor - a boolean indicating if this move should also cause the ide's cursor to move
Returns:
true if move succeeded, false otherwise
Throws:
DataModelException - If move to row fails.

updateAll

public void updateAll(com.klg.jclass.datasource.DataModelListener originator)
               throws DataModelException
Write all pending changes in all DataTables to the data source.

Specified by:
updateAll in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If update fails.

cancelAll

public void cancelAll(com.klg.jclass.datasource.DataModelListener originator)
               throws DataModelException
Cancel all pending changes in all DataTables.

Specified by:
cancelAll in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If an exception occurs while canceling changes.

requeryAll

public void requeryAll(com.klg.jclass.datasource.DataModelListener originator)
                throws DataModelException
Requery all DataTables.

Specified by:
requeryAll in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If requery fails.

getListeners

public Object getListeners()
Return a list of listeners on this DataModel.

Specified by:
getListeners in interface DataModel
Returns:
an Object which is a list of listeners

fireDataModelEvent

public boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event)
Pass event on to listeners of this DataModel.

Specified by:
fireDataModelEvent in interface DataModel
Parameters:
event - a DataModelEvent
Returns:
true if the event was accepted by all listeners, or false if at least one listener vetoed the change.

fireDataModelEvent

public boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event,
                                  com.klg.jclass.datasource.DataModelListener listener)
Pass event on to listeners of this DataModel.

Specified by:
fireDataModelEvent in interface DataModel
Parameters:
event - a DataModelEvent
listener - the DataModelListener
Returns:
true if the event was accepted by the listener, or false if the listener vetoed the change.

enableDataModelEvents

public void enableDataModelEvents(boolean value)
Enable or disable data model events. When disabled, events are not dispatched to registered listeners. This is useful for making mass changes without having listeners repainting on each change. That is, set enabled to false, make the changes, then set back true.

This is different from the DataModelEvent BEGIN_EVENTS and END_EVENTS events where events are still sent but the listener having received the BEGIN_EVENTS event knows it may choose to disregard the events until the END_EVENTS event is received. They are given the choice.

Temporarily disabling events is more efficient than using the BEGIN/END_EVENTS method since the events are not dispatched to all listeners.

Specified by:
enableDataModelEvents in interface DataModel
See Also:
DataModelEvent, getEventsEnabled()

getEventsEnabled

public boolean getEventsEnabled()
Return true if events are enabled, false otherwise.

Specified by:
getEventsEnabled in interface DataModel
Returns:
true if events are enabled, false otherwise.
See Also:
enableDataModelEvents(boolean)

setModelName

public void setModelName(String modelName)
Set this model's name. This is used to identify this model so it must be unique.

Specified by:
setModelName in interface DataModel
Parameters:
modelName - a String which is to be this model's name

getModelName

public String getModelName()
Get this model's name. If no name is set, the default name of an instance of this class will be the concatenation of this class's name and a numeric digit. For example TreeData1.

Specified by:
getModelName in interface DataModel
Returns:
a String which is the name of this model.

getCurrentGlobalTable

public com.klg.jclass.datasource.DataTableModel getCurrentGlobalTable()
Return the DataTableModel currently in focus.

Specified by:
getCurrentGlobalTable in interface DataModel
Returns:
the DataTableModel which has the global cursor's focus
See Also:
moveToRow(com.klg.jclass.datasource.DataModelListener, com.klg.jclass.datasource.DataTableModel, long), getCurrentGlobalBookmark()

getCurrentGlobalBookmark

public long getCurrentGlobalBookmark()
Return the bookmark of the row which has the global cursor's focus.

Specified by:
getCurrentGlobalBookmark in interface DataModel
Returns:
the bookmark of the row on which the global cursor is located
See Also:
moveToRow(com.klg.jclass.datasource.DataModelListener, com.klg.jclass.datasource.DataTableModel, long), getCurrentGlobalTable()

isModified

public boolean isModified()
Are there any pending modifications in any rows in this entire data model?

Specified by:
isModified in interface DataModel
Returns:
true if there is at least one change pending, false otherwise

getCurrentDataTable

public com.klg.jclass.datasource.DataTableModel getCurrentDataTable(com.klg.jclass.datasource.DataModelListener originator,
                                                                    com.klg.jclass.datasource.MetaDataModel myLevel)
                                                             throws DataModelException
Returns the DataTable at the specified MetaData level based on the current bookmark. Bookmark refers to what we're calling the "bookmark path" ie the bookmarks for each parent MetaData level down to the specified level.

Will create the table if it does not exist. In this case it will be the child of the current row in the parent, and so on.

Specified by:
getCurrentDataTable in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
Returns:
the DataTableModel currently in focus for this level
Throws:
DataModelException - If get fails.

getCurrentDataItem

public Object getCurrentDataItem(com.klg.jclass.datasource.DataModelListener originator,
                                 com.klg.jclass.datasource.MetaDataModel myLevel,
                                 String column)
                          throws DataModelException
Returns the data item at the specified MetaData level and column for the current row. Equivalent to calling DataTableModel.getResultData() with the current bookmark at the MetaData level.

Will create the table if it does not exist. In this case it will be the child of the current row in the parent, and so on.

Specified by:
getCurrentDataItem in interface DataModel
Parameters:
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If get fails.

getMetaData

public com.klg.jclass.datasource.MetaDataModel getMetaData(String metaDataName)
Get a MetaDataModel instance by name, or null if not found.

Specified by:
getMetaData in interface DataModel
Parameters:
metaDataName - a String which is the name of the MetaDataModel object
Returns:
the MetaDataModel for which getDescription() == metaDataName, or null if not found.
See Also:
MetaDataModel.setDescription(java.lang.String), MetaDataModel.getDescription()

clearCurrentPath

public void clearCurrentPath(com.klg.jclass.datasource.MetaDataModel parentMeta)
Clear the current path of all children of this MetaDataModel.

Specified by:
clearCurrentPath in interface DataModel
Parameters:
parentMeta - the MetaDataModel whose children are to be cleared.

getFooterMetaTree

public TreeModel getFooterMetaTree()
Retrieves the footer meta tree.

Returns:
The footer meta tree.

getBeforeDetailsMetaTree

public TreeModel getBeforeDetailsMetaTree()
Retrieves the before details meta tree.

Returns:
The before details meta tree.

getAfterDetailsMetaTree

public TreeModel getAfterDetailsMetaTree()
Retrieves the after details meta tree.

Returns:
The after details meta tree.

createFooterMetaTree

protected void createFooterMetaTree()
Create the footer meta tree with the same hierarchy as the meta tree for the record type.


createBeforeDetailsMetaTree

protected void createBeforeDetailsMetaTree()
Create the before details meta tree with the same hierarchy as the meta tree for the record type.


createAfterDetailsMetaTree

protected void createAfterDetailsMetaTree()
Create the after details meta tree with the same hierarchy as the meta tree for the record type.


createSummaryMetaTree

protected void createSummaryMetaTree()
Create the summary meta trees with the same hierarchy as the meta tree for the record type. It assumes the record type meta data tree is already built.


createSummaryMetaTree

protected com.klg.jclass.datasource.DataSourceTreeModel createSummaryMetaTree(com.klg.jclass.datasource.DataSourceTreeModel summaryTree,
                                                                              int summary)
Create a summary meta tree with the same hierarchy as the meta tree for the record type.

Parameters:
summaryTree - The summary meta tree.
summary - The summary type.
Returns:
The new summary meta tree.

createSummaryMetaTreeFromNode

protected void createSummaryMetaTreeFromNode(com.klg.jclass.datasource.DataSourceTreeModel summaryTree,
                                             com.klg.jclass.datasource.MetaDataModel rootMetaData,
                                             com.klg.jclass.datasource.MetaDataModel rootSummary,
                                             int summary)
Recursive helper routine to create the summary meta tree.

Parameters:
summaryTree - The summary meta tree.
rootMetaData - The record type root meta data.
rootSummary - The summary root meta data.
summary - The summary type.

createSummaryMetaData

protected com.klg.jclass.datasource.MetaDataModel createSummaryMetaData(int summary,
                                                                        int metaID)
Create a new summary meta data object.

Parameters:
summary - The summary type.
metaID - The meta id.
Returns:
The new summary meta data object.

setSummaryDataRoot

protected void setSummaryDataRoot(com.klg.jclass.higrid.HiGrid grid,
                                  com.klg.jclass.datasource.DataTableModel recordData)
Set the root for the summary data model.

Parameters:
grid - The HiGrid instance.
recordData - The data table model for the record type.

createSummaryDataTable

protected void createSummaryDataTable(com.klg.jclass.higrid.HiGrid grid,
                                      com.klg.jclass.datasource.DataTableModel recordData,
                                      com.klg.jclass.higrid.FormatNode node)
Create the summary data table for the given data table model.

Parameters:
grid - The HiGrid instance.
recordData - The data table model for the record type.
node - The format node of the level.

resetSummaryDataTables

protected void resetSummaryDataTables(com.klg.jclass.higrid.HiGrid grid,
                                      boolean clearCachedData)
Reset the summary data tables of all cached data.

Parameters:
grid - The HiGrid instance.
clearCachedData - True if the cached data are to be removed.

resetSummaryDataTables

protected void resetSummaryDataTables(com.klg.jclass.higrid.HiGrid grid,
                                      com.klg.jclass.datasource.DataTableModel rootTable,
                                      boolean clearCachedData)
Helper method to reset the summary data tables.

Parameters:
grid - The HiGrid instance.
rootTable - The root record table.
clearCachedData - True if the cached data are to be removed.

clearDataTableTreeUserData

public void clearDataTableTreeUserData(Object user)
Clears all user data. Clears all Objects which were arbitrarily associated with the entire DataTableTree.

Specified by:
clearDataTableTreeUserData in interface DataModel
Parameters:
user - an Object, a reference to the user.

clearDataTableTreeInternalData

public void clearDataTableTreeInternalData(Object user)
For internal use only. Clears all internal data. Clears all Objects which were arbitrarily associated with the entire DataTableTree.

Specified by:
clearDataTableTreeInternalData in interface DataModel
Parameters:
user - an Object, a reference to the user.

Copyright © 2004 Quest Software Inc..
All rights reserved.