use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class CheckDirty method doAction.
/**
* @see Command#doAction(ActionEvent)
*/
@Override
public void doAction(ActionEvent e) {
String action = e.getActionCommand();
if (action.equals(ActionNames.SUB_TREE_SAVED)) {
HashTree subTree = (HashTree) e.getSource();
subTree.traverse(this);
} else if (action.equals(ActionNames.SUB_TREE_LOADED)) {
ListedHashTree addTree = (ListedHashTree) e.getSource();
addTree.traverse(this);
} else if (action.equals(ActionNames.ADD_ALL)) {
previousGuiItems.clear();
GuiPackage.getInstance().getTreeModel().getTestPlan().traverse(this);
if (isWorkbenchSaveable()) {
GuiPackage.getInstance().getTreeModel().getWorkBench().traverse(this);
}
} else if (action.equals(ActionNames.CHECK_REMOVE)) {
GuiPackage guiPackage = GuiPackage.getInstance();
JMeterTreeNode[] nodes = guiPackage.getTreeListener().getSelectedNodes();
removeMode = true;
try {
for (int i = nodes.length - 1; i >= 0; i--) {
guiPackage.getTreeModel().getCurrentSubTree(nodes[i]).traverse(this);
}
} finally {
removeMode = false;
}
}
// If we are merging in another test plan, we know the test plan is dirty now
if (action.equals(ActionNames.SUB_TREE_MERGED)) {
dirty = true;
} else {
dirty = false;
checkMode = true;
try {
HashTree wholeTree = GuiPackage.getInstance().getTreeModel().getTestPlan();
wholeTree.traverse(this);
// check the workbench for modification
if (!dirty) {
// NOSONAR
if (isWorkbenchSaveable()) {
HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
workbench.traverse(this);
}
}
} finally {
checkMode = false;
}
}
GuiPackage.getInstance().setDirty(dirty);
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class Close method closeProject.
static void closeProject(ActionEvent e) {
GuiPackage guiPackage = GuiPackage.getInstance();
guiPackage.clearTestPlan();
JTree tree = guiPackage.getTreeListener().getJTree();
tree.setSelectionRow(0);
FocusRequester.requestFocus(tree);
ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), ActionNames.ADD_ALL));
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class Close method performAction.
/**
* Helper routine to allow action to be shared by LOAD.
*
* @param e event
* @return true if Close was not cancelled
*/
static boolean performAction(ActionEvent e) {
ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.CHECK_DIRTY));
GuiPackage guiPackage = GuiPackage.getInstance();
if (guiPackage.isDirty()) {
int response;
if ((response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), // $NON-NLS-1$
JMeterUtils.getResString("cancel_new_to_save"), // $NON-NLS-1$
JMeterUtils.getResString("save?"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)) == JOptionPane.YES_OPTION) {
ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SAVE));
// in this case we should not close the test plan
if (guiPackage.isDirty()) {
return false;
}
}
if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.CANCEL_OPTION) {
// Don't clear the plan
return false;
}
}
ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.STOP_THREAD));
closeProject(e);
return true;
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class Clear method doAction.
@Override
public void doAction(ActionEvent e) {
GuiPackage guiPackage = GuiPackage.getInstance();
final String actionCommand = e.getActionCommand();
if (actionCommand.equals(ActionNames.CLEAR)) {
JMeterGUIComponent guiComp = guiPackage.getCurrentGui();
if (guiComp instanceof Clearable) {
((Clearable) guiComp).clearData();
}
} else {
guiPackage.getMainFrame().clearData();
for (JMeterTreeNode node : guiPackage.getTreeModel().getNodesOfType(Clearable.class)) {
JMeterGUIComponent guiComp = guiPackage.getGui(node.getTestElement());
if (guiComp instanceof Clearable) {
Clearable item = (Clearable) guiComp;
try {
item.clearData();
} catch (Exception ex) {
log.error("Can't clear: {} {}", node, guiComp, ex);
}
}
}
}
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class CollapseExpand method doAction.
/**
* This method performs the actual command processing.
*
* @param e
* the generic UI action event
*/
@Override
public void doAction(ActionEvent e) {
boolean collapse = ActionNames.COLLAPSE_ALL.equals(e.getActionCommand());
GuiPackage guiInstance = GuiPackage.getInstance();
JTree jTree = guiInstance.getMainFrame().getTree();
if (collapse) {
for (int i = jTree.getRowCount() - 1; i >= 0; i--) {
jTree.collapseRow(i);
}
return;
}
for (int i = 0; i < jTree.getRowCount(); i++) {
jTree.expandRow(i);
}
}
Aggregations