You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by un...@apache.org on 2015/06/03 13:08:57 UTC
svn commit: r1683284 - in /jmeter/trunk: bin/
src/core/org/apache/jmeter/gui/ src/core/org/apache/jmeter/gui/action/
xdocs/ xdocs/usermanual/
Author: undera
Date: Wed Jun 3 11:08:56 2015
New Revision: 1683284
URL: http://svn.apache.org/r1683284
Log:
Bug 57988 - Ability to add elements to tree with hotkeys
Modified:
jmeter/trunk/bin/jmeter.properties
jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java
jmeter/trunk/src/core/org/apache/jmeter/gui/action/KeyStrokes.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/hints_and_tips.xml
Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Wed Jun 3 11:08:56 2015
@@ -180,6 +180,18 @@ not_in_menu=org.apache.jmeter.protocol.h
# The bigger it is, the more it consumes memory
#undo.history.size=0
+# Hotkeys to add JMeter components, will add elements when you press Ctrl+0 .. Ctrl+9
+gui.quick_0=ThreadGroupGui
+gui.quick_1=HttpTestSampleGui
+gui.quick_2=RegexExtractorGui
+gui.quick_3=AssertionGui
+gui.quick_4=ConstantTimerGui
+gui.quick_5=TestActionGui
+gui.quick_6=JSR223PostProcessor
+gui.quick_7=JSR223PreProcessor
+gui.quick_8=DebugSampler
+gui.quick_9=ViewResultsFullVisualizer
+
#---------------------------------------------------------------------------
# Remote hosts and RMI configuration
#---------------------------------------------------------------------------
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=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java Wed Jun 3 11:08:56 2015
@@ -47,11 +47,14 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DropMode;
import javax.swing.ImageIcon;
+import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
@@ -63,6 +66,7 @@ import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
+import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -74,15 +78,19 @@ import javax.swing.tree.TreePath;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.gui.action.ActionNames;
import org.apache.jmeter.gui.action.ActionRouter;
+import org.apache.jmeter.gui.action.KeyStrokes;
import org.apache.jmeter.gui.action.LoadDraggedFile;
import org.apache.jmeter.gui.tree.JMeterCellRenderer;
import org.apache.jmeter.gui.tree.JMeterTreeListener;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.gui.tree.JMeterTreeTransferHandler;
import org.apache.jmeter.gui.util.EscapeDialog;
import org.apache.jmeter.gui.util.JMeterMenuBar;
import org.apache.jmeter.gui.util.JMeterToolBar;
+import org.apache.jmeter.gui.util.MenuFactory;
import org.apache.jmeter.samplers.Clearable;
import org.apache.jmeter.samplers.Remoteable;
+import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.TestStateListener;
import org.apache.jmeter.threads.JMeterContextService;
@@ -647,9 +655,55 @@ public class MainFrame extends JFrame im
treevar.setDropMode(DropMode.ON_OR_INSERT);
treevar.setTransferHandler(new JMeterTreeTransferHandler());
+ addQuickComponentHotkeys(treevar);
+
return treevar;
}
+ private void addQuickComponentHotkeys(JTree treevar) {
+ Action quickComponent = new AbstractAction("Quick Component") {
+ @Override
+ public void actionPerformed(ActionEvent actionEvent) {
+ String propname = "gui.quick_" + actionEvent.getActionCommand();
+ String comp = JMeterUtils.getProperty(propname);
+ log.debug("Event " + propname + ": " + comp);
+
+ if (comp == null) {
+ log.warn("No component set through property: " + propname);
+ return;
+ }
+
+ GuiPackage guiPackage = GuiPackage.getInstance();
+ try {
+ guiPackage.updateCurrentNode();
+ TestElement testElement = guiPackage.createTestElement(SaveService.aliasToClass(comp));
+ JMeterTreeNode parentNode = guiPackage.getCurrentNode();
+ while (!MenuFactory.canAddTo(parentNode, testElement)) {
+ parentNode = (JMeterTreeNode) parentNode.getParent();
+ }
+ if (parentNode.getParent() == null) {
+ log.debug("Cannot add element on very top level");
+ } else {
+ JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode);
+ guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath()));
+ }
+ } catch (Exception err) {
+ log.warn("Failed to perform quick component add: " + comp, err); // $NON-NLS-1$
+ }
+ }
+ };
+
+ InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
+ KeyStroke[] keyStrokes = new KeyStroke[]{KeyStrokes.CTRL_0,
+ KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3,
+ KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6,
+ KeyStrokes.CTRL_7, KeyStrokes.CTRL_8, KeyStrokes.CTRL_9,};
+ for (int n = 0; n < keyStrokes.length; n++) {
+ treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent);
+ inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n));
+ }
+ }
+
/**
* Create the tree cell renderer used to draw the nodes in the test tree.
*
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java?rev=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java Wed Jun 3 11:08:56 2015
@@ -97,6 +97,7 @@ public final class ActionNames {
public static final String MOVE_RIGHT = "move_right"; // $NON-NLS-1$
public static final String UNDO = "undo"; // $NON-NLS-1$
public static final String REDO = "redo"; // $NON-NLS-1$
+ public static final String QUICK_COMPONENT = "quick_component"; // $NON-NLS-1$
// Prevent instantiation
private ActionNames(){
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/KeyStrokes.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/KeyStrokes.java?rev=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/KeyStrokes.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/KeyStrokes.java Wed Jun 3 11:08:56 2015
@@ -74,6 +74,18 @@ public final class KeyStrokes {
public static final KeyStroke ALT_DOWN_ARROW = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK);
public static final KeyStroke ALT_LEFT_ARROW = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.ALT_DOWN_MASK);
public static final KeyStroke ALT_RIGHT_ARROW = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.ALT_DOWN_MASK);
+
+ // component hotkeys
+ public static final KeyStroke CTRL_0 = KeyStroke.getKeyStroke(KeyEvent.VK_0, CONTROL_MASK);
+ public static final KeyStroke CTRL_1 = KeyStroke.getKeyStroke(KeyEvent.VK_1, CONTROL_MASK);
+ public static final KeyStroke CTRL_2 = KeyStroke.getKeyStroke(KeyEvent.VK_2, CONTROL_MASK);
+ public static final KeyStroke CTRL_3 = KeyStroke.getKeyStroke(KeyEvent.VK_3, CONTROL_MASK);
+ public static final KeyStroke CTRL_4 = KeyStroke.getKeyStroke(KeyEvent.VK_4, CONTROL_MASK);
+ public static final KeyStroke CTRL_5 = KeyStroke.getKeyStroke(KeyEvent.VK_5, CONTROL_MASK);
+ public static final KeyStroke CTRL_6 = KeyStroke.getKeyStroke(KeyEvent.VK_6, CONTROL_MASK);
+ public static final KeyStroke CTRL_7 = KeyStroke.getKeyStroke(KeyEvent.VK_7, CONTROL_MASK);
+ public static final KeyStroke CTRL_8 = KeyStroke.getKeyStroke(KeyEvent.VK_8, CONTROL_MASK);
+ public static final KeyStroke CTRL_9 = KeyStroke.getKeyStroke(KeyEvent.VK_9, CONTROL_MASK);
/**
* Check if an event matches the KeyStroke definition.
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Jun 3 11:08:56 2015
@@ -108,6 +108,7 @@ Summary
<h3>General</h3>
<ul>
<li><bug>57913</bug>Automated backups of last saved JMX files. Contributed by Benoit Vatan (benoit.vatan at gmail.com)</li>
+<li><bug>57988</bug> Shortcuts (Ctrl+1 .. Ctrl+9) to quick add elements into test plan. Implemented by Andrey Pokhilko (andrey at blazemeter.com) and contributed by BlazeMeter Ltd.</li>
</ul>
<ch_section>Non-functional changes</ch_section>
<ul>
Modified: jmeter/trunk/xdocs/usermanual/hints_and_tips.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/hints_and_tips.xml?rev=1683284&r1=1683283&r2=1683284&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/hints_and_tips.xml (original)
+++ jmeter/trunk/xdocs/usermanual/hints_and_tips.xml Wed Jun 3 11:08:56 2015
@@ -149,6 +149,58 @@ values: <code>22x22</code> (default size
</description>
</subsection>
+ <subsection name="§-num;.5 Adding Elements with Hotkeys" anchor="component_hotkeys">
+ <p>
+ When you do intense scripting with JMeter, there is a way to add elements to test plan quickly
+ with keyboard shortcuts. Default bindings are:
+ </p>
+ <dl>
+ <dt>
+ <code>Ctrl+0</code>
+ </dt>
+ <dd>Thread Group</dd>
+ <dt>
+ <code>Ctrl+1</code>
+ </dt>
+ <dd>HTTP Request</dd>
+ <dt>
+ <code>Ctrl+2</code>
+ </dt>
+ <dd>Regular Expression Extractor</dd>
+ <dt>
+ <code>Ctrl+3</code>
+ </dt>
+ <dd>Response Assertion</dd>
+ <dt>
+ <code>Ctrl+4</code>
+ </dt>
+ <dd>Constant Timer</dd>
+ <dt>
+ <code>Ctrl+5</code>
+ </dt>
+ <dd>Test Action</dd>
+ <dt>
+ <code>Ctrl+6</code>
+ </dt>
+ <dd>JSR223 PostProcessor</dd>
+ <dt>
+ <code>Ctrl+7</code>
+ </dt>
+ <dd>JSR223 PreProcessor</dd>
+ <dt>
+ <code>Ctrl+8</code>
+ </dt>
+ <dd>Debug Sampler</dd>
+ <dt>
+ <code>Ctrl+9</code>
+ </dt>
+ <dd>View Results Tree</dd>
+ </dl>
+ <p>
+ To change these binding, please find "gui.quick_*" properties within jmeter.properties file as example,
+ it is recommended to put overrides for them into user.properties file.
+ </p>
+ </subsection>
</section>
</body>