use of org.apache.jmeter.gui.tree.JMeterTreeListener in project jmeter by apache.
the class JMeter method startGui.
/**
* Starts up JMeter in GUI mode
*/
private void startGui(String testFile) {
//NOSONAR
System.out.println("================================================================================");
//NOSONAR
System.out.println("Don't use GUI mode for load testing, only for Test creation and Test debugging !");
//NOSONAR
System.out.println("For load testing, use NON GUI Mode:");
//NOSONAR
System.out.println(" jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]");
//NOSONAR
System.out.println("& adapt Java Heap to your test requirements:");
//NOSONAR
System.out.println(" Modify HEAP=\"-Xms512m -Xmx512m\" in the JMeter batch file");
//NOSONAR
System.out.println("================================================================================");
SplashScreen splash = new SplashScreen();
splash.showScreen();
String jMeterLaf = LookAndFeelCommand.getJMeterLaf();
try {
UIManager.setLookAndFeel(jMeterLaf);
} catch (Exception ex) {
log.warn("Could not set LAF to: {}", jMeterLaf, ex);
}
splash.setProgress(10);
JMeterUtils.applyHiDPIOnFonts();
PluginManager.install(this, true);
JMeterTreeModel treeModel = new JMeterTreeModel();
splash.setProgress(30);
JMeterTreeListener treeLis = new JMeterTreeListener(treeModel);
final ActionRouter instance = ActionRouter.getInstance();
instance.populateCommandMap();
splash.setProgress(60);
treeLis.setActionHandler(instance);
GuiPackage.initInstance(treeLis, treeModel);
splash.setProgress(80);
MainFrame main = new MainFrame(treeModel, treeLis);
splash.setProgress(100);
ComponentUtil.centerComponentInWindow(main, 80);
main.setVisible(true);
instance.actionPerformed(new ActionEvent(main, 1, ActionNames.ADD_ALL));
if (testFile != null) {
try {
File f = new File(testFile);
log.info("Loading file: {}", f);
FileServer.getFileServer().setBaseForScript(f);
HashTree tree = SaveService.loadTree(f);
GuiPackage.getInstance().setTestPlanFile(f.getAbsolutePath());
Load.insertLoadedTree(1, tree);
} catch (ConversionException e) {
log.error("Failure loading test file", e);
JMeterUtils.reportErrorToUser(SaveService.CEtoString(e));
} catch (Exception e) {
log.error("Failure loading test file", e);
JMeterUtils.reportErrorToUser(e.toString());
}
} else {
JTree jTree = GuiPackage.getInstance().getMainFrame().getTree();
TreePath path = jTree.getPathForRow(0);
jTree.setSelectionPath(path);
FocusRequester.requestFocus(jTree);
}
splash.setProgress(100);
splash.close();
}
use of org.apache.jmeter.gui.tree.JMeterTreeListener in project jmeter by apache.
the class Start method doAction.
@Override
public void doAction(ActionEvent e) {
if (e.getActionCommand().equals(ActionNames.ACTION_START)) {
popupShouldSave(e);
startEngine(false);
} else if (e.getActionCommand().equals(ActionNames.ACTION_START_NO_TIMERS)) {
popupShouldSave(e);
startEngine(true);
} else if (e.getActionCommand().equals(ActionNames.ACTION_STOP)) {
if (engine != null) {
log.info("Stopping test");
GuiPackage.getInstance().getMainFrame().showStoppingMessage("");
engine.stopTest();
}
} else if (e.getActionCommand().equals(ActionNames.ACTION_SHUTDOWN)) {
if (engine != null) {
log.info("Shutting test down");
GuiPackage.getInstance().getMainFrame().showStoppingMessage("");
engine.askThreadsToStop();
}
} else if (e.getActionCommand().equals(ActionNames.RUN_TG) || e.getActionCommand().equals(ActionNames.RUN_TG_NO_TIMERS) || e.getActionCommand().equals(ActionNames.VALIDATE_TG)) {
popupShouldSave(e);
boolean noTimers = e.getActionCommand().equals(ActionNames.RUN_TG_NO_TIMERS);
boolean isValidation = e.getActionCommand().equals(ActionNames.VALIDATE_TG);
JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
JMeterTreeNode[] nodes = treeListener.getSelectedNodes();
nodes = Copy.keepOnlyAncestors(nodes);
AbstractThreadGroup[] tg = keepOnlyThreadGroups(nodes);
if (nodes.length > 0) {
startEngine(noTimers, isValidation, tg);
} else {
log.warn("No thread group selected the test will not be started");
}
}
}
use of org.apache.jmeter.gui.tree.JMeterTreeListener in project jmeter by apache.
the class Move method doAction.
/**
* @see Command#doAction(ActionEvent)
*/
@Override
public void doAction(ActionEvent e) {
JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
if (treeListener.getSelectedNodes().length != 1) {
// we can only move a single node
return;
}
JMeterTreeNode currentNode = treeListener.getCurrentNode();
JMeterTreeNode parentNode = getParentNode(currentNode);
if (parentNode != null) {
String action = e.getActionCommand();
int index = parentNode.getIndex(currentNode);
if (ActionNames.MOVE_UP.equals(action)) {
if (index > 0) {
// we stay within the same parent node
int newIndx = index - 1;
moveAndSelectNode(currentNode, parentNode, newIndx);
}
} else if (ActionNames.MOVE_DOWN.equals(action)) {
if (index < parentNode.getChildCount() - 1) {
// we stay within the same parent node
int newIndx = index + 1;
moveAndSelectNode(currentNode, parentNode, newIndx);
}
} else if (ActionNames.MOVE_LEFT.equals(action)) {
JMeterTreeNode parentParentNode = getParentNode(parentNode);
// move to the parent
if (parentParentNode != null && canAddTo(parentParentNode, currentNode)) {
moveAndSelectNode(currentNode, parentParentNode, parentParentNode.getIndex(parentNode));
}
} else if (ActionNames.MOVE_RIGHT.equals(action)) {
JMeterTreeNode after = (JMeterTreeNode) parentNode.getChildAfter(currentNode);
if (after != null && canAddTo(after, currentNode)) {
// move as a child of the next sibling
moveAndSelectNode(currentNode, after, 0);
}
// Commented as per sebb
// http://mail-archives.apache.org/mod_mbox/jmeter-dev/201307.mbox/%3CCAOGo0VZ0z3GMbfsq_gSB%2Bp7nTUqLng6Gy2ecvYbD8_AKb-Dt5w%40mail.gmail.com%3E
/*
else {
// move as a sibling of the parent
JMeterTreeNode parentParentNode = getParentNode(parentNode);
after = (JMeterTreeNode) parentParentNode
.getChildAfter(parentNode);
if (after != null
&& canAddTo(parentParentNode, currentNode)) {
moveAndSelectNode(currentNode, parentParentNode,
parentParentNode.getIndex(after));
}
}
*/
}
}
GuiPackage.getInstance().getMainFrame().repaint();
}
use of org.apache.jmeter.gui.tree.JMeterTreeListener in project jmeter by apache.
the class CollapseExpandTreeBranch method doAction.
/**
* This method performs the actual command processing.
*
* @param e the generic UI action event
*/
@Override
public void doAction(ActionEvent e) {
JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
JTree jTree = GuiPackage.getInstance().getMainFrame().getTree();
JMeterTreeNode[] selectedNodes = treeListener.getSelectedNodes();
for (JMeterTreeNode currentNode : selectedNodes) {
if (!currentNode.isLeaf()) {
TreeNode[] nodes = GuiPackage.getInstance().getTreeModel().getPathToRoot(currentNode);
TreePath path = new TreePath(nodes);
boolean collapse = ActionNames.COLLAPSE.equals(e.getActionCommand());
expandCollapseNode(jTree, path, collapse);
}
}
}
use of org.apache.jmeter.gui.tree.JMeterTreeListener in project jmeter by apache.
the class Copy method doAction.
@Override
public void doAction(ActionEvent e) {
JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
JMeterTreeNode[] nodes = treeListener.getSelectedNodes();
nodes = keepOnlyAncestors(nodes);
nodes = cloneTreeNodes(nodes);
setCopiedNodes(nodes);
}
Aggregations