Lines 18-24
Link Here
|
18 |
|
18 |
|
19 |
package org.apache.jmeter.gui.tree; |
19 |
package org.apache.jmeter.gui.tree; |
20 |
|
20 |
|
|
|
21 |
import java.awt.Component; |
21 |
import java.awt.Container; |
22 |
import java.awt.Container; |
|
|
23 |
import java.awt.Point; |
24 |
import java.awt.Rectangle; |
22 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionEvent; |
23 |
import java.awt.event.ActionListener; |
26 |
import java.awt.event.ActionListener; |
24 |
import java.awt.event.InputEvent; |
27 |
import java.awt.event.InputEvent; |
Lines 44-51
import org.apache.log.Logger;
Link Here
|
44 |
public class JMeterTreeListener implements TreeSelectionListener, MouseListener, KeyListener { |
47 |
public class JMeterTreeListener implements TreeSelectionListener, MouseListener, KeyListener { |
45 |
private static final Logger log = LoggingManager.getLoggerForClass(); |
48 |
private static final Logger log = LoggingManager.getLoggerForClass(); |
46 |
|
49 |
|
47 |
// Container endWindow; |
|
|
48 |
// JPopupMenu pop; |
49 |
private TreePath currentPath; |
50 |
private TreePath currentPath; |
50 |
|
51 |
|
51 |
private ActionListener actionHandler; |
52 |
private ActionListener actionHandler; |
Lines 145-153
public class JMeterTreeListener implements TreeSelectionListener, MouseListener,
Link Here
|
145 |
log.debug("value changed, updating currentPath"); |
146 |
log.debug("value changed, updating currentPath"); |
146 |
currentPath = e.getNewLeadSelectionPath(); |
147 |
currentPath = e.getNewLeadSelectionPath(); |
147 |
// Call requestFocusInWindow to ensure current component loses focus and |
148 |
// Call requestFocusInWindow to ensure current component loses focus and |
148 |
// all values are correctly saved |
149 |
// all values are correctly saved. See Bug IDs 55103 and 55459. |
149 |
// see https://issues.apache.org/bugzilla/show_bug.cgi?id=55103 |
|
|
150 |
// see https://issues.apache.org/bugzilla/show_bug.cgi?id=55459 |
151 |
tree.requestFocusInWindow(); |
150 |
tree.requestFocusInWindow(); |
152 |
actionHandler.actionPerformed(new ActionEvent(this, 3333, ActionNames.EDIT)); // $NON-NLS-1$ |
151 |
actionHandler.actionPerformed(new ActionEvent(this, 3333, ActionNames.EDIT)); // $NON-NLS-1$ |
153 |
} |
152 |
} |
Lines 177-184
public class JMeterTreeListener implements TreeSelectionListener, MouseListener,
Link Here
|
177 |
currentPath = tree.getPathForLocation(e.getX(), e.getY()); |
176 |
currentPath = tree.getPathForLocation(e.getX(), e.getY()); |
178 |
} |
177 |
} |
179 |
if (selRow != -1) { |
178 |
if (selRow != -1) { |
180 |
// updateMainMenu(((JMeterGUIComponent) |
|
|
181 |
// getCurrentNode().getUserObject()).createPopupMenu()); |
182 |
if (isRightClick(e)) { |
179 |
if (isRightClick(e)) { |
183 |
if (tree.getSelectionCount() < 2) { |
180 |
if (tree.getSelectionCount() < 2) { |
184 |
tree.setSelectionPath(currentPath); |
181 |
tree.setSelectionPath(currentPath); |
Lines 189-236
public class JMeterTreeListener implements TreeSelectionListener, MouseListener,
Link Here
|
189 |
} |
186 |
} |
190 |
} |
187 |
} |
191 |
|
188 |
|
192 |
|
|
|
193 |
@Override |
189 |
@Override |
194 |
public void mouseExited(MouseEvent ev) { |
190 |
public void mouseExited(MouseEvent e) { |
195 |
} |
191 |
} |
196 |
|
192 |
|
197 |
@Override |
193 |
@Override |
198 |
public void keyPressed(KeyEvent e) { |
194 |
public void keyPressed(KeyEvent e) { |
199 |
if (KeyStrokes.matches(e,KeyStrokes.COPY)) { |
195 |
String actionName = null; |
200 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
196 |
|
201 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.COPY)); |
197 |
if (KeyStrokes.matches(e, KeyStrokes.COPY)) { |
202 |
e.consume(); |
198 |
actionName = ActionNames.COPY; |
203 |
} else if (KeyStrokes.matches(e,KeyStrokes.PASTE)) { |
199 |
} else if (KeyStrokes.matches(e, KeyStrokes.PASTE)) { |
204 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
200 |
actionName = ActionNames.PASTE; |
205 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.PASTE)); |
201 |
} else if (KeyStrokes.matches(e, KeyStrokes.CUT)) { |
206 |
e.consume(); |
202 |
actionName = ActionNames.CUT; |
207 |
} else if (KeyStrokes.matches(e,KeyStrokes.CUT)) { |
203 |
} else if (KeyStrokes.matches(e, KeyStrokes.DUPLICATE)) { |
208 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
204 |
actionName = ActionNames.DUPLICATE; |
209 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.CUT)); |
205 |
} else if (KeyStrokes.matches(e, KeyStrokes.ALT_UP_ARROW)) { |
210 |
e.consume(); |
206 |
actionName = ActionNames.MOVE_UP; |
211 |
} else if (KeyStrokes.matches(e,KeyStrokes.DUPLICATE)) { |
207 |
} else if (KeyStrokes.matches(e, KeyStrokes.ALT_DOWN_ARROW)) { |
212 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
208 |
actionName = ActionNames.MOVE_DOWN; |
213 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.DUPLICATE)); |
209 |
} else if (KeyStrokes.matches(e, KeyStrokes.ALT_LEFT_ARROW)) { |
214 |
e.consume(); |
210 |
actionName = ActionNames.MOVE_LEFT; |
215 |
} else if (KeyStrokes.matches(e,KeyStrokes.ALT_UP_ARROW)) { |
211 |
} else if (KeyStrokes.matches(e, KeyStrokes.ALT_RIGHT_ARROW)) { |
216 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
212 |
actionName = ActionNames.MOVE_RIGHT; |
217 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.MOVE_UP)); |
213 |
} else if (KeyStrokes.matches(e, KeyStrokes.SHIFT_F10_CONTEXT_MENU) |
218 |
e.consume(); |
214 |
|| KeyStrokes.matches(e, KeyStrokes.CONTEXT_MENU)) { |
219 |
} else if (KeyStrokes.matches(e,KeyStrokes.ALT_DOWN_ARROW)) { |
215 |
// Bug 54784 |
220 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
216 |
displayPopupMenu(e); |
221 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.MOVE_DOWN)); |
217 |
} |
222 |
e.consume(); |
218 |
|
223 |
} else if (KeyStrokes.matches(e,KeyStrokes.ALT_LEFT_ARROW)) { |
219 |
if (actionName != null) { |
224 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
220 |
final ActionRouter actionRouter = ActionRouter.getInstance(); |
225 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.MOVE_LEFT)); |
221 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), actionName)); |
226 |
e.consume(); |
|
|
227 |
} else if (KeyStrokes.matches(e,KeyStrokes.ALT_RIGHT_ARROW)) { |
228 |
ActionRouter actionRouter = ActionRouter.getInstance(); |
229 |
actionRouter.doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.MOVE_RIGHT)); |
230 |
e.consume(); |
222 |
e.consume(); |
231 |
} |
223 |
} |
232 |
} |
224 |
} |
233 |
|
225 |
|
|
|
226 |
private void displayPopupMenu(KeyEvent e) { |
227 |
Component invoker = e.getComponent(); |
228 |
TreePath path = new TreePath(getCurrentNode().getPath()); |
229 |
Rectangle r = getJTree().getPathBounds(path); |
230 |
int padding = 5; |
231 |
Point point = new Point(r.x + padding, r.y + padding); |
232 |
JPopupMenu popup = getCurrentNode().createPopupMenu(); |
233 |
GuiPackage.getInstance().displayPopUp(invoker, point, popup); |
234 |
} |
235 |
|
234 |
@Override |
236 |
@Override |
235 |
public void keyReleased(KeyEvent e) { |
237 |
public void keyReleased(KeyEvent e) { |
236 |
} |
238 |
} |