jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1839858 - /jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java
Date Sat, 01 Sep 2018 21:32:06 GMT
Author: pmouawad
Date: Sat Sep  1 21:32:06 2018
New Revision: 1839858

URL: http://svn.apache.org/viewvc?rev=1839858&view=rev
Log:
Bug 61635 - Add a menu to restart JMeter
Fix issue when restarting (nightly) there's no pop up ask to save test plan (if there's an
unsaved change) and changes are deleted after restart

Contributed by orimarko
Bugzilla Id: 61635

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java?rev=1839858&r1=1839857&r2=1839858&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Restart.java Sat Sep  1 21:32:06 2018
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
  * Based on https://dzone.com/articles/programmatically-restart-java
  * @since 5.0
  */
-public class Restart extends AbstractAction implements MenuCreator {
+public class Restart extends AbstractActionWithNoRunningTest implements MenuCreator {
     private static final Logger log = LoggerFactory.getLogger(Restart.class);
 
     private static final String RESTART = "restart";
@@ -60,12 +60,30 @@ public class Restart extends AbstractAct
     }
 
     /**
-     * @see Command#doAction(ActionEvent)
+     * @see Command#doActionAfterCheck(ActionEvent)
      */
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         try {
-            restartApplication(null);
+            GuiPackage guiPackage = GuiPackage.getInstance();
+            ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(),
ActionNames.CHECK_DIRTY));
+            if (guiPackage.isDirty()) {
+                int chosenOption = 
+                        JOptionPane.showConfirmDialog(guiPackage.getMainFrame(), JMeterUtils
+                                .getResString("cancel_exit_to_save"), // $NON-NLS-1$
+                                JMeterUtils.getResString("save?"), // $NON-NLS-1$
+                                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (chosenOption == JOptionPane.NO_OPTION) {
+                    restartApplication(null);
+                } else if (chosenOption == JOptionPane.YES_OPTION) {
+                    ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(),
e.getID(), ActionNames.SAVE));
+                    if (!guiPackage.isDirty()) {
+                        restartApplication(null);
+                    }
+                }
+            } else {
+                restartApplication(null);
+            }
         } catch (Exception ex) {
             log.error("Error trying to restart: {}", ex.getMessage(), ex);
             JOptionPane.showMessageDialog(GuiPackage.getInstance().getMainFrame(), 



Mime
View raw message