Package org.apache.jmeter.gui

Examples of org.apache.jmeter.gui.GuiPackage


        return Arrays.asList(new String[] { MenuFactory.NON_TEST_ELEMENTS });
    }

    @Override
    public void actionPerformed(ActionEvent action) {
        GuiPackage guiPackage = GuiPackage.getInstance();
        JMeterTreeModel treeModel = guiPackage.getTreeModel();
        JMeterTreeNode myTarget = findFirstNodeOfType(org.apache.jmeter.threads.ThreadGroup.class, treeModel);
        if (myTarget == null) {
            JMeterUtils.reportErrorToUser("Cannot find Thread Group");
            return;
        }
View Full Code Here


            return;
        }

        // Check if the user wants to drop any changes
        ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.CHECK_DIRTY));
        GuiPackage guiPackage = GuiPackage.getInstance();
        if (guiPackage.isDirty()) {
            // Check if the user wants to revert
            int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
                    JMeterUtils.getResString("cancel_revert_project"), // $NON-NLS-1$
                    JMeterUtils.getResString("revert_project?")// $NON-NLS-1$
                    JOptionPane.YES_NO_OPTION,
View Full Code Here

    }

    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);
        testTree.traverse(startup); // call ThreadListener.threadStarted()
    }
View Full Code Here

    private void threadFinished(LoopIterationListener iterationListener) {
        ThreadListenerTraverser shut = new ThreadListenerTraverser(false);
        testTree.traverse(shut); // call ThreadListener.threadFinished()
        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
            controller.removeIterationListener(iterationListener);
        }
    }
View Full Code Here

     * @param setDetails if true, then set the file details (if not merging)
     */
    static void loadProjectFile(final ActionEvent e, final File f, final boolean merging, final boolean setDetails) {
        ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.STOP_THREAD));

        final GuiPackage guiPackage = GuiPackage.getInstance();
        if (f != null) {
            InputStream reader = null;
            try {
                    if (merging) {
                        log.info("Merging file: " + f);
                    } else {
                        log.info("Loading file: " + f);
                        // TODO should this be done even if not a full test plan?
                        // and what if load fails?
                        if(setDetails) {
                            FileServer.getFileServer().setBaseForScript(f);
                        }
                    }
                    reader = new FileInputStream(f);
                    final HashTree tree = SaveService.loadTree(reader);
                    final boolean isTestPlan = insertLoadedTree(e.getID(), tree, merging);
   
                    // don't change name if merging
                    if (!merging && isTestPlan && setDetails) {
                        // TODO should setBaseForScript be called here rather than above?
                        guiPackage.setTestPlanFile(f.getAbsolutePath());
                    }
            } catch (NoClassDefFoundError ex) {// Allow for missing optional jars
                reportError("Missing jar file", ex, true);
            } catch (ConversionException ex) {
                log.warn("Could not convert file "+ex);
                JMeterUtils.reportErrorToUser(SaveService.CEtoString(ex));
            } catch (IOException ex) {
                reportError("Error reading file: ", ex, false);
            } catch (Exception ex) {
                reportError("Unexpected error", ex, true);
            } finally {
                JOrphanUtils.closeQuietly(reader);
            }
            guiPackage.updateCurrentGui();
            guiPackage.getMainFrame().repaint();
        }
    }
View Full Code Here

            throw new IllegalUserActionException("Empty TestPlan - see log file");
        }
        final boolean isTestPlan = tree.getArray()[0] instanceof TestPlan;

        // If we are loading a new test plan, initialize the tree with the testplan node we are loading
        final GuiPackage guiInstance = GuiPackage.getInstance();
        if(isTestPlan && !merging) {
            // Why does this not call guiInstance.clearTestPlan() ?
            // Is there a reason for not clearing everything?
            guiInstance.clearTestPlan((TestElement)tree.getArray()[0]);
        }

        if (merging){ // Check if target of merge is reasonable
            final TestElement te = (TestElement)tree.getArray()[0];
            if (!(te instanceof WorkBench || te instanceof TestPlan)){// These are handled specially by addToTree
                final boolean ok = MenuFactory.canAddTo(guiInstance.getCurrentNode(), te);
                if (!ok){
                    String name = te.getName();
                    String className = te.getClass().getName();
                    className = className.substring(className.lastIndexOf('.')+1);
                    throw new IllegalUserActionException("Can't merge "+name+" ("+className+") here");
                }
            }
        }
        final HashTree newTree = guiInstance.addSubTree(tree);
        guiInstance.updateCurrentGui();
        guiInstance.getMainFrame().getTree().setSelectionPath(
                new TreePath(((JMeterTreeNode) newTree.getArray()[0]).getPath()));
        final HashTree subTree = guiInstance.getCurrentSubTree();
        // Send different event wether we are merging a test plan into another test plan,
        // or loading a testplan from scratch
        ActionEvent actionEvent =
            new ActionEvent(subTree.get(subTree.getArray()[subTree.size() - 1]), id,
                    merging ? ActionNames.SUB_TREE_MERGED : ActionNames.SUB_TREE_LOADED);

        ActionRouter.getInstance().actionPerformed(actionEvent);
        final JTree jTree = guiInstance.getMainFrame().getTree();
        if (expandTree && !merging) { // don't automatically expand when merging
            for(int i = 0; i < jTree.getRowCount(); i++) {
                jTree.expandRow(i);
            }
        } else {
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.jmeter.gui.action.AbstractAction#doAction(java.awt.event.ActionEvent)
     */
    @Override
    public void doAction(ActionEvent e) {
        GuiPackage instance = GuiPackage.getInstance();
        List<Stoppable> stopables = instance.getStoppables();
        for (Stoppable element : stopables) {
            instance.unregister(element);
            element.stopServer();
        }
    }
View Full Code Here

     * @see RemoteThreadsListener#threadStarted()
     */
    @Override
    public void threadStarted() {
        JMeterContextService.incrNumberOfThreads();
        GuiPackage gp =GuiPackage.getInstance();
        if (gp != null) {// check there is a GUI
            gp.getMainFrame().updateCounts();
        }
        for (RemoteThreadsLifeCycleListener listener : listeners) {
            listener.threadNumberIncreased(JMeterContextService.getNumberOfThreads());
        }
    }
View Full Code Here

     * @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());
        }
    }
View Full Code Here

        return ok;
    }

    private static void moveAndSelectNode(JMeterTreeNode currentNode,
            JMeterTreeNode parentNode, int newIndx) {
        GuiPackage guiInstance = GuiPackage.getInstance();
        guiInstance.getTreeModel().removeNodeFromParent(currentNode);
        guiInstance.getTreeModel().insertNodeInto(currentNode, parentNode,
                newIndx);

        // select the node
        TreeNode[] nodes = guiInstance.getTreeModel()
                .getPathToRoot(currentNode);
        JTree jTree = guiInstance.getMainFrame().getTree();
        jTree.setSelectionPath(new TreePath(nodes));
    }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.gui.GuiPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.