Search in sources :

Example 1 with GuiPackage

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

the class ModuleController method restoreSelected.

private void restoreSelected() {
    GuiPackage gp = GuiPackage.getInstance();
    if (gp != null) {
        JMeterTreeNode root = (JMeterTreeNode) gp.getTreeModel().getRoot();
        resolveReplacementSubTree(root);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 2 with GuiPackage

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

the class ModuleControllerGui method expandToSelectNode.

/**
     * @param selected JMeterTreeNode tree node to expand
     */
protected void expandToSelectNode(JMeterTreeNode selected) {
    GuiPackage guiInstance = GuiPackage.getInstance();
    JTree jTree = guiInstance.getMainFrame().getTree();
    jTree.expandPath(new TreePath(selected.getPath()));
    selected.setMarkedBySearch(true);
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 3 with GuiPackage

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

the class SearchTreeDialog method doSearch.

/**
     * @param e {@link ActionEvent}
     */
private void doSearch(ActionEvent e) {
    boolean expand = e.getSource() == searchAndExpandButton;
    String wordToSearch = searchTF.getText();
    if (StringUtils.isEmpty(wordToSearch)) {
        return;
    } else {
        this.lastSearch = wordToSearch;
    }
    // reset previous result
    ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SEARCH_RESET));
    // do search
    Searcher searcher = null;
    if (isRegexpCB.isSelected()) {
        searcher = new RegexpSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
    } else {
        searcher = new RawTextSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
    }
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
    Set<JMeterTreeNode> nodes = new HashSet<>();
    int numberOfMatches = 0;
    for (JMeterTreeNode jMeterTreeNode : jMeterTreeModel.getNodesOfType(Searchable.class)) {
        try {
            Searchable searchable = (Searchable) jMeterTreeNode.getUserObject();
            List<JMeterTreeNode> matchingNodes = jMeterTreeNode.getPathToThreadGroup();
            List<String> searchableTokens = searchable.getSearchableTokens();
            boolean result = searcher.search(searchableTokens);
            if (result) {
                numberOfMatches++;
                nodes.addAll(matchingNodes);
            }
        } catch (Exception ex) {
            logger.error("Error occurred searching for word:" + wordToSearch + " in node:" + jMeterTreeNode.getName(), ex);
        }
    }
    GuiPackage guiInstance = GuiPackage.getInstance();
    JTree jTree = guiInstance.getMainFrame().getTree();
    for (JMeterTreeNode jMeterTreeNode : nodes) {
        jMeterTreeNode.setMarkedBySearch(true);
        if (expand) {
            jTree.expandPath(new TreePath(jMeterTreeNode.getPath()));
        }
    }
    GuiPackage.getInstance().getMainFrame().repaint();
    searchTF.requestFocusInWindow();
    statusLabel.setText(MessageFormat.format(JMeterUtils.getResString("search_tree_matches"), new Object[] { numberOfMatches }));
}
Also used : ActionEvent(java.awt.event.ActionEvent) JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) Searchable(org.apache.jmeter.gui.Searchable) HashSet(java.util.HashSet)

Example 4 with GuiPackage

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

the class Start method startEngine.

/**
     * Start JMeter engine
     * @param ignoreTimer flag to ignore timers
     * @param isValidationShot 
     * @param threadGroupsToRun Array of AbstractThreadGroup to run
     */
private void startEngine(boolean ignoreTimer, boolean isValidationShot, AbstractThreadGroup[] threadGroupsToRun) {
    GuiPackage gui = GuiPackage.getInstance();
    HashTree testTree = gui.getTreeModel().getTestPlan();
    JMeter.convertSubTree(testTree);
    if (threadGroupsToRun != null && threadGroupsToRun.length > 0) {
        removeThreadGroupsFromHashTree(testTree, threadGroupsToRun);
    }
    testTree.add(testTree.getArray()[0], gui.getMainFrame());
    if (log.isDebugEnabled()) {
        log.debug("test plan before cloning is running version: {}", ((TestPlan) testTree.getArray()[0]).isRunningVersion());
    }
    ListedHashTree clonedTree = null;
    if (isValidationShot) {
        TreeCloner cloner = createTreeClonerForValidation();
        testTree.traverse(cloner);
        clonedTree = cloner.getClonedTree();
    } else {
        TreeCloner cloner = cloneTree(testTree, ignoreTimer);
        clonedTree = cloner.getClonedTree();
    }
    if (popupCheckExistingFileListener(testTree)) {
        engine = new StandardJMeterEngine();
        engine.configure(clonedTree);
        try {
            engine.runTest();
        } catch (JMeterEngineException e) {
            JOptionPane.showMessageDialog(gui.getMainFrame(), e.getMessage(), JMeterUtils.getResString("error_occurred"), //$NON-NLS-1$
            JOptionPane.ERROR_MESSAGE);
        }
        if (log.isDebugEnabled()) {
            log.debug("test plan after cloning and running test is running version: {}", ((TestPlan) testTree.getArray()[0]).isRunningVersion());
        }
    }
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) HashTree(org.apache.jorphan.collections.HashTree) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) StandardJMeterEngine(org.apache.jmeter.engine.StandardJMeterEngine) GuiPackage(org.apache.jmeter.gui.GuiPackage) TreeCloner(org.apache.jmeter.engine.TreeCloner) JMeterEngineException(org.apache.jmeter.engine.JMeterEngineException)

Example 5 with GuiPackage

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

the class StopStoppables method doAction.

/* (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();
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) Stoppable(org.apache.jmeter.gui.Stoppable)

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