Search in sources :

Example 41 with GuiPackage

use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.

the class SelectTemplatesDialog method checkDirtyAndLoad.

/**
     * Check if existing Test Plan has been modified and ask user 
     * what he wants to do if test plan is dirty
     * @param actionEvent {@link ActionEvent}
     */
private void checkDirtyAndLoad(final ActionEvent actionEvent) throws HeadlessException {
    final String selectedTemplate = templateList.getText();
    final Template template = TemplateManager.getInstance().getTemplateByName(selectedTemplate);
    if (template == null) {
        return;
    }
    final boolean isTestPlan = template.isTestPlan();
    // Check if the user wants to drop any changes
    if (isTestPlan) {
        ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.CHECK_DIRTY));
        GuiPackage guiPackage = GuiPackage.getInstance();
        if (guiPackage.isDirty()) {
            // Check if the user wants to create from template
            int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), // $NON-NLS-1$
            JMeterUtils.getResString("cancel_new_from_template"), // $NON-NLS-1$
            JMeterUtils.getResString("template_load?"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.SAVE));
            }
            if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.CANCEL_OPTION) {
                // Don't clear the plan
                return;
            }
        }
    }
    ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.STOP_THREAD));
    final File parent = template.getParent();
    final File fileToCopy = parent != null ? new File(parent, template.getFileName()) : new File(JMeterUtils.getJMeterHome(), template.getFileName());
    Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false);
    this.setVisible(false);
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) Template(org.apache.jmeter.gui.action.template.Template)

Example 42 with GuiPackage

use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.

the class JMeterThread method threadFinished.

private void threadFinished(LoopIterationListener iterationListener) {
    ThreadListenerTraverser shut = new ThreadListenerTraverser(false);
    // call ThreadListener.threadFinished()
    testTree.traverse(shut);
    JMeterContextService.decrNumberOfThreads();
    threadGroup.decrNumberOfThreads();
    GuiPackage gp = GuiPackage.getInstance();
    if (gp != null) {
        // check there is a GUI
        gp.getMainFrame().updateCounts();
    }
    if (iterationListener != null) {
        // probably not possible, but check anyway
        threadGroupLoopController.removeIterationListener(iterationListener);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 43 with GuiPackage

use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.

the class JMeterThread method threadStarted.

private void threadStarted() {
    JMeterContextService.incrNumberOfThreads();
    threadGroup.incrNumberOfThreads();
    GuiPackage gp = GuiPackage.getInstance();
    if (gp != null) {
        // check there is a GUI
        gp.getMainFrame().updateCounts();
    }
    ThreadListenerTraverser startup = new ThreadListenerTraverser(true);
    // call ThreadListener.threadStarted()
    testTree.traverse(startup);
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 44 with GuiPackage

use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.

the class RemoteThreadsListenerImpl method threadFinished.

/* (non-Javadoc)
     * @see org.apache.jmeter.samplers.RemoteThreadsListener#threadFinished()
     */
@Override
public void threadFinished() {
    JMeterContextService.decrNumberOfThreads();
    GuiPackage gp = GuiPackage.getInstance();
    if (gp != null) {
        // check there is a GUI
        gp.getMainFrame().updateCounts();
    }
    for (RemoteThreadsLifeCycleListener listener : listeners) {
        listener.threadNumberDecreased(JMeterContextService.getNumberOfThreads());
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 45 with GuiPackage

use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.

the class JMeterMenuBar method makeOptionsMenu.

private void makeOptionsMenu() {
    // OPTIONS MENU
    //$NON-NLS-1$
    optionsMenu = makeMenuRes("option", 'O');
    //$NON-NLS-1$
    JMenuItem functionHelper = makeMenuItemRes("function_dialog_menu_item", 'F', ActionNames.FUNCTIONS, KeyStrokes.FUNCTIONS);
    //$NON-NLS-1$
    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());
        // show the classname to the user
        menuItem.setToolTipText(laf.getClassName());
        lafMenu.add(menuItem);
    }
    optionsMenu.add(functionHelper);
    optionsMenu.add(lafMenu);
    //$NON-NLS-1$
    JCheckBoxMenuItem menuLoggerPanel = makeCheckBoxMenuItemRes("menu_logger_panel", ActionNames.LOGGER_PANEL_ENABLE_DISABLE);
    GuiPackage guiInstance = GuiPackage.getInstance();
    if (guiInstance != null) {
        //avoid error in ant task tests (good way?)
        guiInstance.setMenuItemLoggerPanel(menuLoggerPanel);
    }
    optionsMenu.add(menuLoggerPanel);
    //$NON-NLS-1$
    JMenu menuLoggerLevel = makeMenuRes("menu_logger_level");
    JMenuItem menuItem;
    String levelString;
    for (Level level : Level.values()) {
        levelString = level.toString();
        menuItem = new JMenuItem(levelString);
        menuItem.addActionListener(ActionRouter.getInstance());
        menuItem.setActionCommand(ActionNames.LOG_LEVEL_PREFIX + levelString);
        // show the classname to the user
        menuItem.setToolTipText(levelString);
        menuLoggerLevel.add(menuItem);
    }
    optionsMenu.add(menuLoggerLevel);
    if (SSLManager.isSSLSupported()) {
        //$NON-NLS-1$
        sslManager = makeMenuItemRes("sslmanager", 'S', ActionNames.SSL_MANAGER, KeyStrokes.SSL_MANAGER);
        optionsMenu.add(sslManager);
    }
    optionsMenu.add(makeLanguageMenu());
    //$NON-NLS-1$
    JMenuItem collapse = makeMenuItemRes("menu_collapse_all", ActionNames.COLLAPSE_ALL, KeyStrokes.COLLAPSE_ALL);
    optionsMenu.add(collapse);
    //$NON-NLS-1$
    JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL);
    optionsMenu.add(expand);
    //$NON-NLS-1$
    JMenuItem zoomIn = makeMenuItemRes("menu_zoom_in", ActionNames.ZOOM_IN);
    optionsMenu.add(zoomIn);
    //$NON-NLS-1$
    JMenuItem zoomOut = makeMenuItemRes("menu_zoom_out", ActionNames.ZOOM_OUT);
    optionsMenu.add(zoomOut);
    addPluginsMenuItems(optionsMenu, menuCreators, MENU_LOCATION.OPTIONS);
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) GuiPackage(org.apache.jmeter.gui.GuiPackage) Level(org.slf4j.event.Level) JMenuItem(javax.swing.JMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JMenu(javax.swing.JMenu)

Aggregations

GuiPackage (org.apache.jmeter.gui.GuiPackage)49 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)21 ActionEvent (java.awt.event.ActionEvent)9 JTree (javax.swing.JTree)8 TreePath (javax.swing.tree.TreePath)7 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)6 TestElement (org.apache.jmeter.testelement.TestElement)5 HashTree (org.apache.jorphan.collections.HashTree)5 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)4 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)4 Controller (org.apache.jmeter.control.Controller)3 Searchable (org.apache.jmeter.gui.Searchable)3 Component (java.awt.Component)2 File (java.io.File)2 HashSet (java.util.HashSet)2 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)2 ConversionException (com.thoughtworks.xstream.converters.ConversionException)1 HeadlessException (java.awt.HeadlessException)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1