borland Packages Class Hierarchy dbswing Package
java.lang.Object +----com.borland.dbswing.DBTreeNavBinder +----com.borland.dbswing.DBTreeDataBinder
Variables Constructors Properties Methods
Implements DBDataBinder, AccessListener, ColumnAware, DataChangeListener, DataSetAware, Designable, NavigationListener, PropertyChangeListener, Serializable, EventListener, TreeModelListener, TreeSelectionListener
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.
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");
JdbTree
, JdbNavTree
, DBTreeDataBinder
protected boolean ignoreValueChangeAn flag indicating that a change of value should be ignored. You should never need to use this variable.
protected int modeThe current unknown data value mode.
protected TreeModel treeModelThe
TreeModel
of this tree from which data is read.
protected TreeSelectionModel treeSelectionModelIdentifies the
treeSelectionModel
containing the current tree selection.
public DBTreeNavBinder()Constructs a
DBTreeNavBinder
component. Calls the null
constructor of its superclass.
public DBTreeNavBinder(JTree jTree)Creates a
DBTreeNavBinder
that navigates the specified JTree
. Calls the null
constructor of its superclass.
jTree
JTree
which this DBTreeNavBinder
will navigate.
public String getColumnName() public void setColumnName(String columnName)Returns and sets the column name of the
DataSet
from which values should be read.
dataSet
property
public DataSet getDataSet() public void setDataSet(DataSet dataSet)Returns and sets the
DataSet
from which values should be read.
columnName
property
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.
public TreeModel getTreeModel() public void setTreeModel(TreeModel treeModel)Returns and sets the
TreeModel
containing data to navigate in the DataSet
.
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.
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.
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.
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.
protected void updateSelectedTreeValue()Finds the current value and sets it as the current selection in the tree.