Link Here
|
20 |
|
20 |
|
21 |
import java.awt.Component; |
21 |
import java.awt.Component; |
22 |
import java.awt.HeadlessException; |
22 |
import java.awt.HeadlessException; |
|
|
23 |
import java.awt.event.ActionEvent; |
23 |
import java.io.IOException; |
24 |
import java.io.IOException; |
24 |
import java.io.Serializable; |
25 |
import java.io.Serializable; |
25 |
import java.util.Collection; |
26 |
import java.util.Collection; |
Link Here
|
39 |
import javax.swing.JPopupMenu; |
40 |
import javax.swing.JPopupMenu; |
40 |
import javax.swing.KeyStroke; |
41 |
import javax.swing.KeyStroke; |
41 |
import javax.swing.MenuElement; |
42 |
import javax.swing.MenuElement; |
|
|
43 |
import javax.swing.event.MenuKeyEvent; |
44 |
import javax.swing.event.MenuKeyListener; |
45 |
|
42 |
import org.apache.jmeter.control.Controller; |
46 |
import org.apache.jmeter.control.Controller; |
43 |
import org.apache.jmeter.gui.GuiPackage; |
47 |
import org.apache.jmeter.gui.GuiPackage; |
44 |
import org.apache.jmeter.gui.JMeterGUIComponent; |
48 |
import org.apache.jmeter.gui.JMeterGUIComponent; |
Link Here
|
69 |
* and also for resource lookup in messages.properties |
73 |
* and also for resource lookup in messages.properties |
70 |
*/ |
74 |
*/ |
71 |
public static final String THREADS = "menu_threads"; //$NON-NLS-1$ |
75 |
public static final String THREADS = "menu_threads"; //$NON-NLS-1$ |
72 |
|
76 |
|
73 |
public static final String FRAGMENTS = "menu_fragments"; //$NON-NLS-1$ |
77 |
public static final String FRAGMENTS = "menu_fragments"; //$NON-NLS-1$ |
74 |
|
78 |
|
75 |
public static final String TIMERS = "menu_timer"; //$NON-NLS-1$ |
79 |
public static final String TIMERS = "menu_timer"; //$NON-NLS-1$ |
Link Here
|
123 |
private static final String[] MENU_PARENT_SAMPLER = new String[] { |
127 |
private static final String[] MENU_PARENT_SAMPLER = new String[] { |
124 |
MenuFactory.CONTROLLERS }; |
128 |
MenuFactory.CONTROLLERS }; |
125 |
|
129 |
|
126 |
private static final List<MenuInfo> timers, controllers, samplers, threads, |
130 |
private static final List<MenuInfo> timers, controllers, samplers, threads, |
127 |
fragments,configElements, assertions, listeners, nonTestElements, |
131 |
fragments,configElements, assertions, listeners, nonTestElements, |
128 |
postProcessors, preProcessors; |
132 |
postProcessors, preProcessors; |
129 |
|
133 |
|
Link Here
|
202 |
|
206 |
|
203 |
/** |
207 |
/** |
204 |
* @param menu JPopupMenu |
208 |
* @param menu JPopupMenu |
205 |
* @param addSaveTestFragmentMenu Add Save as Test Fragment menu if true |
209 |
* @param addSaveTestFragmentMenu Add Save as Test Fragment menu if true |
206 |
*/ |
210 |
*/ |
207 |
public static void addFileMenu(JPopupMenu menu, boolean addSaveTestFragmentMenu) { |
211 |
public static void addFileMenu(JPopupMenu menu, boolean addSaveTestFragmentMenu) { |
208 |
// the undo/redo as a standard goes first in Edit menus |
212 |
// the undo/redo as a standard goes first in Edit menus |
Link Here
|
267 |
menu.add(redo); |
271 |
menu.add(redo); |
268 |
} |
272 |
} |
269 |
|
273 |
|
270 |
|
|
|
271 |
public static JMenu makeMenus(String[] categories, String label, String actionCommand) { |
274 |
public static JMenu makeMenus(String[] categories, String label, String actionCommand) { |
272 |
JMenu addMenu = new JMenu(label); |
275 |
JMenu addMenu = new JMenu(label); |
273 |
for (int i = 0; i < categories.length; i++) { |
276 |
for (int i = 0; i < categories.length; i++) { |
Link Here
|
374 |
for (MenuInfo info : menuInfo) { |
377 |
for (MenuInfo info : menuInfo) { |
375 |
menu.add(makeMenuItem(info, actionCommand)); |
378 |
menu.add(makeMenuItem(info, actionCommand)); |
376 |
} |
379 |
} |
|
|
380 |
// Bug 54784: adds listener for the enter and space keys to add items |
381 |
menu.addMenuKeyListener(new MenuKeyListener() { |
382 |
@Override |
383 |
public void menuKeyTyped(MenuKeyEvent e) {} |
384 |
|
385 |
@Override |
386 |
public void menuKeyReleased(MenuKeyEvent e) {} |
387 |
|
388 |
@Override |
389 |
public void menuKeyPressed(MenuKeyEvent e) { |
390 |
if (e.getKeyCode() != KeyStrokes.ENTER.getKeyCode() |
391 |
&& e.getKeyCode() != KeyStrokes.SPACE.getKeyCode()) { |
392 |
return; |
393 |
} |
394 |
// using selectedPath because e.getPath() always returns the |
395 |
// first item in the menu rather than the selected item |
396 |
MenuElement[] selectedPath = e.getMenuSelectionManager().getSelectedPath(); |
397 |
MenuElement source = selectedPath[selectedPath.length - 1]; |
398 |
|
399 |
ActionEvent event = new ActionEvent(source, e.getID(), ActionNames.ADD); |
400 |
ActionRouter.getInstance().actionPerformed(event); |
401 |
// small hack: for some reason the menu doesn't hide when |
402 |
// adding elements that can't contain children, e.g.Counter |
403 |
if (e.getComponent().isShowing()) { |
404 |
e.getComponent().setVisible(false); |
405 |
} |
406 |
e.consume(); |
407 |
} |
408 |
}); |
409 |
// end Bug 54784 change |
377 |
GuiUtils.makeScrollableMenu(menu); |
410 |
GuiUtils.makeScrollableMenu(menu); |
378 |
return menu; |
411 |
return menu; |
379 |
} |
412 |
} |
Link Here
|
435 |
JMenuItem newMenuChoice = new JMenuItem(info.getLabel()); |
468 |
JMenuItem newMenuChoice = new JMenuItem(info.getLabel()); |
436 |
newMenuChoice.setName(info.getClassName()); |
469 |
newMenuChoice.setName(info.getClassName()); |
437 |
newMenuChoice.addActionListener(ActionRouter.getInstance()); |
470 |
newMenuChoice.addActionListener(ActionRouter.getInstance()); |
|
|
471 |
|
438 |
if (actionCommand != null) { |
472 |
if (actionCommand != null) { |
439 |
newMenuChoice.setActionCommand(actionCommand); |
473 |
newMenuChoice.setActionCommand(actionCommand); |
440 |
} |
474 |
} |
Link Here
|
555 |
if (categories.contains(ASSERTIONS)) { |
589 |
if (categories.contains(ASSERTIONS)) { |
556 |
assertions.add(new MenuInfo(item, name)); |
590 |
assertions.add(new MenuInfo(item, name)); |
557 |
} |
591 |
} |
558 |
|
|
|
559 |
} |
592 |
} |
560 |
} catch (IOException e) { |
593 |
} catch (IOException e) { |
561 |
log.error("", e); |
594 |
log.error("", e); |
562 |
- |
|
|