View | Details | Raw Unified | Return to bug 54784
Collapse All | Expand All

(-)src/core/org/apache/jmeter/gui/tree/JMeterTreeListener.java (-1 / +18 lines)
Lines 18-23 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;
22
import java.awt.Rectangle;
21
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionListener;
24
import java.awt.event.ActionListener;
23
import java.awt.event.InputEvent;
25
import java.awt.event.InputEvent;
Lines 30-35 Link Here
30
import javax.swing.JTree;
32
import javax.swing.JTree;
31
import javax.swing.event.TreeSelectionEvent;
33
import javax.swing.event.TreeSelectionEvent;
32
import javax.swing.event.TreeSelectionListener;
34
import javax.swing.event.TreeSelectionListener;
35
import javax.swing.tree.TreeNode;
33
import javax.swing.tree.TreePath;
36
import javax.swing.tree.TreePath;
34
37
35
import org.apache.jmeter.gui.GuiPackage;
38
import org.apache.jmeter.gui.GuiPackage;
Lines 210-216 Link Here
210
            actionName = ActionNames.COLLAPSE;
213
            actionName = ActionNames.COLLAPSE;
211
        } else if (KeyStrokes.matches(e, KeyStrokes.SHIFT_RIGHT_ARROW)) {
214
        } else if (KeyStrokes.matches(e, KeyStrokes.SHIFT_RIGHT_ARROW)) {
212
            actionName = ActionNames.EXPAND;
215
            actionName = ActionNames.EXPAND;
213
        } 
216
        } else if (KeyStrokes.matches(e, KeyStrokes.CONTEXT_MENU) ||
217
                KeyStrokes.matches(e, KeyStrokes.SHIFT_F10)) {
218
            displayPopUp(e);
219
        }
214
        
220
        
215
        if (actionName != null) {
221
        if (actionName != null) {
216
            final ActionRouter actionRouter = ActionRouter.getInstance();
222
            final ActionRouter actionRouter = ActionRouter.getInstance();
Lines 231-236 Link Here
231
        return e.isPopupTrigger() || (InputEvent.BUTTON2_MASK & e.getModifiers()) > 0 || (InputEvent.BUTTON3_MASK == e.getModifiers());
237
        return e.isPopupTrigger() || (InputEvent.BUTTON2_MASK & e.getModifiers()) > 0 || (InputEvent.BUTTON3_MASK == e.getModifiers());
232
    }
238
    }
233
239
240
    private void displayPopUp(KeyEvent e) {
241
        JMeterTreeNode currentNode = getCurrentNode();
242
        JPopupMenu pop = currentNode.createPopupMenu();
243
244
        TreeNode[] path = currentNode.getPath();
245
        Rectangle rectangle = tree.getPathBounds(new TreePath(path));
246
        GuiPackage.getInstance().displayPopUp((Component) e.getSource(),
247
                rectangle.x + rectangle.width / 2,
248
                rectangle.y + rectangle.height / 2, pop);
249
    }
250
234
    private void displayPopUp(MouseEvent e) {
251
    private void displayPopUp(MouseEvent e) {
235
        JPopupMenu pop = getCurrentNode().createPopupMenu();
252
        JPopupMenu pop = getCurrentNode().createPopupMenu();
236
        GuiPackage.getInstance().displayPopUp(e, pop);
253
        GuiPackage.getInstance().displayPopUp(e, pop);
(-)src/core/org/apache/jmeter/gui/action/KeyStrokes.java (-1 / +4 lines)
Lines 76-81 Link Here
76
    public static final KeyStroke CUT               = KeyStroke.getKeyStroke(KeyEvent.VK_X, CONTROL_MASK);
76
    public static final KeyStroke CUT               = KeyStroke.getKeyStroke(KeyEvent.VK_X, CONTROL_MASK);
77
    public static final KeyStroke REMOTE_STOP_ALL   = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_DOWN_MASK);
77
    public static final KeyStroke REMOTE_STOP_ALL   = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_DOWN_MASK);
78
    public static final KeyStroke REMOTE_SHUT_ALL   = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.ALT_DOWN_MASK);
78
    public static final KeyStroke REMOTE_SHUT_ALL   = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.ALT_DOWN_MASK);
79
    public static final KeyStroke CONTEXT_MENU      = KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0);
80
    public static final KeyStroke SHIFT_F10         = KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.SHIFT_DOWN_MASK);
79
81
80
    public static final KeyStroke REMOVE            = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
82
    public static final KeyStroke REMOVE            = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
81
    public static final KeyStroke ACTION_STOP       = KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, CONTROL_MASK);
83
    public static final KeyStroke ACTION_STOP       = KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, CONTROL_MASK);
Lines 110-116 Link Here
110
     * @return true if event matches the keystroke definition
112
     * @return true if event matches the keystroke definition
111
     */
113
     */
112
    public static boolean matches(KeyEvent e, KeyStroke k){
114
    public static boolean matches(KeyEvent e, KeyStroke k){
113
        final int modifiersEx = e.getModifiersEx()  | e.getModifiers();// Hack to get full modifier value
115
        final int modifiersEx = (e.getModifiersEx() | e.getModifiers()) & // Hack to get full modifier value
116
                ~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON1_DOWN_MASK); // In case of using virtual keyboard on screen
114
        return e.getKeyCode() == k.getKeyCode() && modifiersEx == k.getModifiers();
117
        return e.getKeyCode() == k.getKeyCode() && modifiersEx == k.getModifiers();
115
    }
118
    }
116
}
119
}
(-)src/core/org/apache/jmeter/gui/action/ActionNames.java (+2 lines)
Lines 114-119 Link Here
114
    public static final String VALIDATE_TG      = "validate_tg"; //$NON-NLS-1$
114
    public static final String VALIDATE_TG      = "validate_tg"; //$NON-NLS-1$
115
    public static final String ZOOM_IN          = "zoom_in"; //$NON-NLS-1$
115
    public static final String ZOOM_IN          = "zoom_in"; //$NON-NLS-1$
116
    public static final String ZOOM_OUT         = "zoom_out"; //$NON-NLS-1$
116
    public static final String ZOOM_OUT         = "zoom_out"; //$NON-NLS-1$
117
    public static final String ENTER            = "enter"; // $NON-NLS-1$
118
    public static final String CONTEXT_MENU     = "context_menu"; // $NON-NLS-1$
117
119
118
    // Prevent instantiation
120
    // Prevent instantiation
119
    private ActionNames() {}
121
    private ActionNames() {}
(-)src/core/org/apache/jmeter/gui/GuiPackage.java (-2 / +19 lines)
Lines 631-641 Link Here
631
     *            the popup menu to display
631
     *            the popup menu to display
632
     */
632
     */
633
    public void displayPopUp(Component invoker, MouseEvent e, JPopupMenu popup) {
633
    public void displayPopUp(Component invoker, MouseEvent e, JPopupMenu popup) {
634
        displayPopUp(invoker, e.getX(), e.getY(), popup);
635
    }
636
637
    /**
638
     * Display the specified popup menu at the location specified
639
     * with the specified source component.
640
     *
641
     * @param invoker
642
     *            the source component
643
     * @param x
644
     *            the x coordinate this popup to be displayed
645
     * @param y
646
     *            the y coordinate this popup to be displayed
647
     * @param popup
648
     *            the popup menu to display
649
     */
650
    public void displayPopUp(Component invoker, int x, int y, JPopupMenu popup) {
634
        if (popup != null) {
651
        if (popup != null) {
635
            log.debug("Showing pop up for {} at x,y = {},{}", invoker, e.getX(), e.getY());
652
            log.debug("Showing pop up for {} at x,y = {},{}", invoker, x, y);
636
653
637
            popup.pack();
654
            popup.pack();
638
            popup.show(invoker, e.getX(), e.getY());
655
            popup.show(invoker, x, y);
639
            popup.setVisible(true);
656
            popup.setVisible(true);
640
            popup.requestFocusInWindow();
657
            popup.requestFocusInWindow();
641
        }
658
        }

Return to bug 54784