1 package org.apache.jmeter.module.actions; 2 3 import javax.swing.JMenu ; 4 import javax.swing.JMenuItem ; 5 import javax.swing.JPopupMenu ; 6 import javax.swing.MenuElement ; 7 import org.apache.jmeter.module.cookies.JMeterCookie; 8 import org.apache.jmeter.module.integration.JMeterIntegrationEngine; 9 import org.openide.nodes.Node; 10 import org.openide.util.HelpCtx; 11 import org.openide.util.NbBundle; 12 import org.openide.util.Utilities; 13 import org.openide.util.actions.CookieAction; 14 import org.openide.util.actions.Presenter; 15 16 public final class JMeterSpecificAction extends CookieAction implements Presenter.Popup { 17 18 protected void performAction(Node[] activatedNodes) { 19 } 22 23 protected int mode() { 24 return CookieAction.MODE_EXACTLY_ONE; 25 } 26 27 public String getName() { 28 return NbBundle.getMessage(JMeterSpecificAction.class, "CTL_JMeterSpecificAction"); 29 } 30 31 protected Class [] cookieClasses() { 32 return new Class [] { 33 JMeterCookie.class 34 }; 35 } 36 37 protected void initialize() { 38 super.initialize(); 39 putValue("noIconInMenu", Boolean.TRUE); 41 } 42 43 public HelpCtx getHelpCtx() { 44 return HelpCtx.DEFAULT_HELP; 45 } 46 47 protected boolean asynchronous() { 48 return false; 49 } 50 51 public JMenuItem getPopupPresenter() { 52 JMenu retValue = new JMenu (getName()); 53 54 Node[] nodes = getActivatedNodes(); 55 try { 56 if (nodes.length > 0) { 57 JMeterCookie cookie = (JMeterCookie)nodes[0].getCookie(JMeterCookie.class); 58 JPopupMenu menu = JMeterIntegrationEngine.getDefault().getElementMenu(cookie.getElement()); 59 60 boolean submenuAdded = false; 61 for(MenuElement submenu : menu.getSubElements()) { 62 if (submenu instanceof JMenu ) { 63 retValue.add(submenu.getComponent()); 64 submenuAdded = true; 65 } 66 } 67 68 if (!submenuAdded) { 69 return null; 70 } 71 } 72 } catch (Exception e) { 73 e.printStackTrace(); 74 } 75 return retValue; 78 } 79 } 80 81 | Popular Tags |