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