JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource
Class TreeData

java.lang.Object
  |
  +--com.klg.jclass.datasource.TreeData
All Implemented Interfaces:
DataModel, Serializable
Direct Known Subclasses:
JCData, JCTreeData

public class TreeData
extends Object
implements DataModel, Serializable

An implementation of DataModel. Implements trees and listener functions.

See Also:
Serialized Form

Field Summary
protected  long currentBookmark
          Previous row_identifier, used for cursor
protected  com.klg.jclass.datasource.DataTableModel currentDataTable
          Previous data table, used for cursor
protected  com.klg.jclass.datasource.DataSourceTreeModel data_tree
          DataSourceTreeModel for DataTables.
protected  boolean eventsEnabled
          enable events?
protected  com.klg.jclass.util.JCListenerList listeners
          Listeners
protected  com.klg.jclass.datasource.DataSourceTreeModel meta_tree
          DataSourceTreeModel for metadata.
protected  String modelName
          This model's name
protected static int nameCounter
          Static counter used to create default names for instances of this class.
 
Constructor Summary
TreeData()
          A constructor for TreeData, an implementation of DataModel which can be extened.
 
Method Summary
 void addDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
          Implements DataModel method addDataModelListener.
 void cancelAll(com.klg.jclass.datasource.DataModelListener originator)
          Cancels 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.
 void enableDataModelEvents(boolean value)
          Enable or disable data model events.
 boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event)
          Passes event on to listeners of this DataModel.
 boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event, com.klg.jclass.datasource.DataModelListener listener)
          Passes event on to a single specific listener of this DataModel.
protected  void fireDataModelEventInternal(com.klg.jclass.datasource.DataModelEvent event, com.klg.jclass.datasource.DataModelListener listener)
          Sends event on to a single specific listener of this DataModel (internal version)
 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()
          Implements DataModel method getDataTree.
 boolean getEventsEnabled()
          Return true if events are enabled, false otherwise.
 Object getListeners()
          Returns a list of listeners
 com.klg.jclass.datasource.MetaDataModel getMetaData(String metaDataName)
          Get a MetaDataModel instance by name, or null if not found.
 TreeModel getMetaDataTree()
          Implements DataModel method getMetaDataTree.
 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)
          Implements DataModel method removeDataModelListener.
 void requeryAll(com.klg.jclass.datasource.DataModelListener originator)
          Requeries all DataTables.
protected  boolean sendDataModelEvent(com.klg.jclass.datasource.DataModelEvent event, com.klg.jclass.datasource.DataModelListener listener)
          Sends event on to listeners of this DataModel (internal version)
 void setModelName(String modelName)
          Set this model's name.
 void updateAll(com.klg.jclass.datasource.DataModelListener originator)
          Writes 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

meta_tree

protected com.klg.jclass.datasource.DataSourceTreeModel meta_tree
DataSourceTreeModel for metadata.


data_tree

protected transient com.klg.jclass.datasource.DataSourceTreeModel data_tree
DataSourceTreeModel for DataTables.


listeners

protected com.klg.jclass.util.JCListenerList listeners
Listeners


currentDataTable

protected transient com.klg.jclass.datasource.DataTableModel currentDataTable
Previous data table, used for cursor


currentBookmark

protected long currentBookmark
Previous row_identifier, used for cursor


eventsEnabled

protected boolean eventsEnabled
enable events?


nameCounter

protected static int nameCounter
Static counter used to create default names for instances of this class.


modelName

protected String modelName
This model's name

Constructor Detail

TreeData

public TreeData()
A constructor for TreeData, an implementation of DataModel which can be extened.

Method Detail

getMetaDataTree

public TreeModel getMetaDataTree()
Implements DataModel method getMetaDataTree.

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

getDataTableTree

public TreeModel getDataTableTree()
Implements DataModel method getDataTree.

Specified by:
getDataTableTree in interface DataModel
Returns:
a TreeModel which can be traversed to the hierarchy of DataTableModels.

addDataModelListener

public void addDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
Implements DataModel method addDataModelListener.

Specified by:
addDataModelListener in interface DataModel
See Also:
DataModelListener

removeDataModelListener

public void removeDataModelListener(com.klg.jclass.datasource.DataModelListener listener)
Implements DataModel method removeDataModelListener.

Specified by:
removeDataModelListener in interface DataModel
See Also:
DataModelListener

getListeners

public Object getListeners()
Returns a list of listeners

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

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.

Upon intialization of the data model the current data table is the root data table and the current bookmark is the first row.

Fires a BEFORE_MOVE_TO_CURRENT_ROW which if cancelled, cancels the move and an AFTER_MOVE_TO_CURRENT_ROW on a sucessful move.

During the move if the row or subtree which is being left is modified a BEFORE_COMMIT_ROW or a BEFORE_COMMIT_CONDITIONAL message will be sent. If either of these is cancelled, the move will fail.

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 the move succeeded, false otherwise (may have been cancelled)
Throws:
DataModelException - If moveToRow 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
Writes all pending changes in all DataTables to the data source. Wraps recursive calls to commitAll() between BEGING_EVENTS and END_EVENTS events so listeners can choose to batch these events.

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

cancelAll

public void cancelAll(com.klg.jclass.datasource.DataModelListener originator)
               throws DataModelException
Cancels all pending changes in all DataTables. Wraps recursive calls to cancelAllRowChanges() between BEGIN_EVENTS and END_EVENTS events so listeners can choose to batch these events.

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

requeryAll

public void requeryAll(com.klg.jclass.datasource.DataModelListener originator)
                throws DataModelException
Requeries all DataTables. All previous DataTableModels are invalidated. The root is reset in the DataTableTree.

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

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.

fireDataModelEvent

public boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event,
                                  com.klg.jclass.datasource.DataModelListener listener)
Passes event on to a single specific listener 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.

fireDataModelEvent

public boolean fireDataModelEvent(com.klg.jclass.datasource.DataModelEvent event)
Passes 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.

sendDataModelEvent

protected boolean sendDataModelEvent(com.klg.jclass.datasource.DataModelEvent event,
                                     com.klg.jclass.datasource.DataModelListener listener)
Sends event on to listeners of this DataModel (internal version)

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.

fireDataModelEventInternal

protected void fireDataModelEventInternal(com.klg.jclass.datasource.DataModelEvent event,
                                          com.klg.jclass.datasource.DataModelListener listener)
Sends event on to a single specific listener of this DataModel (internal version)

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()

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()

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

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.