1 package com.explosion.datastream.exql.gui;
2
3 import java.awt.event.MouseEvent;
4 import java.util.Hashtable;
5 import java.util.Vector;
6
7 import javax.swing.JTree;
8 import javax.swing.tree.TreeModel;
9 import javax.swing.tree.TreeNode;
10
11 import com.explosion.datastream.exql.EXQLConstants;
12 import com.explosion.expf.Application;
13 import com.explosion.expf.ExpFrame;
14 import com.explosion.expf.menusandtools.menu.MenuHelper;
15 import com.explosion.expf.menusandtools.menu.popup.ExpPopupIntercepter;
16 import com.explosion.expf.menusandtools.menu.popup.ExpPopupableMenu;
17 import com.explosion.expf.menusandtools.menu.segmented.ExpMenuSegment;
18 import com.explosion.utilities.exception.ExceptionManagerFactory;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 /***
40 * @author Stephen Cowx
41 * Created on 31-Mar-2005
42 * This is mainly so I can intercept and interpert the popup requests
43 */
44 public class ExqlTree extends JTree implements ExpPopupIntercepter
45 {
46 private ExpPopupableMenu menu;
47 private EXQLBaseTool tool;
48
49 /***
50 *
51 */
52 public ExqlTree() {
53 super();
54 }
55 /***
56 * @param value
57 */
58 public ExqlTree(Object[] value) {
59 super(value);
60 }
61 /***
62 * @param value
63 */
64 public ExqlTree(Hashtable value) {
65 super(value);
66 }
67 /***
68 * @param value
69 */
70 public ExqlTree(Vector value) {
71 super(value);
72 }
73 /***
74 * @param newModel
75 */
76 public ExqlTree(TreeModel newModel) {
77 super(newModel);
78 }
79 /***
80 * @param root
81 */
82 public ExqlTree(TreeNode root, EXQLBaseTool tool) {
83 super(root);
84 this.tool = tool;
85 }
86 /***
87 * @param root
88 * @param asksAllowsChildren
89 */
90 public ExqlTree(TreeNode root, boolean asksAllowsChildren) {
91 super(root, asksAllowsChildren);
92 }
93
94 /***
95 * Pops up a popup menu
96 * @param event
97 */
98 public void popupEvent(MouseEvent event) {
99 try
100 {
101 menu = new ExpPopupableMenu();
102 MenuHelper menuHelper = new MenuHelper(((ExpFrame)Application.getApplicationFrame()).getListener());
103
104 ExpMenuSegment segment = menu.createNewSegment(ExpMenuSegment.ANY_POSITION);
105 segment.addElement(menuHelper.createMenuItem("Refresh", 'r', EXQLConstants.MENU_REFRESH, null, 1));
106 segment.addElement(menuHelper.createMenuItem("Run script", 's', EXQLConstants.MENU_RUNSCRIPT, null, 1));
107 menuHelper.checkEnabled();
108 menu.show(event);
109 }
110 catch (Exception e)
111 {
112 ExceptionManagerFactory.getExceptionManager().manageException(e,"Exception caught while handling popupEvent");
113 }
114 }
115 }