borland Packages  Class Hierarchy  dbswing Package 

DBTreeNavBinder component

java.lang.Object
   +----com.borland.dbswing.DBTreeNavBinder
           +----com.borland.dbswing.DBTreeDataBinder

About the DBTreeNavBinder component

Variables  Constructors  Properties  Methods  

Implements DBDataBinder, AccessListener, ColumnAware, DataChangeListener, DataSetAware, Designable, NavigationListener, PropertyChangeListener, Serializable, EventListener, TreeModelListener, TreeSelectionListener

Note: This is a feature of JBuilder Professional and Enterprise.

DBTreeNavBinder navigates a DataSet by synchronizing a JTree's selected value with a DataSet Column value. DBTreeNavBinder is the default binder used by JdbNavTree.

There are two other ways to use a DBTreeNavBinder to navigate a DataSet. The easiest way is to simply set the JTree property to a JTree (or subclass of JTree). Alternatively, any component using a TreeSelectionModel can be set as DBTreeNavBinder's treeSelectionModel property (or DBTreeNavBinder can be added as a TreeSelectionListener to the component). If you take this approach, however, you are responsible for opening the DataSet from which to read data.

In either case, you also need to set DBTreeNavBinder's dataSet and columnName properties to indicate the DataSet and Column in which the tree will navigate.

If you set the JTree property, DBTreeNavBinder will also bind the background, foreground, and font properties from those defined on Column columnName (if defined), unless already explicitly set on the JTree itself.

DBTreeNavBinder can only synchronize values between the tree and DataSet if the TreeNodes are of actual type javax.swing.tree.DefaultMutableTreeNode, since the DefaultMutableTreeNode.getUserObject() method is used to read values from the tree. The object returned by getUserObject() is assumed to be of the same data type as that of Column columnName.

Unlike DBTreeDataBinder, which writes values into the current row of a DataSet, DBTreeNavBinder locates and navigates to a row in the DataSet with a Column value matching the currently selected node in the tree.

If the selected value in the tree cannot be located in the DataSet, DBTreeNavBinder displays a confirmation dialog explaining that this is the case. If the current value in the DataSet cannot be found in the tree, the tree's selection is cleared.

Example:

JTree jTree = new JTree();
DBTreeNavBinder DBTreeNavBinder = new DBTreeNavBinder();

// set the tree's TreeModel
jTree.setModel(treeModel);
 
// when a value is selected from the tree, it will be
// written to the "path" column of DataSet dataSet
dbTreeNavBinder.setJTree(jTree);
dbTreeNavBinder.setDataSet(dataSet);
dbTreeNavBinder.setColumnName("path");
 
See also: JdbTree, JdbNavTree, DBTreeDataBinder

DBTreeNavBinder variables

Variables implemented in this class

DBTreeNavBinder constructors

DBTreeNavBinder properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

DBTreeNavBinder methods

Methods implemented in this class

Methods implemented in java.lang.Object


DBTreeNavBinder variables

ignoreValueChange

  protected boolean ignoreValueChange
An flag indicating that a change of value should be ignored. You should never need to use this variable.

mode

  protected int mode
The current unknown data value mode.

treeModel

  protected TreeModel treeModel
The TreeModel of this tree from which data is read.

treeSelectionModel

  protected TreeSelectionModel treeSelectionModel
Identifies the treeSelectionModel containing the current tree selection.

DBTreeNavBinder constructors

DBTreeNavBinder()

  public DBTreeNavBinder()
Constructs a DBTreeNavBinder component. Calls the null constructor of its superclass.

DBTreeNavBinder(javax.swing.JTree)

  public DBTreeNavBinder(JTree jTree)
Creates a DBTreeNavBinder that navigates the specified JTree. Calls the null constructor of its superclass.

Parameters:

jTree
The JTree which this DBTreeNavBinder will navigate.

DBTreeNavBinder properties

columnName

 public String getColumnName()
 public void setColumnName(String columnName)
Returns and sets the column name of the DataSet from which values should be read.

See also: dataSet property

dataSet

 public DataSet getDataSet()
 public void setDataSet(DataSet dataSet)
Returns and sets the DataSet from which values should be read.

See also: columnName property

JTree

 public JTree getJTree()
 public void setJTree(JTree jTree)
Returns and sets the JTree used to navigate the DataSet.

See About DBNavTreeBinder component for more information.

treeModel

 public TreeModel getTreeModel()
 public void setTreeModel(TreeModel treeModel)
Returns and sets the TreeModel containing data to navigate in the DataSet.

treeSelectionModel

 public TreeSelectionModel getTreeSelectionModel()
 public void setTreeSelectionModel(TreeSelectionModel treeSelectionModel)
Returns and sets the TreeSelectionModel used to determine when navigation in the DataSet should occur.

See About DBNavTreeBinder component for more information.

useLeafNodesOnly

 public boolean isUseLeafNodesOnly()
 public void setUseLeafNodesOnly(boolean useLeafNodesOnly)
Returns and sets whether to ignore internal node values during selection changes and when locating nodes by value.

DBTreeNavBinder methods

bindColumnProperties()

  protected void bindColumnProperties()
Sets the font, foreground, and background properties from the column properties of the same names if these properties are not explicitly set.

findUserObject(javax.swing.tree.DefaultMutableTreeNode, java.lang.Object)

  protected TreePath findUserObject(DefaultMutableTreeNode node, Object object)
Searches for the user object within the tree rooted at node using a depth-first search algorithm. The equals() method of the node's user object is called to determine whether the two user objects are equal.

Returns the TreePath to the specified user object if found, otherwise returns null. You can override this method to implement your own tree search algorithm.

updateSelectedTreeValue()

  protected void updateSelectedTreeValue()
Finds the current value and sets it as the current selection in the tree.