You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/12/20 08:13:53 UTC
svn commit: r1818741 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/
src/core/org/apache/jmeter/gui/util/
src/protocol/http/org/apache/jmeter/protocol/http/config/gui/
src/protocol/http/org/apache/jmeter/protocol/http/control/gui/ xdocs/
Author: pmouawad
Date: Wed Dec 20 08:13:52 2017
New Revision: 1818741
URL: http://svn.apache.org/viewvc?rev=1818741&view=rev
Log:
Bug 61919 - UX : Reorder Menus
Refactoring/formatting in preparation for alternate menu sorting
Contributed by Graham Russell
This closes #357
Bugzilla Id: 61919
Modified:
jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java
jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.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=1818741&r1=1818740&r2=1818741&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java Wed Dec 20 08:13:52 2017
@@ -41,7 +41,6 @@ import org.apache.jmeter.testelement.Tes
* @see org.apache.jmeter.samplers.gui.AbstractSamplerGui
*
*/
-
public interface JMeterGUIComponent extends ClearGui {
/**
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java?rev=1818741&r1=1818740&r2=1818741&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java Wed Dec 20 08:13:52 2017
@@ -42,6 +42,7 @@ import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -766,23 +767,19 @@ public class MainFrame extends JFrame im
*/
@Override
public void drop(DropTargetDropEvent dtde) {
- try {
- Transferable tr = dtde.getTransferable();
- DataFlavor[] flavors = tr.getTransferDataFlavors();
- for (DataFlavor flavor : flavors) {
- // Check for file lists specifically
- if (flavor.isFlavorJavaFileListType()) {
- dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
- try {
- openJmxFilesFromDragAndDrop(tr);
- } finally {
- dtde.dropComplete(true);
- }
- return;
- }
+ Transferable tr = dtde.getTransferable();
+ boolean anyFlavourIsJavaFileList =
+ Arrays.stream(tr.getTransferDataFlavors())
+ .anyMatch(DataFlavor::isFlavorJavaFileListType);
+ if (anyFlavourIsJavaFileList) {
+ dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
+ try {
+ openJmxFilesFromDragAndDrop(tr);
+ } catch (UnsupportedFlavorException | IOException e) {
+ log.warn("Dnd failed", e);
+ } finally {
+ dtde.dropComplete(true);
}
- } catch (UnsupportedFlavorException | IOException e) {
- log.warn("Dnd failed", e);
}
}
@@ -832,7 +829,6 @@ public class MainFrame extends JFrame im
warnIndicator.setText(Integer.toString(errorOrFatal.get()));
});
}
-
}
@Override
@@ -847,7 +843,8 @@ public class MainFrame extends JFrame im
@Override
public void actionPerformed(ActionEvent event) {
if (event.getSource() == warnIndicator) {
- ActionRouter.getInstance().doActionNow(new ActionEvent(event.getSource(), event.getID(), ActionNames.LOGGER_PANEL_ENABLE_DISABLE));
+ ActionRouter.getInstance().doActionNow(
+ new ActionEvent(event.getSource(), event.getID(), ActionNames.LOGGER_PANEL_ENABLE_DISABLE));
}
}
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=1818741&r1=1818740&r2=1818741&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 Wed Dec 20 08:13:52 2017
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -34,6 +33,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
@@ -468,59 +468,26 @@ public final class MenuFactory {
private static void initializeMenus() {
try {
- List<String> guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] {
- JMeterGUIComponent.class, TestBean.class });
- Collections.sort(guiClasses);
- for (String name : guiClasses) {
-
- /*
- * JMeterTreeNode and TestBeanGUI are special GUI classes, and
- * aren't intended to be added to menus
- *
- * TODO: find a better way of checking this
- */
- if (name.endsWith("JMeterTreeNode") // $NON-NLS-1$
- || name.endsWith("TestBeanGUI")) {// $NON-NLS-1$
- continue;// Don't try to instantiate these
- }
+ List<String> guiClasses = ClassFinder
+ .findClassesThatExtend(
+ JMeterUtils.getSearchPaths(),
+ new Class[] {JMeterGUIComponent.class, TestBean.class})
+ .stream()
+ // JMeterTreeNode and TestBeanGUI are special GUI classes,
+ // and aren't intended to be added to menus
+ .filter(name -> !name.endsWith("JMeterTreeNode"))
+ .filter(name -> !name.endsWith("TestBeanGUI"))
+ .filter(name -> !elementsToSkip.contains(name))
+ .distinct()
+ .sorted(Comparator.comparing(String::trim))
+ .collect(Collectors.toList());
- if (elementsToSkip.contains(name)) { // No point instantiating class
- log.info("Skipping {}", name);
+ for (String name : guiClasses) {
+ JMeterGUIComponent item = getItem(name);
+ if (item == null) {
continue;
}
- boolean hideBean = false; // Should the TestBean be hidden?
-
- JMeterGUIComponent item = null;
- try {
- Class<?> c = Class.forName(name);
- if (TestBean.class.isAssignableFrom(c)) {
- TestBeanGUI tbgui = new TestBeanGUI(c);
- hideBean = tbgui.isHidden() || (tbgui.isExpert() && !JMeterUtils.isExpertMode());
- item = tbgui;
- } else {
- item = (JMeterGUIComponent) c.newInstance();
- }
- } catch (NoClassDefFoundError e) {
- log.warn(
- "Configuration error, probably corrupt or missing third party library(jar) ? Could not create class: {}. {}",
- name, e, e);
- continue;
- } catch(HeadlessException e) {
- log.warn("Could not instantiate class: {}", name, e); // NOSONAR
- continue;
- } catch(RuntimeException e) {
- throw e;
- } catch (Exception e) {
- log.warn("Could not instantiate class: {}", name, e); // NOSONAR
- continue;
- }
- if (hideBean || elementsToSkip.contains(item.getStaticLabel())) {
- log.info("Skipping {}", name);
- continue;
- } else {
- elementsToSkip.add(name); // Don't add it again
- }
Collection<String> categories = item.getMenuCategories();
if (categories == null) {
log.debug("{} participates in no menus.", name);
@@ -535,47 +502,71 @@ public final class MenuFactory {
if (categories.contains(TIMERS)) {
timers.add(new MenuInfo(item, name));
}
-
if (categories.contains(POST_PROCESSORS)) {
postProcessors.add(new MenuInfo(item, name));
}
-
if (categories.contains(PRE_PROCESSORS)) {
preProcessors.add(new MenuInfo(item, name));
}
-
if (categories.contains(CONTROLLERS)) {
controllers.add(new MenuInfo(item, name));
}
-
if (categories.contains(SAMPLERS)) {
samplers.add(new MenuInfo(item, name));
}
-
if (categories.contains(NON_TEST_ELEMENTS)) {
nonTestElements.add(new MenuInfo(item, name));
}
-
if (categories.contains(LISTENERS)) {
listeners.add(new MenuInfo(item, name));
}
-
if (categories.contains(CONFIG_ELEMENTS)) {
configElements.add(new MenuInfo(item, name));
}
if (categories.contains(ASSERTIONS)) {
assertions.add(new MenuInfo(item, name));
}
-
}
} catch (IOException e) {
log.error("IO Exception while initializing menus.", e);
}
}
+ private static JMeterGUIComponent getItem(String name) {
+ JMeterGUIComponent item = null;
+ boolean hideBean = false; // Should the TestBean be hidden?
+ try {
+ Class<?> c = Class.forName(name);
+ if (TestBean.class.isAssignableFrom(c)) {
+ TestBeanGUI tbgui = new TestBeanGUI(c);
+ hideBean = tbgui.isHidden() || (tbgui.isExpert() && !JMeterUtils.isExpertMode());
+ item = tbgui;
+ } else {
+ item = (JMeterGUIComponent) c.newInstance();
+ }
+ } catch (NoClassDefFoundError e) {
+ log.warn("Configuration error, probably corrupt or missing third party library(jar) ? Could not create class: {}.",
+ name, e);
+ } catch (HeadlessException e) {
+ log.warn("Could not instantiate class: {}", name, e);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ log.warn("Could not instantiate class: {}", name, e);
+ }
+ if (hideBean || (item != null && elementsToSkip.contains(item.getStaticLabel()))) {
+ log.info("Skipping {}", name);
+ item = null;
+ } else {
+ elementsToSkip.add(name);
+ }
+ return item;
+ }
+
private static void addSeparator(JPopupMenu menu) {
MenuElement[] elements = menu.getSubElements();
- if ((elements.length > 0) && !(elements[elements.length - 1] instanceof JPopupMenu.Separator)) {
+ if ((elements.length > 0)
+ && !(elements[elements.length - 1] instanceof JPopupMenu.Separator)) {
menu.addSeparator();
}
}
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java?rev=1818741&r1=1818740&r2=1818741&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java Wed Dec 20 08:13:52 2017
@@ -50,47 +50,30 @@ import org.apache.jorphan.gui.JLabeledTe
/**
* GUI for Http Request defaults
- *
*/
public class HttpDefaultsGui extends AbstractConfigGui {
private static final long serialVersionUID = 241L;
private static final Font FONT_DEFAULT = UIManager.getDefaults().getFont("TextField.font");
-
private static final Font FONT_SMALL = new Font("SansSerif", Font.PLAIN, (int) Math.round(FONT_DEFAULT.getSize() * 0.8));
private UrlConfigGui urlConfigGui;
-
private JCheckBox retrieveEmbeddedResources;
-
private JCheckBox concurrentDwn;
-
- private JTextField concurrentPool;
-
+ private JTextField concurrentPool;
private JCheckBox useMD5;
-
private JLabeledTextField embeddedRE; // regular expression used to match against embedded resource URLs
-
private JTextField sourceIpAddr; // does not apply to Java implementation
-
private JComboBox<String> sourceIpType = new JComboBox<>(HTTPSamplerBase.getSourceTypeList());
-
private JTextField proxyHost;
-
private JTextField proxyPort;
-
private JTextField proxyUser;
-
private JPasswordField proxyPass;
-
private JComboBox<String> httpImplementation = new JComboBox<>(HTTPSamplerFactory.getImplementations());
-
private JTextField connectTimeOut;
-
private JTextField responseTimeOut;
-
public HttpDefaultsGui() {
super();
init();
@@ -172,7 +155,6 @@ public class HttpDefaultsGui extends Abs
config.setProperty(HTTPSamplerBase.IMPLEMENTATION, httpImplementation.getSelectedItem().toString(),"");
config.setProperty(HTTPSamplerBase.CONNECT_TIMEOUT, connectTimeOut.getText());
config.setProperty(HTTPSamplerBase.RESPONSE_TIMEOUT, responseTimeOut.getText());
-
}
/**
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java?rev=1818741&r1=1818740&r2=1818741&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java Wed Dec 20 08:13:52 2017
@@ -45,52 +45,34 @@ import org.apache.jmeter.testelement.Tes
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.JLabeledTextField;
-//For unit tests, @see TestHttpTestSampleGui
-
/**
* HTTP Sampler GUI
- *
*/
public class HttpTestSampleGui extends AbstractSamplerGui {
private static final long serialVersionUID = 241L;
private static final Font FONT_DEFAULT = UIManager.getDefaults().getFont("TextField.font");
-
private static final Font FONT_SMALL = new Font("SansSerif", Font.PLAIN, (int) Math.round(FONT_DEFAULT.getSize() * 0.8));
private UrlConfigGui urlConfigGui;
-
private JCheckBox retrieveEmbeddedResources;
-
private JCheckBox concurrentDwn;
-
- private JTextField concurrentPool;
-
+ private JTextField concurrentPool;
private JCheckBox useMD5;
-
private JLabeledTextField embeddedRE; // regular expression used to match against embedded resource URLs
-
private JTextField sourceIpAddr; // does not apply to Java implementation
-
private JComboBox<String> sourceIpType = new JComboBox<>(HTTPSamplerBase.getSourceTypeList());
-
- private final boolean isAJP;
-
private JTextField proxyHost;
-
private JTextField proxyPort;
-
private JTextField proxyUser;
-
private JPasswordField proxyPass;
-
private JComboBox<String> httpImplementation = new JComboBox<>(HTTPSamplerFactory.getImplementations());
-
private JTextField connectTimeOut;
-
private JTextField responseTimeOut;
+ private final boolean isAJP;
+
public HttpTestSampleGui() {
isAJP = false;
init();
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1818741&r1=1818740&r2=1818741&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Dec 20 08:13:52 2017
@@ -186,6 +186,7 @@ Summary
<li><pr>351</pr> Fixed about dialog position on first view. Contributed by Graham Russell (graham at ham1.co.uk)</li>
<li><pr>352</pr> Menu bar - added mnemonics to more menu items. Contributed by Graham Russell (graham at ham1.co.uk)</li>
<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>
</ul>
<ch_section>Non-functional changes</ch_section>