View Javadoc

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   *     Copyright 2004 Stephen Cowx
23   *
24   *     Licensed under the Apache License, Version 2.0 (the "License");
25   *     you may not use this file except in compliance with the License.
26   *     You may obtain a copy of the License at
27   *
28   *     http://www.apache.org/licenses/LICENSE-2.0
29   *
30   *     Unless required by applicable law or agreed to in writing, software
31   *     distributed under the License is distributed on an "AS IS" BASIS,
32   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33   *     See the License for the specific language governing permissions and
34   *     limitations under the License.
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 }