use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class SelectTemplatesDialog method checkDirtyAndLoad.
/**
* Check if existing Test Plan has been modified and ask user
* what he wants to do if test plan is dirty
* @param actionEvent {@link ActionEvent}
*/
private void checkDirtyAndLoad(final ActionEvent actionEvent) throws HeadlessException {
final String selectedTemplate = templateList.getText();
final Template template = TemplateManager.getInstance().getTemplateByName(selectedTemplate);
if (template == null) {
return;
}
final boolean isTestPlan = template.isTestPlan();
// Check if the user wants to drop any changes
if (isTestPlan) {
ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.CHECK_DIRTY));
GuiPackage guiPackage = GuiPackage.getInstance();
if (guiPackage.isDirty()) {
// Check if the user wants to create from template
int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), // $NON-NLS-1$
JMeterUtils.getResString("cancel_new_from_template"), // $NON-NLS-1$
JMeterUtils.getResString("template_load?"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.SAVE));
}
if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.CANCEL_OPTION) {
// Don't clear the plan
return;
}
}
}
ActionRouter.getInstance().doActionNow(new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.STOP_THREAD));
final File parent = template.getParent();
final File fileToCopy = parent != null ? new File(parent, template.getFileName()) : new File(JMeterUtils.getJMeterHome(), template.getFileName());
Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false);
this.setVisible(false);
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class JMeterThread method threadFinished.
private void threadFinished(LoopIterationListener iterationListener) {
ThreadListenerTraverser shut = new ThreadListenerTraverser(false);
// call ThreadListener.threadFinished()
testTree.traverse(shut);
JMeterContextService.decrNumberOfThreads();
threadGroup.decrNumberOfThreads();
GuiPackage gp = GuiPackage.getInstance();
if (gp != null) {
// check there is a GUI
gp.getMainFrame().updateCounts();
}
if (iterationListener != null) {
// probably not possible, but check anyway
threadGroupLoopController.removeIterationListener(iterationListener);
}
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class JMeterThread method threadStarted.
private void threadStarted() {
JMeterContextService.incrNumberOfThreads();
threadGroup.incrNumberOfThreads();
GuiPackage gp = GuiPackage.getInstance();
if (gp != null) {
// check there is a GUI
gp.getMainFrame().updateCounts();
}
ThreadListenerTraverser startup = new ThreadListenerTraverser(true);
// call ThreadListener.threadStarted()
testTree.traverse(startup);
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class RemoteThreadsListenerImpl method threadFinished.
/* (non-Javadoc)
* @see org.apache.jmeter.samplers.RemoteThreadsListener#threadFinished()
*/
@Override
public void threadFinished() {
JMeterContextService.decrNumberOfThreads();
GuiPackage gp = GuiPackage.getInstance();
if (gp != null) {
// check there is a GUI
gp.getMainFrame().updateCounts();
}
for (RemoteThreadsLifeCycleListener listener : listeners) {
listener.threadNumberDecreased(JMeterContextService.getNumberOfThreads());
}
}
use of org.apache.jmeter.gui.GuiPackage in project jmeter by apache.
the class JMeterMenuBar method makeOptionsMenu.
private void makeOptionsMenu() {
// OPTIONS MENU
//$NON-NLS-1$
optionsMenu = makeMenuRes("option", 'O');
//$NON-NLS-1$
JMenuItem functionHelper = makeMenuItemRes("function_dialog_menu_item", 'F', ActionNames.FUNCTIONS, KeyStrokes.FUNCTIONS);
//$NON-NLS-1$
lafMenu = makeMenuRes("appearance", 'L');
for (LookAndFeelInfo laf : getAllLAFs()) {
JMenuItem menuItem = new JMenuItem(laf.getName());
menuItem.addActionListener(ActionRouter.getInstance());
menuItem.setActionCommand(ActionNames.LAF_PREFIX + laf.getClassName());
// show the classname to the user
menuItem.setToolTipText(laf.getClassName());
lafMenu.add(menuItem);
}
optionsMenu.add(functionHelper);
optionsMenu.add(lafMenu);
//$NON-NLS-1$
JCheckBoxMenuItem menuLoggerPanel = makeCheckBoxMenuItemRes("menu_logger_panel", ActionNames.LOGGER_PANEL_ENABLE_DISABLE);
GuiPackage guiInstance = GuiPackage.getInstance();
if (guiInstance != null) {
//avoid error in ant task tests (good way?)
guiInstance.setMenuItemLoggerPanel(menuLoggerPanel);
}
optionsMenu.add(menuLoggerPanel);
//$NON-NLS-1$
JMenu menuLoggerLevel = makeMenuRes("menu_logger_level");
JMenuItem menuItem;
String levelString;
for (Level level : Level.values()) {
levelString = level.toString();
menuItem = new JMenuItem(levelString);
menuItem.addActionListener(ActionRouter.getInstance());
menuItem.setActionCommand(ActionNames.LOG_LEVEL_PREFIX + levelString);
// show the classname to the user
menuItem.setToolTipText(levelString);
menuLoggerLevel.add(menuItem);
}
optionsMenu.add(menuLoggerLevel);
if (SSLManager.isSSLSupported()) {
//$NON-NLS-1$
sslManager = makeMenuItemRes("sslmanager", 'S', ActionNames.SSL_MANAGER, KeyStrokes.SSL_MANAGER);
optionsMenu.add(sslManager);
}
optionsMenu.add(makeLanguageMenu());
//$NON-NLS-1$
JMenuItem collapse = makeMenuItemRes("menu_collapse_all", ActionNames.COLLAPSE_ALL, KeyStrokes.COLLAPSE_ALL);
optionsMenu.add(collapse);
//$NON-NLS-1$
JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL);
optionsMenu.add(expand);
//$NON-NLS-1$
JMenuItem zoomIn = makeMenuItemRes("menu_zoom_in", ActionNames.ZOOM_IN);
optionsMenu.add(zoomIn);
//$NON-NLS-1$
JMenuItem zoomOut = makeMenuItemRes("menu_zoom_out", ActionNames.ZOOM_OUT);
optionsMenu.add(zoomOut);
addPluginsMenuItems(optionsMenu, menuCreators, MENU_LOCATION.OPTIONS);
}
Aggregations