01: /*
02: * The contents of this file are subject to the Mozilla Public License
03: * Version 1.1 (the "License"); you may not use this file except in
04: * compliance with the License. You may obtain a copy of the License at
05: * 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. See the
09: * License for the specific language governing rights and limitations
10: * under the License.
11: *
12: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
13: *
14: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
15: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
16: *
17: * Contributor(s):
18: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
19: *
20: * If you didn't download this code from the following link, you should check
21: * if you aren't using an obsolete version: http://www.isqlviewer.com
22: */
23: package org.isqlviewer.ui.listeners;
24:
25: import java.awt.event.ActionEvent;
26: import java.awt.event.MouseEvent;
27: import java.awt.event.MouseListener;
28:
29: import javax.swing.JTree;
30: import javax.swing.tree.TreePath;
31:
32: import org.isqlviewer.bookmarks.BookmarkReference;
33: import org.isqlviewer.swing.SwingUtilities;
34: import org.isqlviewer.swing.action.SharedActions;
35: import org.isqlviewer.swing.action.SwingEventManager;
36:
37: /**
38: * TODO Add BookmarkMouseInputListener JavaDoc inforamation
39: * <p>
40: *
41: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
42: * @version 1.0
43: */
44: public class BookmarkMouseInputListener implements MouseListener {
45:
46: private JTree bookmarkView = null;
47: private SwingEventManager eventManager = null;
48:
49: public BookmarkMouseInputListener(JTree bookmarkView,
50: SwingEventManager manager) {
51:
52: this .bookmarkView = bookmarkView;
53: this .eventManager = manager;
54: }
55:
56: public void mouseClicked(MouseEvent e) {
57:
58: handleInput(e);
59: }
60:
61: public void mouseEntered(MouseEvent e) {
62:
63: }
64:
65: public void mouseExited(MouseEvent e) {
66:
67: }
68:
69: public void mousePressed(MouseEvent e) {
70:
71: }
72:
73: public void mouseReleased(MouseEvent e) {
74:
75: }
76:
77: private void handleInput(MouseEvent e) {
78:
79: int clickCount = e.getClickCount();
80: if (clickCount == 2 && !e.isPopupTrigger()) {
81: TreePath path = bookmarkView.getSelectionPath();
82: if (path != null
83: && path.getLastPathComponent() instanceof BookmarkReference) {
84: eventManager.actionPerformed(new ActionEvent(
85: bookmarkView, SharedActions.EDIT_BOOKMARK, ""));
86: } else if (path == null) {
87: SwingUtilities.beep();
88: }
89: }
90: }
91:
92: }
|