01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.him.swing.resourcetree.formresourcetree;
20:
21: import javax.swing.event.*;
22: import javax.swing.tree.*;
23:
24: import org.openharmonise.him.swing.resourcetree.TreeNode;
25:
26: /**
27: * Mouse listener for {@link org.openharmonise.him.swing.resourcetree.formresourcetree.FormResourceTree}.
28: *
29: * @author Matthew Large
30: * @version $Revision: 1.1 $
31: *
32: */
33: public class FormTreeMouseListener extends DefaultTreeSelectionModel
34: implements TreeSelectionListener, TreeSelectionModel {
35:
36: /**
37: * Tree to listen to.
38: */
39: private FormResourceTree m_tree;
40:
41: /**
42: * Re-entry check.
43: */
44: private boolean m_bReEntryStop = false;
45:
46: /**
47: * Constructs a new form tree mouse listener.
48: *
49: * @param tree tree to listen to.
50: */
51: public FormTreeMouseListener(FormResourceTree tree) {
52: super ();
53: this .m_tree = tree;
54: }
55:
56: /* (non-Javadoc)
57: * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
58: */
59: public void valueChanged(TreeSelectionEvent tse) {
60: if (!m_bReEntryStop) {
61: TreeNode node = (TreeNode) tse.getPath()
62: .getLastPathComponent();
63: FormTreeCell cell = this .m_tree.getCellForPath(node
64: .getFilePath());
65: if (cell.isEnabled()) {
66: cell.mouseClicked(null);
67: m_bReEntryStop = true;
68: this .clearSelection();
69: m_bReEntryStop = false;
70: }
71: }
72: }
73: }
|