01: /*
02: *
03: * (c) Copyright 2004 - 2007 osbl development team.
04: *
05: * This file is part of the osbl (http://osbl.wilken.de).
06: *
07: * the osbl is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.osbl.client.wings.navigation;
15:
16: import org.wings.event.SMouseListener;
17: import org.wings.event.SMouseEvent;
18: import org.wings.STree;
19:
20: import javax.swing.*;
21: import javax.swing.tree.DefaultMutableTreeNode;
22: import java.awt.event.ActionEvent;
23:
24: /**
25: * @author hengels
26: * @version $Revision: 1.4 $
27: */
28: public class NavigationListener implements SMouseListener {
29: public void mouseClicked(SMouseEvent e) {
30: STree tree = (STree) e.getSource();
31: int row = tree.rowAtPoint(e.getPoint());
32: DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
33: .getPathForRow(row).getLastPathComponent();
34: Object userObject = node.getUserObject();
35: if (userObject instanceof Action) {
36: Action action = (Action) userObject;
37: action
38: .actionPerformed(new ActionEvent(
39: this ,
40: 0,
41: (String) action
42: .getValue(Action.ACTION_COMMAND_KEY)));
43: }
44:
45: e.consume();
46: }
47: }
|