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);
}
}
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();
}
}
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();
}
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);
}
}
}
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;
}
Aggregations