01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package com.artenum.so6.dataflow.util;
34:
35: import java.awt.event.MouseEvent;
36: import java.awt.event.MouseListener;
37: import java.awt.event.MouseMotionListener;
38:
39: import javax.swing.JPopupMenu;
40:
41: /**
42: * @author Sebastien
43: */
44: public class So6PopupMenu extends JPopupMenu implements
45: MouseMotionListener, MouseListener {
46: private Object mouseListener;
47:
48: public So6PopupMenu(Object mouseListener) {
49: this .mouseListener = mouseListener;
50: }
51:
52: private boolean maybeShowPopup(MouseEvent e) {
53: if (e.isPopupTrigger()) {
54: show(e.getComponent(), e.getX(), e.getY());
55:
56: return true;
57: }
58:
59: return false;
60: }
61:
62: public void mouseDragged(MouseEvent e) {
63: ((MouseMotionListener) mouseListener).mouseDragged(e);
64: }
65:
66: public void mouseMoved(MouseEvent e) {
67: ((MouseMotionListener) mouseListener).mouseMoved(e);
68: }
69:
70: public void mouseClicked(MouseEvent e) {
71: ((MouseListener) mouseListener).mouseClicked(e);
72: }
73:
74: public void mouseEntered(MouseEvent e) {
75: ((MouseListener) mouseListener).mouseEntered(e);
76: }
77:
78: public void mouseExited(MouseEvent e) {
79: ((MouseListener) mouseListener).mouseExited(e);
80: }
81:
82: public void mousePressed(MouseEvent e) {
83: if (!maybeShowPopup(e)) {
84: ((MouseListener) mouseListener).mousePressed(e);
85: }
86: }
87:
88: public void mouseReleased(MouseEvent e) {
89: if (!maybeShowPopup(e)) {
90: ((MouseListener) mouseListener).mouseReleased(e);
91: }
92: }
93: }
|