01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.struct;
25:
26: import jacareto.system.Environment;
27:
28: import java.awt.Insets;
29:
30: import javax.swing.JTree;
31: import javax.swing.event.TreeExpansionEvent;
32: import javax.swing.event.TreeWillExpandListener;
33: import javax.swing.tree.ExpandVetoException;
34:
35: /**
36: * The tree of a structure.
37: *
38: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
39: * @version 1.0
40: */
41: public class StructureTree extends JTree implements
42: TreeWillExpandListener {
43: /** The env. */
44: Environment env;
45:
46: /**
47: * Creates a new structure tree for a given structure.
48: *
49: * @param env the environment
50: * @param structure the structure to create the tree for
51: */
52: public StructureTree(Environment env, Structure structure) {
53: super (structure);
54: this .env = env;
55:
56: setCellRenderer(new StructureTreeCellRenderer(env));
57: addTreeWillExpandListener(this );
58: }
59:
60: /**
61: * Returns the insets.
62: *
63: * @return the insets.
64: */
65: public Insets getInsets() {
66: return new Insets(5, 5, 5, 5);
67: }
68:
69: // Tree expansion listener methods
70:
71: /**
72: * Called when a path has been collapsed.
73: *
74: * @param event the event.
75: *
76: * @throws ExpandVetoException DOCUMENT ME!
77: */
78: public void treeWillCollapse(TreeExpansionEvent event)
79: throws ExpandVetoException {
80: if (event.getPath().getLastPathComponent() instanceof RootElement) {
81: throw new ExpandVetoException(event);
82: }
83: }
84:
85: /**
86: * Called when a path has been expanded.
87: *
88: * @param event the event.
89: */
90: public void treeWillExpand(TreeExpansionEvent event) {
91: }
92: }
|