equal
deleted
inserted
replaced
103 |
103 |
104 /** |
104 /** |
105 * Sets whether or not to test leafness by asking getAllowsChildren() |
105 * Sets whether or not to test leafness by asking getAllowsChildren() |
106 * or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() |
106 * or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() |
107 * is messaged, otherwise isLeaf() is messaged. |
107 * is messaged, otherwise isLeaf() is messaged. |
|
108 * |
|
109 * @param newValue if true, getAllowsChildren() is messaged, otherwise |
|
110 * isLeaf() is messaged |
108 */ |
111 */ |
109 public void setAsksAllowsChildren(boolean newValue) { |
112 public void setAsksAllowsChildren(boolean newValue) { |
110 asksAllowsChildren = newValue; |
113 asksAllowsChildren = newValue; |
111 } |
114 } |
112 |
115 |
123 } |
126 } |
124 |
127 |
125 /** |
128 /** |
126 * Sets the root to <code>root</code>. A null <code>root</code> implies |
129 * Sets the root to <code>root</code>. A null <code>root</code> implies |
127 * the tree is to display nothing, and is legal. |
130 * the tree is to display nothing, and is legal. |
|
131 * |
|
132 * @param root new value of tree root |
128 */ |
133 */ |
129 public void setRoot(TreeNode root) { |
134 public void setRoot(TreeNode root) { |
130 Object oldRoot = this.root; |
135 Object oldRoot = this.root; |
131 this.root = root; |
136 this.root = root; |
132 if (root == null && oldRoot != null) { |
137 if (root == null && oldRoot != null) { |
229 /** |
234 /** |
230 * Invoked this to insert newChild at location index in parents children. |
235 * Invoked this to insert newChild at location index in parents children. |
231 * This will then message nodesWereInserted to create the appropriate |
236 * This will then message nodesWereInserted to create the appropriate |
232 * event. This is the preferred way to add children as it will create |
237 * event. This is the preferred way to add children as it will create |
233 * the appropriate event. |
238 * the appropriate event. |
|
239 * |
|
240 * @param newChild child node to be inserted |
|
241 * @param parent node to which children new node will be added |
|
242 * @param index index of parent's children |
234 */ |
243 */ |
235 public void insertNodeInto(MutableTreeNode newChild, |
244 public void insertNodeInto(MutableTreeNode newChild, |
236 MutableTreeNode parent, int index){ |
245 MutableTreeNode parent, int index){ |
237 parent.insert(newChild, index); |
246 parent.insert(newChild, index); |
238 |
247 |
245 /** |
254 /** |
246 * Message this to remove node from its parent. This will message |
255 * Message this to remove node from its parent. This will message |
247 * nodesWereRemoved to create the appropriate event. This is the |
256 * nodesWereRemoved to create the appropriate event. This is the |
248 * preferred way to remove a node as it handles the event creation |
257 * preferred way to remove a node as it handles the event creation |
249 * for you. |
258 * for you. |
|
259 * |
|
260 * @param node the node to be removed from it's parrent |
250 */ |
261 */ |
251 public void removeNodeFromParent(MutableTreeNode node) { |
262 public void removeNodeFromParent(MutableTreeNode node) { |
252 MutableTreeNode parent = (MutableTreeNode)node.getParent(); |
263 MutableTreeNode parent = (MutableTreeNode)node.getParent(); |
253 |
264 |
254 if(parent == null) |
265 if(parent == null) |
264 } |
275 } |
265 |
276 |
266 /** |
277 /** |
267 * Invoke this method after you've changed how node is to be |
278 * Invoke this method after you've changed how node is to be |
268 * represented in the tree. |
279 * represented in the tree. |
|
280 * |
|
281 * @param node the changed node |
269 */ |
282 */ |
270 public void nodeChanged(TreeNode node) { |
283 public void nodeChanged(TreeNode node) { |
271 if(listenerList != null && node != null) { |
284 if(listenerList != null && node != null) { |
272 TreeNode parent = node.getParent(); |
285 TreeNode parent = node.getParent(); |
273 |
286 |
301 |
314 |
302 /** |
315 /** |
303 * Invoke this method after you've inserted some TreeNodes into |
316 * Invoke this method after you've inserted some TreeNodes into |
304 * node. childIndices should be the index of the new elements and |
317 * node. childIndices should be the index of the new elements and |
305 * must be sorted in ascending order. |
318 * must be sorted in ascending order. |
|
319 * |
|
320 * @param node parent node which children count been incremented |
|
321 * @param childIndices indexes of inserted children |
306 */ |
322 */ |
307 public void nodesWereInserted(TreeNode node, int[] childIndices) { |
323 public void nodesWereInserted(TreeNode node, int[] childIndices) { |
308 if(listenerList != null && node != null && childIndices != null |
324 if(listenerList != null && node != null && childIndices != null |
309 && childIndices.length > 0) { |
325 && childIndices.length > 0) { |
310 int cCount = childIndices.length; |
326 int cCount = childIndices.length; |
320 /** |
336 /** |
321 * Invoke this method after you've removed some TreeNodes from |
337 * Invoke this method after you've removed some TreeNodes from |
322 * node. childIndices should be the index of the removed elements and |
338 * node. childIndices should be the index of the removed elements and |
323 * must be sorted in ascending order. And removedChildren should be |
339 * must be sorted in ascending order. And removedChildren should be |
324 * the array of the children objects that were removed. |
340 * the array of the children objects that were removed. |
|
341 * |
|
342 * @param node parent node which childred were removed |
|
343 * @param childIndices indexes of removed childs |
|
344 * @param removedChildren array of the children objects that were removed |
325 */ |
345 */ |
326 public void nodesWereRemoved(TreeNode node, int[] childIndices, |
346 public void nodesWereRemoved(TreeNode node, int[] childIndices, |
327 Object[] removedChildren) { |
347 Object[] removedChildren) { |
328 if(node != null && childIndices != null) { |
348 if(node != null && childIndices != null) { |
329 fireTreeNodesRemoved(this, getPathToRoot(node), childIndices, |
349 fireTreeNodesRemoved(this, getPathToRoot(node), childIndices, |
332 } |
352 } |
333 |
353 |
334 /** |
354 /** |
335 * Invoke this method after you've changed how the children identified by |
355 * Invoke this method after you've changed how the children identified by |
336 * childIndicies are to be represented in the tree. |
356 * childIndicies are to be represented in the tree. |
|
357 * |
|
358 * @param node changed node |
|
359 * @param childIndices indexes of changed children |
337 */ |
360 */ |
338 public void nodesChanged(TreeNode node, int[] childIndices) { |
361 public void nodesChanged(TreeNode node, int[] childIndices) { |
339 if(node != null) { |
362 if(node != null) { |
340 if (childIndices != null) { |
363 if (childIndices != null) { |
341 int cCount = childIndices.length; |
364 int cCount = childIndices.length; |
358 |
381 |
359 /** |
382 /** |
360 * Invoke this method if you've totally changed the children of |
383 * Invoke this method if you've totally changed the children of |
361 * node and its children's children... This will post a |
384 * node and its children's children... This will post a |
362 * treeStructureChanged event. |
385 * treeStructureChanged event. |
|
386 * |
|
387 * @param node changed node |
363 */ |
388 */ |
364 public void nodeStructureChanged(TreeNode node) { |
389 public void nodeStructureChanged(TreeNode node) { |
365 if(node != null) { |
390 if(node != null) { |
366 fireTreeStructureChanged(this, getPathToRoot(node), null, null); |
391 fireTreeStructureChanged(this, getPathToRoot(node), null, null); |
367 } |
392 } |
372 * where the original node is the last element in the returned array. |
397 * where the original node is the last element in the returned array. |
373 * The length of the returned array gives the node's depth in the |
398 * The length of the returned array gives the node's depth in the |
374 * tree. |
399 * tree. |
375 * |
400 * |
376 * @param aNode the TreeNode to get the path for |
401 * @param aNode the TreeNode to get the path for |
|
402 * @return an array of TreeNodes giving the path from the root |
377 */ |
403 */ |
378 public TreeNode[] getPathToRoot(TreeNode aNode) { |
404 public TreeNode[] getPathToRoot(TreeNode aNode) { |
379 return getPathToRoot(aNode, 0); |
405 return getPathToRoot(aNode, 0); |
380 } |
406 } |
381 |
407 |