Source code: javatools/awt/event/TreeReloadEvent.java
1 /*
2 * TreeReloadEvent.java
3 *
4 * Created on 5 gennaio 2003, 19.08
5 Javatools (modified version) - Some useful general classes.
6 Copyright (C) 2002-2003 Chris Bitmead (original) Antonio Petrelli (modified)
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program 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
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Contact me at: brenmcguire@users.sourceforge.net
23 */
24
25 package javatools.awt.event;
26
27 /** Event to manage a tree reload.
28 * @author Antonio Petrelli
29 * @version 0.1.8
30 */
31 public class TreeReloadEvent extends java.awt.AWTEvent implements java.awt.ActiveEvent {
32
33 /**
34 * Marks the first integer id for the range of invocation event ids.
35 */
36 public static final int INVOCATION_FIRST = 1200;
37
38 /**
39 * The default id for all InvocationEvents.
40 */
41 public static final int INVOCATION_DEFAULT = INVOCATION_FIRST;
42
43 /**
44 * Marks the last integer id for the range of invocation event ids.
45 */
46 public static final int INVOCATION_LAST = INVOCATION_DEFAULT;
47
48 /** Creates a new instance of TreeReloadEvent
49 * @param source The object that generated the event.
50 * @param pTree The tree to be reloaded.
51 * @param pNode The node to be reloaded.
52 */
53 public TreeReloadEvent(Object source, javax.swing.JTree pTree, javax.swing.tree.TreeNode pNode) {
54 super(source, INVOCATION_DEFAULT);
55 tree = pTree;
56 node = pNode;
57 }
58
59 /** Creates a new instance of TreeReloadEvent
60 * @param source The object that generated the event.
61 * @param pTree The tree to be reloaded.
62 */
63 public TreeReloadEvent(Object source, javax.swing.JTree pTree) {
64 super(source, INVOCATION_DEFAULT);
65 tree = pTree;
66 node = null;
67 }
68
69 /** Dispatches the event.
70 */
71 public void dispatch() {
72 if (node != null) {
73 ((javax.swing.tree.DefaultTreeModel) tree.getModel()).reload(node);
74 }
75 else
76 ((javax.swing.tree.DefaultTreeModel) tree.getModel()).reload();
77 }
78
79 private javax.swing.JTree tree;
80 private javax.swing.tree.TreeNode node;
81 }