jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1204302 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/action/ src/core/org/apache/jmeter/gui/util/ src/core/org/apache/jmeter/resources/ xdocs/
Date Mon, 21 Nov 2011 00:22:47 GMT
Author: sebb
Date: Mon Nov 21 00:22:47 2011
New Revision: 1204302

URL: http://svn.apache.org/viewvc?rev=1204302&view=rev
Log:
Bug 46921 - Add Ability to Change Controller elements

Added:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/xdocs/changes.xml

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=1204302&r1=1204301&r2=1204302&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 Mon Nov 21 00:22:47
2011
@@ -36,6 +36,7 @@ public class ActionNames {
     public static final String ADD_PARENT       = "Add Parent"; // $NON-NLS-1$
     public static final String ANALYZE_FILE     = "Analyze File"; // $NON-NLS-1$
     public static final String CHANGE_LANGUAGE  = "change_language"; // $NON-NLS-1$
+    public static final String CHANGE_PARENT    = "Change Parent"; // $NON-NLS-1$
     public static final String CHECK_DIRTY      = "check_dirty"; // $NON-NLS-1$
     public static final String CHECK_REMOVE     = "check_remove"; // $NON-NLS-1$
     public static final String CLEAR            = "action.clear"; // $NON-NLS-1$

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java?rev=1204302&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java Mon Nov 21 00:22:47
2011
@@ -0,0 +1,90 @@
+/*
+ * 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.Component;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.jmeter.control.Controller;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.tree.JMeterTreeModel;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * Implements the Add Parent menu command
+ */
+public class ChangeParent implements Command {
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final Set<String> commands = new HashSet<String>();
+
+    static {
+        commands.add(ActionNames.CHANGE_PARENT);
+    }
+
+    public ChangeParent() {
+    }
+
+    public void doAction(ActionEvent e) {
+        String name = ((Component) e.getSource()).getName();
+        GuiPackage guiPackage = GuiPackage.getInstance();
+        JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
+        if (!(currentNode.getUserObject() instanceof Controller)) {
+            Toolkit.getDefaultToolkit().beep();
+            return;
+        }
+        try {
+            guiPackage.updateCurrentNode();
+            TestElement controller = guiPackage.createTestElement(name);
+            changeParent(controller, guiPackage, currentNode);
+        } catch (Exception err) {
+            Toolkit.getDefaultToolkit().beep();
+            log.error("Failed to change parent", err);
+        }
+
+    }
+
+    public Set<String> getActionNames() {
+        return commands;
+    }
+
+    private void changeParent(TestElement newParent, GuiPackage guiPackage, JMeterTreeNode
currentNode) {
+        JMeterTreeModel treeModel = guiPackage.getTreeModel();
+        JMeterTreeNode newNode = new JMeterTreeNode(newParent, treeModel);
+        JMeterTreeNode parentNode = (JMeterTreeNode) currentNode.getParent();
+        int index = parentNode.getIndex(currentNode);
+        treeModel.insertNodeInto(newNode, parentNode, index);
+        treeModel.removeNodeFromParent(currentNode);
+        Enumeration<JMeterTreeNode> nodes = currentNode.children();
+        while(nodes.hasMoreElements()) {
+            JMeterTreeNode node = nodes.nextElement();
+            treeModel.removeNodeFromParent(node);
+            treeModel.insertNodeInto(node, newNode, newNode.getChildCount());
+        }
+        
+    }
+
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ChangeParent.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=1204302&r1=1204301&r2=1204302&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 Mon Nov 21 00:22:47
2011
@@ -249,6 +249,9 @@ public final class MenuFactory {
         pop.add(makeMenus(MENU_PARENT_CONTROLLER,
                 JMeterUtils.getResString("insert_parent"),// $NON-NLS-1$
                 ActionNames.ADD_PARENT));
+        pop.add(makeMenus(MENU_PARENT_CONTROLLER,
+                JMeterUtils.getResString("change_parent"),// $NON-NLS-1$
+                ActionNames.CHANGE_PARENT));
         MenuFactory.addEditMenu(pop, true);
         MenuFactory.addFileMenu(pop);
         return pop;

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=1204302&r1=1204301&r2=1204302&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Mon Nov 21 00:22:47
2011
@@ -118,6 +118,7 @@ cancel=Cancel
 cancel_exit_to_save=There are test items that have not been saved.  Do you wish to save before
exiting?
 cancel_new_to_save=There are test items that have not been saved.  Do you wish to save before
clearing the test plan?
 cancel_revert_project=There are test items that have not been saved.  Do you wish to revert
to the previously saved test plan?
+change_parent=Change Parent
 char_value=Unicode character number (decimal or 0xhex)
 choose_function=Choose a function
 choose_language=Choose Language

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1204302&r1=1204301&r2=1204302&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Mon Nov 21 00:22:47 2011
@@ -220,6 +220,7 @@ This behaviour can be changed with prope
 <li>Bug 52161 - Enable plugins to add own translation rules in addition to upgrade.properties.
 Loads any additional properties found in META-INF/resources/org.apache.jmeter.nameupdater.properties
files</li>
 <li>Bug 42538 - Add "duplicate node" in context menu</li>
+<li>Bug 46921 - Add Ability to Change Controller elements</li>
 </ul>
 
 <h2>Non-functional changes</h2>



Mime
View raw message