jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1819495 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/JMeterGUIComponent.java src/core/org/apache/jmeter/gui/util/MenuFactory.java src/core/org/apache/jmeter/gui/util/MenuInfo.java xdocs/changes.xml
Date Fri, 29 Dec 2017 14:32:00 GMT
Author: pmouawad
Date: Fri Dec 29 14:32:00 2017
New Revision: 1819495

URL: http://svn.apache.org/viewvc?rev=1819495&view=rev
Log:
Bug 61935 - Let GUI component (dynamically) decide whether it can be added via the menu or
not
Contributed by Peter Doornbosch (https://bitbucket.org/pjtr/)
This closes #364
Bugzilla Id: 61935

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuInfo.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java?rev=1819495&r1=1819494&r2=1819495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java Fri Dec 29 14:32:00
2017
@@ -220,4 +220,12 @@ public interface JMeterGUIComponent exte
      * @see org.apache.jmeter.gui.util.MenuFactory
      */
     Collection<String> getMenuCategories();
+
+    /**
+     * Returns whether a component of this type can be added to the test plan.
+     * @return true if the component can be added, false otherwise.
+     */
+    default boolean canBeAdded() {
+        return true;
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1819495&r1=1819494&r2=1819495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Fri Dec 29 14:32:00
2017
@@ -511,6 +511,7 @@ public final class MenuFactory {
 
         JMenuItem newMenuChoice = new JMenuItem(info.getLabel());
         newMenuChoice.setName(info.getClassName());
+        newMenuChoice.setEnabled(info.getEnabled(actionCommand));
         newMenuChoice.addActionListener(ActionRouter.getInstance());
         if (actionCommand != null) {
             newMenuChoice.setActionCommand(actionCommand);

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuInfo.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuInfo.java?rev=1819495&r1=1819494&r2=1819495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuInfo.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuInfo.java Fri Dec 29 14:32:00 2017
@@ -20,6 +20,7 @@ package org.apache.jmeter.gui.util;
 
 import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.JMeterGUIComponent;
+import org.apache.jmeter.gui.action.ActionNames;
 
 /**
  * Class to hold additional information needed when building the GUI lists
@@ -74,4 +75,18 @@ public class MenuInfo {
     public int getSortOrder() {
         return sortOrder;
     }
+
+    /**
+     * Returns whether the menu item represented by this MenuInfo object should be enabled
+     * @param actionCommand    the action command name for the menu item
+     * @return true when menu item should be enabled, false otherwise.
+     */
+    public boolean getEnabled(String actionCommand) {
+        if (ActionNames.ADD.equals(actionCommand)) {
+            return guiComp.canBeAdded();
+        }
+        else {
+            return true;
+        }
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1819495&r1=1819494&r2=1819495&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Dec 29 14:32:00 2017
@@ -191,6 +191,7 @@ Summary
     <li><pr>353</pr>Re-wrote some existing tests in Spock. Contributed
by Graham Russell (graham at ham1.co.uk)</li>
     <li><bug>61919</bug>UX : Reorder Menus. Contributed by Graham Russell
(graham at ham1.co.uk)</li>
     <li><bug>61920</bug>Plugins : Add ability to listen to Test Plan loading/closing.
Contributed by Peter Doornbosch (https://bitbucket.org/pjtr/)</li>
+    <li><bug>61935</bug>Plugins : Let GUI component (dynamically) decide
whether it can be added via the menu or not. Contributed by Peter Doornbosch (https://bitbucket.org/pjtr/)</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>



Mime
View raw message