KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > tree > TreeModel


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.tree;
14
15 /**
16  * exposes parent/child relationship between objects.
17  *
18  * @author av
19  */

20 public interface TreeModel {
21   
22   public static final TreeModel EMPTY_MODEL = new TreeModel() {
23     public Object JavaDoc[] getRoots() {
24       return new Object JavaDoc[0];
25     }
26     public boolean hasChildren(Object JavaDoc node) {
27       return false;
28     }
29     public Object JavaDoc[] getChildren(Object JavaDoc node) {
30       return null;
31     }
32     public Object JavaDoc getParent(Object JavaDoc node) {
33       return null;
34     }
35     public void addTreeModelChangeListener(TreeModelChangeListener l) {
36     }
37     public void removeTreeModelChangeListener(TreeModelChangeListener l) {
38     }
39     public void fireModelChanged(boolean identityChanged) {
40     }
41   };
42
43   /**
44    * returns the root members of the tree.
45    */

46   Object JavaDoc[] getRoots();
47   
48   /**
49    * @return true if the member can be expanded
50    */

51   boolean hasChildren(Object JavaDoc node);
52   
53   /**
54    * @return the children of the member
55    */

56   Object JavaDoc[] getChildren(Object JavaDoc node);
57   
58   /**
59    * @return the parent of member or null, if this is a root member
60    */

61   Object JavaDoc getParent(Object JavaDoc node);
62   
63   void addTreeModelChangeListener(TreeModelChangeListener l);
64   void removeTreeModelChangeListener(TreeModelChangeListener l);
65
66   
67   /**
68    * fires a TreeModelChangeEvent.
69    * @param identityChanged if true, the identities of the tree nodes
70    * have changed and, for example, the selection will be cleared.
71    */

72   void fireModelChanged(boolean identityChanged);
73 }
74
Popular Tags