<html> <head> <title>Service TreeControl</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="../../../../../idl.css"> </head> <body> <div id="adc-idlref"> <a name="_top_"> </a><table class="navimain" border="0" cellpadding="3"> <tr> <td class="navimain"><a href="../../module-ix.html" class="navimain">Overview</a></td> <td class="navimain"><a href="module-ix.html" class="navimain">Module</a></td> <td class="navimainnone">Use</td> <td class="navimainnone">Devguide</td> <td class="navimain"><a href="../../../../../index-files/index-1.html" class="navimain">Index</a></td> </tr> </table> <table class="navisub" border="0" cellpadding="0"> <tr> <td class="navisub">Constructors' Summary</td> <td class="navisub">Constructors' Details</td> </tr> </table> <hr> <table border="0" width="100%" cellpadding="5" cellspacing="3" class="title-table" style="margin-bottom:6pt;"> <tr> <td><p class="namechain"><a href="../../../../../module-ix.html" class="namechain">::</a> <a href="../../../../module-ix.html" class="namechain">com</a> :: <a href="../../../module-ix.html" class="namechain">sun</a> :: <a href="../../module-ix.html" class="namechain">star</a> :: <a href="../module-ix.html" class="namechain">awt</a> :: <a href="module-ix.html" class="namechain">tree</a> :: </p> </td> </tr> <tr> <td class="title"><table class="title-table" width="99%"> <tr> <td width="25%" class="title2">unpublished </td> <td width="50%" class="title">service TreeControl</td> <td width="*"/></tr> </table> </td> </tr> <tr> <td><dl> <dt><b>Supported Interface</b></dt> <dd><a href="XTreeControl.html">XTreeControl</a></dd> </dl> </td> </tr> <tr> <td><dl> <dt><b>Description</b></dt> <dd>A control that displays a set of hierarchical data as an outline. </dd> <dd><p> <h4>The Data Model</h4> <p>A specific node in a tree is identified by a <a href="XTreeNode.html">XTreeNode</a>. A leaf node is a node without any children and that returns <b>false</b> when calling <a href="XTreeNode.html">XTreeNode</a>::<a href="XTreeNode.html#hasChildrenOnDemand">hasChildrenOnDemand()</a>. An expanded node is a non-leaf node that will displays its children when all its ancestors are expanded. A collapsed node is one which hides them. A node is visible when all parent nodes are expanded and the node itself is in the display area. </p> <p>The nodes are retrieved from a <a href="XTreeDataModel.html">XTreeDataModel</a>. You can implement it yourself or use the <a href="MutableTreeDataModel.html">MutableTreeDataModel</a> which uses <a href="XMutableTreeNode.html">XMutableTreeNode</a> and <a href="XMutableTreeDataModel.html">XMutableTreeDataModel</a> for a simple and mutable data model. <p>The data model must be set at the <a href="TreeControlModel.html">TreeControlModel</a>::<a href="TreeControlModel.html#TreeDataModel">TreeDataModel</a> property.</p> <h4>Selection</h4> <p>If you are interested in knowing when the selection changes implement a ::com::sun::star::<a href="../../view/module-ix.html">view</a>::<a href="../../view/XSelectionChangeListener.html">XSelectionChangeListener</a> and add the instance with the method ::com::sun::star::<a href="../../view/module-ix.html">view</a>::<a href="../../view/XSelectionSupplier.html">XSelectionSupplier</a>::<a href="../../view/XSelectionSupplier.html#addSelectionChangeListener">addSelectionChangeListener()</a>. You than will be notified for any selection change. </p> <p> If you are interested in detecting either double-click events or when a user clicks on a node, regardless of whether or not it was selected, you can get the ::com::sun::star::<a href="../module-ix.html">awt</a>::<a href="../XWindow.html">XWindow</a> and add yourself as a ::com::sun::star::<a href="../module-ix.html">awt</a>::<a href="../XMouseClickHandler.html">XMouseClickHandler</a>. You can use the method <a href="XTreeControl.html">XTreeControl</a>::<a href="XTreeControl.html#getNodeForLocation">getNodeForLocation()</a> to retrieve the node that was under the mouse at the time the event was fired. </p> <h4>Adding child nodes on demand</h4> <p>If you want to add child nodes to your tree on demand you can do the following. <ul> <li>Make sure the parent node returns <b>true</b> for <a href="XTreeNode.html">XTreeNode</a>::<a href="XTreeNode.html#hasChildrenOnDemand">hasChildrenOnDemand()</a> either by implementing <a href="XTreeNode.html">XTreeNode</a> yourself or if you use the <a href="MutableTreeDataModel.html">MutableTreeDataModel</a>, use <a href="XMutableTreeNode.html">XMutableTreeNode</a>::<a href="XMutableTreeNode.html#setHasChildrenOnDemand">setHasChildrenOnDemand()</a>.</li> <li>Implement a <a href="XTreeExpansionListener.html">XTreeExpansionListener</a> and add the instance with the method <a href="XTreeControl.html">XTreeControl</a>::<a href="XTreeControl.html#addTreeExpansionListener">addTreeExpansionListener()</a>.</li> </ul> Now you get called when the node will become expanded or collapsed. So on <a href="XTreeExpansionListener.html">XTreeExpansionListener</a>::<a href="XTreeExpansionListener.html#treeExpanding">treeExpanding()</a> you can check the <a href="TreeExpansionEvent.html">TreeExpansionEvent</a> if the parent node with children on demand is going to be expanded and in that case add the missing child nodes. You can also veto the expansion or collapsing of a parent node by using the <a href="ExpandVetoException.html">ExpandVetoException</a>. </p> </dd> </dl> </td> </tr> </table> <hr> <hr> <br> <a href="#_top_">Top of Page</a><hr size="3"><p class="copyright" align="center">Copyright © 2008 Sun Microsystems, Inc.</p> </div> <!-- id="adc-idlref" --> </body> </html>