Search in sources :

Example 16 with GuiPackage

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

the class EnableComponent method toggleComponents.

private void toggleComponents(JMeterTreeNode[] nodes) {
    GuiPackage pack = GuiPackage.getInstance();
    for (JMeterTreeNode node : nodes) {
        boolean enable = !node.isEnabled();
        node.setEnabled(enable);
        pack.getGui(node.getTestElement()).setEnabled(enable);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 17 with GuiPackage

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

the class EnableComponent method enableComponents.

private void enableComponents(JMeterTreeNode[] nodes, boolean enable) {
    GuiPackage pack = GuiPackage.getInstance();
    for (JMeterTreeNode node : nodes) {
        node.setEnabled(enable);
        pack.getGui(node.getTestElement()).setEnabled(enable);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 18 with GuiPackage

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

the class JMeterUtils method reportErrorToUser.

/**
     * Report an error through a dialog box in GUI mode 
     * or in logs and stdout in Non GUI mode
     *
     * @param errorMsg - the error message.
     * @param titleMsg - title string
     * @param exception Exception
     */
public static void reportErrorToUser(String errorMsg, String titleMsg, Exception exception) {
    if (errorMsg == null) {
        errorMsg = "Unknown error - see log file";
        log.warn("Unknown error", new Throwable("errorMsg == null"));
    }
    GuiPackage instance = GuiPackage.getInstance();
    if (instance == null) {
        if (exception != null) {
            log.error(errorMsg, exception);
        } else {
            log.error(errorMsg);
        }
        // NOSONAR intentional
        System.out.println(errorMsg);
        // Done
        return;
    }
    try {
        JOptionPane.showMessageDialog(instance.getMainFrame(), errorMsg, titleMsg, JOptionPane.ERROR_MESSAGE);
    } catch (HeadlessException e) {
        log.warn("reportErrorToUser(\"" + errorMsg + "\") caused", e);
    }
}
Also used : HeadlessException(java.awt.HeadlessException) GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 19 with GuiPackage

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

the class AddParent method addParentToTree.

protected void addParentToTree(TestElement newParent) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeNode newNode = new JMeterTreeNode(newParent, guiPackage.getTreeModel());
    JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
    JMeterTreeNode parentNode = (JMeterTreeNode) currentNode.getParent();
    int index = parentNode.getIndex(currentNode);
    guiPackage.getTreeModel().insertNodeInto(newNode, parentNode, index);
    JMeterTreeNode[] nodes = guiPackage.getTreeListener().getSelectedNodes();
    for (JMeterTreeNode node : nodes) {
        moveNode(guiPackage, node, newNode);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 20 with GuiPackage

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

the class AddThinkTimeBetweenEachStep method doAction.

@Override
public void doAction(ActionEvent e) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
    if (!(currentNode.getUserObject() instanceof Controller || currentNode.getUserObject() instanceof ThreadGroup)) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }
    try {
        addThinkTimeToChildren(guiPackage, currentNode);
    } catch (Exception err) {
        Toolkit.getDefaultToolkit().beep();
        log.error("Failed to add think times", err);
        JMeterUtils.reportErrorToUser("Failed to add think times", err);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) ThreadGroup(org.apache.jmeter.threads.ThreadGroup) Controller(org.apache.jmeter.control.Controller) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

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