KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jaggenerator > JagTreeModelListener


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 /*
19  * MyTreeModelListener.java
20  *
21  * Created on 16 september 2002, 22:03
22  */

23
24 package com.finalist.jaggenerator;
25
26 import com.finalist.jaggenerator.modules.*;
27
28 import javax.swing.event.*;
29 import javax.swing.tree.*;
30
31 /**
32  *
33  * @author hillie
34  */

35 public class JagTreeModelListener implements TreeModelListener {
36
37    /** Creates a new instance of MyTreeModelListener */
38    public JagTreeModelListener() {
39    }
40
41
42    /** <p>Invoked after a node (or a set of siblings) has changed in some
43     * way. The node(s) have not changed locations in the tree or
44     * altered their children arrays, but other attributes have
45     * changed and may affect presentation. Example: the name of a
46     * file has changed, but it is in the same location in the file
47     * system.</p>
48     * <p>To indicate the root has changed, childIndices and children
49     * will be null. </p>
50     *
51     * <p>Use <code>e.getPath()</code>
52     * to get the parent of the changed node(s).
53     * <code>e.getChildIndices()</code>
54     * returns the index(es) of the changed node(s).</p>
55     *
56     */

57    public void treeNodesChanged(TreeModelEvent e) {
58       DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent());
59       /*
60        * If the event lists children, then the changed
61        * node is the child of the node we've already
62        * gotten. Otherwise, the changed node and the
63        * specified node are the same.
64        */

65       try {
66          int index = e.getChildIndices()[0];
67          node = (DefaultMutableTreeNode) (node.getChildAt(index));
68       }
69       catch (NullPointerException JavaDoc exc) {
70       }
71    }
72
73
74    /** <p>Invoked after nodes have been inserted into the tree.</p>
75     *
76     * <p>Use <code>e.getPath()</code>
77     * to get the parent of the new node(s).
78     * <code>e.getChildIndices()</code>
79     * returns the index(es) of the new node(s)
80     * in ascending order.</p>
81     *
82     */

83    public void treeNodesInserted(TreeModelEvent e) {
84    }
85
86
87    /** <p>Invoked after nodes have been removed from the tree. Note that
88     * if a subtree is removed from the tree, this method may only be
89     * invoked once for the root of the removed subtree, not once for
90     * each individual set of siblings removed.</p>
91     *
92     * <p>Use <code>e.getPath()</code>
93     * to get the former parent of the deleted node(s).
94     * <code>e.getChildIndices()</code>
95     * returns, in ascending order, the index(es)
96     * the node(s) had before being deleted.</p>
97     *
98     */

99    public void treeNodesRemoved(TreeModelEvent e) {
100    }
101
102
103    /** <p>Invoked after the tree has drastically changed structure from a
104     * given node down. If the path returned by e.getPath() is of length
105     * one and the first element does not identify the current root node
106     * the first element should become the new root of the tree.<p>
107     *
108     * <p>Use <code>e.getPath()</code>
109     * to get the path to the node.
110     * <code>e.getChildIndices()</code>
111     * returns null.</p>
112     *
113     */

114    public void treeStructureChanged(TreeModelEvent e) {
115    }
116
117 }
118
Popular Tags