01: /*
02: Copyright (c) 2003 eInnovation Inc. All rights reserved
03:
04: This library is free software; you can redistribute it and/or modify it under the terms
05: of the GNU Lesser General Public License as published by the Free Software Foundation;
06: either version 2.1 of the License, or (at your option) any later version.
07:
08: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
09: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: See the GNU Lesser General Public License for more details.
11: */
12:
13: package com.openedit.webui.tree;
14:
15: import java.util.List;
16:
17: /**
18: * This is the model for a <code>{@link WebTree}</code>.
19: *
20: * @author Eric Galluzzo
21: */
22: public interface WebTreeModel {
23: /**
24: * Returns the child of <code>parent</code> at index <code>index</code> in the parent's child
25: * array. <code>parent</code> must be a node previously obtained from this data source. This
26: * should not return <code>null</code> if <code>index</code> is a valid index for
27: * <code>parent</code> (that is <code>index >= 0 && index <
28: * getChildCount(parent)</code>).
29: *
30: * @param parent A node in the tree, obtained from this data source
31: *
32: * @return The child of <code>parent</code> at index <code>index</code>
33: */
34: public Object getChild(Object parent, int index);
35:
36: public List getChildren(Object parent);
37:
38: public List getChildrenInRows(Object inParent, int inColCount);
39:
40: /**
41: * Returns the number of children of <code>parent</code>. Returns 0 if the node is a leaf or
42: * if it has no children. <code>parent</code> must be a node previously obtained from this
43: * data source.
44: *
45: * @param parent A node in the tree, obtained from this data source
46: *
47: * @return The number of children of the node <code>parent</code>
48: */
49: public int getChildCount(Object parent);
50:
51: /**
52: * Returns the index of <code>child</code> in <code>parent</code>. If <code>parent</code> is
53: * <code>null</code> or <code>child</code> is <code>null</code>, returns -1.
54: *
55: * @param parent A node in the tree, obtained from this data source
56: * @param child The node we are interested in
57: *
58: * @return The index of the child in the parent, or -1 if either <code>child</code> or
59: * <code>parent</code> is <code>null</code>
60: */
61: public int getIndexOfChild(Object parent, Object child);
62:
63: /**
64: * Returns <code>true</code> if <code>node</code> is a leaf. It is possible for this method to
65: * return <code>false</code> even if <code>node</code> has no children. A directory in a
66: * filesystem, for example, may contain no files; the node representing the directory is not a
67: * leaf, but it also has no children.
68: *
69: * @param node A node in the tree, obtained from this data source
70: *
71: * @return <code>true</code> if <code>node</code> is a leaf
72: */
73: public boolean isLeaf(Object node);
74:
75: /**
76: * Returns the root of the tree. Returns <code>null</code> only if the tree has no nodes.
77: *
78: * @return the root of the tree
79: */
80: public Object getRoot();
81:
82: /**
83: * Returns a unique ID for the given node. This ID should be unique
84: * throughout the tree.
85: *
86: * @param inNode The node
87: *
88: * @return The node's ID
89: */
90: public String getId(Object inNode);
91:
92: public Object getParent(Object inNode);
93:
94: public Object getChildById(String inId);
95: }
|