Search in sources :

Example 6 with GuiPackage

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

the class UndoCommand method doAction.

@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
    GuiPackage guiPackage = GuiPackage.getInstance();
    final String command = e.getActionCommand();
    if (command.equals(ActionNames.UNDO)) {
        guiPackage.goInHistory(-1);
    } else if (command.equals(ActionNames.REDO)) {
        guiPackage.goInHistory(1);
    } else {
        throw new IllegalArgumentException("Wrong action called: " + command);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 7 with GuiPackage

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

the class Remove method doAction.

@Override
public void doAction(ActionEvent e) {
    int isConfirm = SKIP_CONFIRM ? JOptionPane.YES_OPTION : JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), // $NON-NLS-1$
    JMeterUtils.getResString("remove_confirm_msg"), // $NON-NLS-1$
    JMeterUtils.getResString("remove_confirm_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (isConfirm == JOptionPane.YES_OPTION) {
        // TODO - removes the nodes from the CheckDirty map - should it be done later, in case some can't be removed?
        ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), ActionNames.CHECK_REMOVE));
        GuiPackage guiPackage = GuiPackage.getInstance();
        JMeterTreeNode[] nodes = guiPackage.getTreeListener().getSelectedNodes();
        // Save parent node for later
        TreePath newTreePath = guiPackage.getTreeListener().removedSelectedNode();
        for (int i = nodes.length - 1; i >= 0; i--) {
            removeNode(nodes[i]);
        }
        guiPackage.getTreeListener().getJTree().setSelectionPath(newTreePath);
        guiPackage.updateCurrentGui();
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) ActionEvent(java.awt.event.ActionEvent) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 8 with GuiPackage

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

the class ResetSearchCommand method doAction.

/**
     * @see Command#doAction(ActionEvent)
     */
@Override
public void doAction(ActionEvent e) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
    for (JMeterTreeNode jMeterTreeNode : jMeterTreeModel.getNodesOfType(Searchable.class)) {
        if (jMeterTreeNode.getUserObject() instanceof Searchable) {
            List<JMeterTreeNode> matchingNodes = jMeterTreeNode.getPathToThreadGroup();
            for (JMeterTreeNode jMeterTreeNode2 : matchingNodes) {
                jMeterTreeNode2.setMarkedBySearch(false);
            }
        }
    }
    GuiPackage.getInstance().getMainFrame().repaint();
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) Searchable(org.apache.jmeter.gui.Searchable)

Example 9 with GuiPackage

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

the class GuiLogEventAppender method append.

@Override
public void append(LogEvent logEvent) {
    // Note: GuiPackage class access SHOULD be always successful.
    //       For example, if it fails to get GuiPackage#getInstance() due to static member initialization failure
    //       (e.g, accessing JMeterUtils#getPropDefault(...) without initializing application properties),
    //       the error log can be detected as "Recursive call to appender ..." by Log4j2 LoggerControl,
    //       resulting in no meaningful error logs in the log appender targets.
    GuiPackage instance = GuiPackage.getInstance();
    if (instance != null) {
        final String serializedString = getStringLayout().toSerializable(logEvent);
        if (serializedString != null && !serializedString.isEmpty()) {
            LogEventObject logEventObject = new LogEventObject(logEvent, serializedString);
            instance.getLogEventBus().postEvent(logEventObject);
        }
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage)

Example 10 with GuiPackage

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

the class JMeterTreeModel method addComponent.

/**
     * Add a {@link TestElement} to a {@link JMeterTreeNode}
     * @param component The {@link TestElement} to be used as data for the newly created node
     * @param node The {@link JMeterTreeNode} into which the newly created node is to be inserted
     * @return new {@link JMeterTreeNode} for the given <code>component</code>
     * @throws IllegalUserActionException
     *             when the user object for the <code>node</code> is not an instance
     *             of {@link AbstractConfigGui}
     */
public JMeterTreeNode addComponent(TestElement component, JMeterTreeNode node) throws IllegalUserActionException {
    if (node.getUserObject() instanceof AbstractConfigGui) {
        throw new IllegalUserActionException("This node cannot hold sub-elements");
    }
    GuiPackage guiPackage = GuiPackage.getInstance();
    if (guiPackage != null) {
        // The node can be added in non GUI mode at startup
        guiPackage.updateCurrentNode();
        JMeterGUIComponent guicomp = guiPackage.getGui(component);
        guicomp.clearGui();
        guicomp.configure(component);
        guicomp.modifyTestElement(component);
        // put the gui object back
        guiPackage.getCurrentGui();
    // to the way it was.
    }
    JMeterTreeNode newNode = new JMeterTreeNode(component, this);
    // disable the loaded node
    try {
        newNode.setEnabled(component.isEnabled());
    } catch (Exception e) {
        // TODO - can this ever happen?
        newNode.setEnabled(true);
    }
    this.insertNodeInto(newNode, node, node.getChildCount());
    return newNode;
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) AbstractConfigGui(org.apache.jmeter.config.gui.AbstractConfigGui)

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