public CheckDirty() { previousGuiItems = new HashMap<>(); ActionRouter.getInstance().addPreActionListener(ExitCommand.class, this); ActionRouter.getInstance().addPostActionListener(UndoCommand.class, this); }
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 0) { ActionRouter.getInstance().doActionNow( new ActionEvent(e.getSource(), e.getID(), ActionNames.LINK_RELEASE_NOTES)); } } });
/** * Handles click on warnIndicator */ @Override public void actionPerformed(ActionEvent event) { if (event.getSource() == warnIndicator) { ActionRouter.getInstance().doActionNow( new ActionEvent(event.getSource(), event.getID(), ActionNames.LOGGER_PANEL_ENABLE_DISABLE)); } }
/** * Called when the main JMeter frame is being closed. Sends a * notification so that JMeter can react appropriately. * * @param event * the WindowEvent to handle */ @Override public void windowClosing(WindowEvent event) { ActionRouter.getInstance().actionPerformed(new ActionEvent(this, event.getID(), ActionNames.EXIT)); } }
/** * Make a menuItem using a fixed label which is also used as the item name. * This is used for items such as recent files and hostnames which are not resources * @param label (this is not used as a resource key) * @param actionCommand * @return the menu item */ private static JMenuItem makeMenuItemNoRes(String label, String actionCommand) { JMenuItem menuItem = new JMenuItem(label); menuItem.setName(label); menuItem.setActionCommand(actionCommand); menuItem.addActionListener(ActionRouter.getInstance()); return menuItem; }
@Override public JMenuItem[] getMenuItemsAtLocation(MENU_LOCATION location) { if(location == MENU_LOCATION.HELP) { JMenuItem menuItemIC = new JMenuItem( JMeterUtils.getResString("export_transactions_menu"), KeyEvent.VK_UNDEFINED); menuItemIC.setName(ExportTransactionAndSamplerNames.EXPORT_NAMES); menuItemIC.setActionCommand(ExportTransactionAndSamplerNames.EXPORT_NAMES); menuItemIC.setAccelerator(null); menuItemIC.addActionListener(ActionRouter.getInstance()); return new JMenuItem[]{menuItemIC}; } return new JMenuItem[0]; }
private static JMenuItem makeMenuItemRes(String resource, int mnemonic, String actionCommand, KeyStroke keyStroke){ JMenuItem menuItem = new JMenuItem(JMeterUtils.getResString(resource), mnemonic); menuItem.setName(resource); menuItem.setActionCommand(actionCommand); menuItem.setAccelerator(keyStroke); menuItem.addActionListener(ActionRouter.getInstance()); return menuItem; }
private JMenuItem createMenuItem(String name, String actionCommand) { JMenuItem addThinkTimesToChildren = new JMenuItem(JMeterUtils.getResString(name)); addThinkTimesToChildren.setName(name); addThinkTimesToChildren.addActionListener(ActionRouter.getInstance()); addThinkTimesToChildren.setActionCommand(actionCommand); return addThinkTimesToChildren; }
@Override public JMenuItem[] getMenuItemsAtLocation(MENU_LOCATION location) { if(location == MENU_LOCATION.FILE) { JMenuItem menuItemIC = new JMenuItem( JMeterUtils.getResString(RESTART), KeyEvent.VK_UNDEFINED); menuItemIC.setName(RESTART); menuItemIC.setActionCommand(RESTART); menuItemIC.setAccelerator(null); menuItemIC.addActionListener(ActionRouter.getInstance()); return new JMenuItem[]{menuItemIC}; } return new JMenuItem[0]; } /**
/** * Create a single menu item * * @param label for the MenuItem * @param name for the MenuItem * @param actionCommand predefined string, e.g. ActionNames.ADD * {@link ActionNames} * @return the menu item */ public static JMenuItem makeMenuItem(String label, String name, String actionCommand) { JMenuItem newMenuChoice = new JMenuItem(label); newMenuChoice.setName(name); newMenuChoice.addActionListener(ActionRouter.getInstance()); if (actionCommand != null) { newMenuChoice.setActionCommand(actionCommand); } return newMenuChoice; }
@Override public void actionPerformed(ActionEvent e) { String[] source = new String[] { Help.HELP_FUNCTIONS, functionList.getText() }; ActionRouter.getInstance().doActionNow( new ActionEvent(source, e.getID(), ActionNames.HELP)); } }
/** * Generate a button component from icon bean * @param iconBean contains I18N key, ActionNames, icon path, optional icon path pressed * @return a button for toolbar */ private static JButton makeButtonItemRes(IconToolbarBean iconBean) throws Exception { final URL imageURL = JMeterUtils.class.getClassLoader().getResource(iconBean.getIconPath()); if (imageURL == null) { throw new Exception("No icon for: " + iconBean.getActionName()); } JButton button = new JButton(new ImageIcon(imageURL)); button.setToolTipText(JMeterUtils.getResString(iconBean.getI18nKey())); final URL imageURLPressed = JMeterUtils.class.getClassLoader().getResource(iconBean.getIconPathPressed()); button.setPressedIcon(new ImageIcon(imageURLPressed)); button.addActionListener(ActionRouter.getInstance()); button.setActionCommand(iconBean.getActionNameResolve()); return button; }
/** * Create a single menu item from the resource name. * * @param resource for the MenuItem * @param actionCommand predefined string, e.g. ActionNames.ADD * {@link ActionNames} * @return the menu item */ public static JMenuItem makeMenuItemRes(String resource, String actionCommand) { JMenuItem newMenuChoice = new JMenuItem(JMeterUtils.getResString(resource)); newMenuChoice.setName(resource); newMenuChoice.addActionListener(ActionRouter.getInstance()); if (actionCommand != null) { newMenuChoice.setActionCommand(actionCommand); } return newMenuChoice; }
@Override public void doAction(ActionEvent ev) { try { String className = ev.getActionCommand().substring(ActionNames.LAF_PREFIX.length()).replace('/', '.'); UIManager.setLookAndFeel(className); JMeterUtils.refreshUI(); PREFS.put(USER_PREFS_KEY, className); int chosenOption = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils .getResString("laf_quit_after_change"), // $NON-NLS-1$ JMeterUtils.getResString("exit"), // $NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (chosenOption == JOptionPane.YES_OPTION) { ActionRouter.getInstance().doActionNow(new ActionEvent(ev.getSource(), ev.getID(), ActionNames.EXIT)); } } catch (UnsupportedLookAndFeelException | InstantiationException | ClassNotFoundException | IllegalAccessException e) { JMeterUtils.reportErrorToUser("Look and Feel unavailable:" + e.toString()); } }
private JMenu createLaFMenu() { JMenu lafMenu = makeMenuRes("appearance", 'L'); for (LookAndFeelInfo laf : getAllLAFs()) { JMenuItem menuItem = new JMenuItem(laf.getName()); menuItem.addActionListener(ActionRouter.getInstance()); menuItem.setActionCommand(ActionNames.LAF_PREFIX + laf.getClassName()); menuItem.setToolTipText(laf.getClassName()); // show the classname to the user lafMenu.add(menuItem); } return lafMenu; }
private static JCheckBoxMenuItem makeCheckBoxMenuItemRes(String resource, String actionCommand, KeyStroke keyStroke){ JCheckBoxMenuItem cbkMenuItem = new JCheckBoxMenuItem(JMeterUtils.getResString(resource)); cbkMenuItem.setName(resource); cbkMenuItem.setActionCommand(actionCommand); cbkMenuItem.setAccelerator(keyStroke); cbkMenuItem.addActionListener(ActionRouter.getInstance()); return cbkMenuItem; } }
/** * Check if we should save before run * * @param e * the event that led to the call of this method */ protected void popupShouldSave(ActionEvent e) { log.debug("popupShouldSave"); if (GuiPackage.getInstance().getTestPlanFile() == null) { if (JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("should_save"), //$NON-NLS-1$ JMeterUtils.getResString("warning"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SAVE)); } } else if (GuiPackage.getInstance().shouldSaveBeforeRun()) { ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SAVE)); } }
/** * Create a single menu item from a MenuInfo object * * @param info the MenuInfo object * @param actionCommand predefined string, e.g. ActionNames.ADD * {@link ActionNames} * @return the menu item */ private static Component makeMenuItem(MenuInfo info, String actionCommand) { if (info instanceof MenuSeparatorInfo) { return new JPopupMenu.Separator(); } JMenuItem newMenuChoice = new JMenuItem(info.getLabel()); newMenuChoice.setName(info.getClassName()); newMenuChoice.setEnabled(info.getEnabled(actionCommand)); newMenuChoice.addActionListener(ActionRouter.getInstance()); if (actionCommand != null) { newMenuChoice.setActionCommand(actionCommand); } return newMenuChoice; }
static void closeProject(ActionEvent e) { GuiPackage guiPackage = GuiPackage.getInstance(); guiPackage.clearTestPlan(); JTree tree = guiPackage.getTreeListener().getJTree(); tree.setSelectionRow(0); FocusRequester.requestFocus(tree); FileServer.getFileServer().setScriptName(null); ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), ActionNames.ADD_ALL)); } }
/** * @see Command#doAction(ActionEvent) */ @Override public void doAction(ActionEvent e) { GuiPackage guiPack = GuiPackage.getInstance(); ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), ActionNames.CHECK_CUT)); JMeterTreeNode[] currentNodes = guiPack.getTreeListener().getSelectedNodes(); currentNodes = Copy.keepOnlyAncestors(currentNodes); Copy.setCopiedNodes(currentNodes); for (JMeterTreeNode currentNode : currentNodes) { guiPack.getTreeModel().removeNodeFromParent(currentNode); } guiPack.getMainFrame().repaint(); } }