com.tensegrity.gui.swing.control.attributetree
Class AttributeTreeModel

java.lang.Object
  extended bycom.tensegrity.gui.swing.control.attributetree.AttributeTreeModel
All Implemented Interfaces:
AttributableOnSetListener, EventListenerTag, javax.swing.table.TableModel

public class AttributeTreeModel
extends java.lang.Object
implements javax.swing.table.TableModel, AttributableOnSetListener

The TableModel for the AttributeTree

Version:
$Id: AttributeTreeModel.java,v 1.40 2004/07/23 11:07:17 BurkhardWick Exp $
Author:
BurkhardWick

Constructor Summary
AttributeTreeModel(SwingAttributeTree tree)
          Constructor
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
 void allowEditing(boolean b)
          Enables/disables the editing of fields that are usually not editable
 void attributesChanged(AttributableOnSetEvent attributableOnSetEvent)
          Invoked when an attribute in an AttributableOnSet object has changed.
protected  void expandPath(AttributeTreeNode node)
          Expands all nodes on the path to the given node
 AttributableOnSet getAttributableOnSet()
          Returns the AttributableOnSet currently loaded into the table
 java.util.List getAttributePaths(boolean ignoreLeafs)
          Returns all paths of the current attribute set
 java.lang.Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
protected  AttributeSet getCurrentAttributeSet()
          Returns the current AttributeSet
 java.util.Vector getLeafExpansions()
          Returns all expanded nodes that have no expanded child nodes
 AttributeTreeNode getNodeByPath(java.lang.String path)
          Returns the node with the given path
 java.lang.String getNodePath(AttributeTreeNode node)
          Returns the path to the given node.
 java.util.Collection getRealPaths(java.lang.String shortPath)
          Returns the real paths the given short path (retrieved by node.getPathName()) is referring to.
 AttributeTreeNode getRoot()
          Returns the root node of the tree structure
protected  AttributeTreeNode getRow(AttributeTreeNode node, int row)
          Returns the AttributeTreeNode representing the given table row relative to the given node.
 AttributeTreeNode getRow(int row)
          Returns the AttributeTreeNode representing the given table row.
 int getRowCount()
           
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
protected  boolean isExpanded(int row)
          Returns true, if the node at the given row is expanded
 boolean isMutable(java.lang.String pathName)
          Checks, if the attribute described by the given path name is mutable or not. !
 boolean isUndefined(int row, int col)
          Returns true, if the attribute at the given row and column is in a undefined state when editing a multiselection.
 void rebuildTree()
          Rebuilds the tree that is displayed in this table
 void refreshTree()
          Refreshed the information in the tree by reloading it from the current AttributableOnSet
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setAttributableOnSet(AttributableOnSet attributable)
          Sets the AttributableOnSet to be edited in this table
 void setExpanded(int row, boolean expanded)
          Expands/collapse the node at the given row
 void setExpandedAll(int row, boolean expanded)
          Set the expanded state of all nodes in the subtree under the node at the given row.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 void updateStaticValues()
          Updates the static values of the nodes like the visible state or the level
 void updateTree()
          Updates the values in the tree by reloading the attributes from the AttributableOnSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeTreeModel

public AttributeTreeModel(SwingAttributeTree tree)
Constructor

Parameters:
tree - The tree this model belongs to
Method Detail

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

getRow

public AttributeTreeNode getRow(int row)
Returns the AttributeTreeNode representing the given table row.

Parameters:
row - The row to retrieve the node for
Returns:
the AttributeTreeNode representing the given table row.

getRow

protected AttributeTreeNode getRow(AttributeTreeNode node,
                                   int row)
Returns the AttributeTreeNode representing the given table row relative to the given node.

Parameters:
node - The node that rhe relative row number is referring to
row - The row to retrieve the node for
Returns:
the AttributeTreeNode representing the given table row.

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

rebuildTree

public void rebuildTree()
Rebuilds the tree that is displayed in this table


updateTree

public void updateTree()
Updates the values in the tree by reloading the attributes from the AttributableOnSet


isMutable

public boolean isMutable(java.lang.String pathName)
Checks, if the attribute described by the given path name is mutable or not. ! Note that the Attribute may still be immutable, if this method returns true, when it is returned as immutable from the AttributableOnSet itself !

Parameters:
pathName - The path name of the attribute (type root might be removed)
Returns:
true, if the mutable state is not changed in the editor false, if the attribute will not be editable by the editor

setAttributableOnSet

public void setAttributableOnSet(AttributableOnSet attributable)
Sets the AttributableOnSet to be edited in this table

Parameters:
attributable - the AttributableOnSet to be edited in this table

getAttributableOnSet

public AttributableOnSet getAttributableOnSet()
Returns the AttributableOnSet currently loaded into the table

Returns:
the AttributableOnSet currently loaded into the table

getCurrentAttributeSet

protected AttributeSet getCurrentAttributeSet()
Returns the current AttributeSet

Returns:
the current AttributeSet

refreshTree

public void refreshTree()
Refreshed the information in the tree by reloading it from the current AttributableOnSet


attributesChanged

public void attributesChanged(AttributableOnSetEvent attributableOnSetEvent)
Description copied from interface: AttributableOnSetListener
Invoked when an attribute in an AttributableOnSet object has changed.

Specified by:
attributesChanged in interface AttributableOnSetListener
Parameters:
attributableOnSetEvent - the event carrying information.

allowEditing

public void allowEditing(boolean b)
Enables/disables the editing of fields that are usually not editable

Parameters:
b - True to enable editing

getLeafExpansions

public java.util.Vector getLeafExpansions()
Returns all expanded nodes that have no expanded child nodes

Returns:
A vector containing all leaf expansions

getNodeByPath

public AttributeTreeNode getNodeByPath(java.lang.String path)
Returns the node with the given path

Parameters:
path - The path of the node
Returns:
the node with the given path

updateStaticValues

public void updateStaticValues()
Updates the static values of the nodes like the visible state or the level


isExpanded

protected boolean isExpanded(int row)
Returns true, if the node at the given row is expanded

Parameters:
row - The row to check
Returns:
true, if the node at the given row is expanded

setExpanded

public void setExpanded(int row,
                        boolean expanded)
Expands/collapse the node at the given row

Parameters:
row - The row to expand/collapse
expanded - True to expand, false to collapse

setExpandedAll

public void setExpandedAll(int row,
                           boolean expanded)
Set the expanded state of all nodes in the subtree under the node at the given row.

Parameters:
row - The row to expand/collapse
expanded - The new state

expandPath

protected void expandPath(AttributeTreeNode node)
Expands all nodes on the path to the given node

Parameters:
node - The node which defines the end of the path to expand

getNodePath

public java.lang.String getNodePath(AttributeTreeNode node)
Returns the path to the given node. Warning! When merging element types is on, the path might not be correct for all selected elements!

Parameters:
node - The node to retrieve the path for
Returns:
the path to the given node

isUndefined

public boolean isUndefined(int row,
                           int col)
Returns true, if the attribute at the given row and column is in a undefined state when editing a multiselection.

Parameters:
row - The row of the attribute to check
col - The column of the attribute to check
Returns:
True, if the attribute value is undefined

getRoot

public AttributeTreeNode getRoot()
Returns the root node of the tree structure

Returns:
the root node of the tree structure

getAttributePaths

public java.util.List getAttributePaths(boolean ignoreLeafs)
Returns all paths of the current attribute set

Parameters:
ignoreLeafs - true, to ignore leafs
Returns:
all paths of the current attribute set

getRealPaths

public java.util.Collection getRealPaths(java.lang.String shortPath)
Returns the real paths the given short path (retrieved by node.getPathName()) is referring to. The reason for this is the merging of the types, so one pathname refers to more than one node.

Parameters:
shortPath - The path name retrieved by AttributeTreeNode.getPathName()
Returns:
Returns all paths that the short path is referring to


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.