jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1765498 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/action/ src/core/org/apache/jmeter/resources/ src/core/org/apache/jmeter/threads/gui/ src/core/org/apache/jmeter/util/ xdocs/
Date Tue, 18 Oct 2016 19:14:55 GMT
Author: pmouawad
Date: Tue Oct 18 19:14:55 2016
New Revision: 1765498

URL: http://svn.apache.org/viewvc?rev=1765498&view=rev
Log:
Bug 60266 - Usability/ UX : It should not be possible to close/exit/Revert/Load/Load a recent
project or create from template a JMeter plan or open a new one if a test is running
Bugzilla Id: 60266

Added:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java
  (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Close.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ExitCommand.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/LoadRecentProject.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Move.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/RevertProject.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/TemplatesCommand.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java
    jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
    jmeter/trunk/xdocs/changes.xml

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java?rev=1765498&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java
(added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java
Tue Oct 18 19:14:55 2016
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.gui.action;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JOptionPane;
+
+import org.apache.jmeter.exceptions.IllegalUserActionException;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * {@link AbstractAction} implementation that check no test is running 
+ * before calling {@link AbstractActionWithNoRunningTest#doActionAfterCheck(ActionEvent)}
+ * @since 3.1
+ */
+public abstract class AbstractActionWithNoRunningTest extends AbstractAction {
+
+    @Override
+    public final void doAction(ActionEvent e) throws IllegalUserActionException {
+        if (JMeterUtils.isTestRunning()) {
+            JOptionPane.showMessageDialog(GuiPackage.getInstance().getMainFrame(),
+                    JMeterUtils.getResString("action_check_message"),  //$NON-NLS-1$
+                    JMeterUtils.getResString("action_check_title"),  //$NON-NLS-1$
+                    JOptionPane.WARNING_MESSAGE);
+            return;
+        }
+        doActionAfterCheck(e);
+    }
+
+    /**
+     * Called to handle {@link ActionEvent} only if no test is running
+     * @param e {@link ActionEvent}
+     * @throws IllegalUserActionException
+     */
+    protected abstract void doActionAfterCheck(ActionEvent e) throws IllegalUserActionException;
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractActionWithNoRunningTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java Tue Oct 18 19:14:55
2016
@@ -24,19 +24,15 @@ import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
 
-import javax.swing.JOptionPane;
-
-import org.apache.jmeter.gui.GuiPackage;
-import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JMeterError;
 import org.apache.log.Logger;
 
 /**
- * 
+ * Change language
  */
-public class ChangeLanguage extends AbstractAction {
+public class ChangeLanguage extends AbstractActionWithNoRunningTest {
     private static final Set<String> commands = new HashSet<>();
 
     private static final Logger log = LoggingManager.getLoggerForClass();
@@ -46,17 +42,10 @@ public class ChangeLanguage extends Abst
     }
 
     /**
-     * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
+     * @see org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest#doActionAfterCheck(ActionEvent)
      */
     @Override
-    public void doAction(ActionEvent e) {
-        if (JMeterContextService.getTestStartTime()>0) {
-            JOptionPane.showMessageDialog(GuiPackage.getInstance().getMainFrame(),
-                    JMeterUtils.getResString("language_change_test_running"),  //$NON-NLS-1$
-                    JMeterUtils.getResString("language_change_title"),  //$NON-NLS-1$
-                    JOptionPane.WARNING_MESSAGE);
-            return;
-        }
+    public void doActionAfterCheck(ActionEvent e) {
         String locale = ((Component) e.getSource()).getName();
         Locale loc;
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Close.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Close.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Close.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Close.java Tue Oct 18 19:14:55 2016
@@ -34,7 +34,7 @@ import org.apache.jmeter.util.JMeterUtil
  * test plan.
  *
  */
-public class Close extends AbstractAction {
+public class Close extends AbstractActionWithNoRunningTest {
 
     private static final Set<String> commands = new HashSet<>();
 
@@ -65,7 +65,7 @@ public class Close extends AbstractActio
      *            the generic UI action event
      */
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         performAction(e);
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ExitCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ExitCommand.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ExitCommand.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ExitCommand.java Tue Oct 18 19:14:55
2016
@@ -27,7 +27,7 @@ import javax.swing.JOptionPane;
 import org.apache.jmeter.gui.GuiPackage;
 import org.apache.jmeter.util.JMeterUtils;
 
-public class ExitCommand extends AbstractAction {
+public class ExitCommand extends AbstractActionWithNoRunningTest {
 
     private static final Set<String> commands = new HashSet<>();
 
@@ -58,7 +58,7 @@ public class ExitCommand extends Abstrac
      *            Description of Parameter
      */
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(),
ActionNames.CHECK_DIRTY));
         if (GuiPackage.getInstance().isDirty()) {
             int chosenOption = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
JMeterUtils

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java Tue Oct 18 19:14:55 2016
@@ -50,7 +50,7 @@ import com.thoughtworks.xstream.converte
  * Handles the Open (load a new file) and Merge commands.
  *
  */
-public class Load extends AbstractAction {
+public class Load extends AbstractActionWithNoRunningTest {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private static final boolean expandTree = JMeterUtils.getPropDefault("onload.expandtree",
false); //$NON-NLS-1$
@@ -72,7 +72,7 @@ public class Load extends AbstractAction
     }
 
     @Override
-    public void doAction(final ActionEvent e) {
+    public void doActionAfterCheck(final ActionEvent e) {
         final JFileChooser chooser = FileDialoger.promptToOpenFile(new String[] { ".jmx"
}); //$NON-NLS-1$
         if (chooser == null) {
             return;

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/LoadRecentProject.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LoadRecentProject.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/LoadRecentProject.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/LoadRecentProject.java Tue Oct 18 19:14:55
2016
@@ -59,7 +59,7 @@ public class LoadRecentProject extends L
     }
 
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         // We must ask the user if it is ok to close current project
         if (!Close.performAction(e)) {
             return;

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Move.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Move.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Move.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Move.java Tue Oct 18 19:14:55 2016
@@ -35,6 +35,10 @@ import org.apache.jmeter.testelement.Tes
 import org.apache.jmeter.testelement.TestPlan;
 import org.apache.jmeter.testelement.WorkBench;
 
+/**
+ * Move a node up/down/left/right 
+ *
+ */
 public class Move extends AbstractAction {
     private static final Set<String> commands = new HashSet<>();
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/RevertProject.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/RevertProject.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/RevertProject.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/RevertProject.java Tue Oct 18 19:14:55
2016
@@ -32,7 +32,7 @@ import org.apache.jmeter.util.JMeterUtil
  * Handles the Revert Project command.
  *
  */
-public class RevertProject extends AbstractAction {
+public class RevertProject extends AbstractActionWithNoRunningTest {
     private static final Set<String> commands = new HashSet<>();
 
     static {
@@ -49,7 +49,7 @@ public class RevertProject extends Abstr
     }
 
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         // Get the file name of the current project
         String projectFile = GuiPackage.getInstance().getTestPlanFile();
         // Check if the user has loaded any file

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/TemplatesCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/TemplatesCommand.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/TemplatesCommand.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/TemplatesCommand.java Tue Oct 18 19:14:55
2016
@@ -26,7 +26,7 @@ import java.util.Set;
  * Open Templates 
  * @since 2.10
  */
-public class TemplatesCommand extends AbstractAction {
+public class TemplatesCommand extends AbstractActionWithNoRunningTest {
 
     private static final Set<String> commands = new HashSet<>();
 
@@ -41,10 +41,10 @@ public class TemplatesCommand extends Ab
     }
 
     /**
-     * @see Command#doAction(ActionEvent)
+     * @see org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest#doActionAfterCheck(ActionEvent)
      */
     @Override
-    public void doAction(ActionEvent e) {
+    public void doActionAfterCheck(ActionEvent e) {
         IODH.dialog.setVisible(true);
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Oct 18 19:14:55
2016
@@ -559,8 +559,8 @@ junit_success_default_msg=Test successfu
 junit_success_msg=Success Message
 junit_test_config=JUnit Test Parameters
 junit_test_method=Test Method
-language_change_test_running=A Test is currently running, stop or shutdown test to change
language
-language_change_title=Test Running
+action_check_message=A Test is currently running, stop or shutdown test to execute this command
+action_check_title=Test Running
 ldap_argument_list=LDAPArgument List
 ldap_connto=Connection timeout (in milliseconds)
 ldap_parse_results=Parse the search results ?

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Tue Oct 18 19:14:55
2016
@@ -549,8 +549,8 @@ junit_success_default_msg=Test r\u00E9us
 junit_success_msg=Message de succ\u00E8s
 junit_test_config=Param\u00E8tres Test JUnit
 junit_test_method=M\u00E9thode de test
-language_change_test_running=Un test est en cours, arr\u00EAtez le avant de changer la langue
-language_change_title=Test en cours
+action_check_message=Un test est en cours, arr\u00EAtez le avant d''utiliser cette commande
+action_check_title=Test en cours
 ldap_argument_list=Liste d'arguments LDAP
 ldap_connto=D\u00E9lai d'attente de connexion (millisecondes)
 ldap_parse_results=Examiner les r\u00E9sultats de recherche ?

Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java Tue Oct
18 19:14:55 2016
@@ -84,7 +84,7 @@ public abstract class AbstractThreadGrou
         
         if(this.isEnabled() && 
                 // Check test is not started already
-                JMeterContextService.getTestStartTime()==0) {
+                !JMeterUtils.isTestRunning()) {
             pop.addSeparator();
             JMenuItem runTg = new JMenuItem(JMeterUtils.getResString("run_threadgroup"));
             runTg.setName("run_threadgroup");

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java Tue Oct 18 19:14:55 2016
@@ -51,6 +51,7 @@ import javax.swing.SwingUtilities;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.reflect.ClassFinder;
 import org.apache.jorphan.test.UnitTestManager;
@@ -1201,6 +1202,13 @@ public class JMeterUtils implements Unit
         }
         return retVal.toString();
     }
+    
+    /**
+     * @return true if test is running
+     */
+    public static boolean isTestRunning() {
+        return JMeterContextService.getTestStartTime()>0;
+    }
 
     /**
      * Get the JMeter home directory - does not include the trailing separator.

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1765498&r1=1765497&r2=1765498&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Oct 18 19:14:55 2016
@@ -189,6 +189,7 @@ Summary
     <li><bug>60106</bug>Settings defaults : Switch "<code>jmeter.save.saveservice.connect_time</code>"
to true (after 3.0)</li>
     <li><pr>229</pr> tiny memory allocation improvements. Contributed by
Benoit Wiart (b.wiart at ubik-ingenierie.com)</li>
     <li><bug>59945</bug>For all JSR223 elements, if script language has
not been chosen on the UI, the script will be interpreted as a groovy script.</li>
+    <li><bug>60266</bug>Usability/ UX : It should not be possible to close/exit/Revert/Load/Load
a recent project or create from template a JMeter plan or open a new one if a test is running</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>



Mime
View raw message