jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1468204 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/action/Copy.java src/core/org/apache/jmeter/gui/action/Cut.java xdocs/changes.xml
Date Tue, 16 Apr 2013 10:51:19 GMT
On 15 April 2013 20:52, <pmouawad@apache.org> wrote:

> Author: pmouawad
> Date: Mon Apr 15 19:52:08 2013
> New Revision: 1468204
>
> URL: http://svn.apache.org/r1468204
> Log:
> Bug 54847 - Cut & Paste is broken with tree multi-selection
> Bugzilla Id: 54847
>
> Modified:
>     jmeter/trunk/src/core/org/apache/jmeter/gui/action/Copy.java
>     jmeter/trunk/src/core/org/apache/jmeter/gui/action/Cut.java
>     jmeter/trunk/xdocs/changes.xml
>
> Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Copy.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Copy.java?rev=1468204&r1=1468203&r2=1468204&view=diff
>
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Copy.java (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Copy.java Mon Apr
> 15 19:52:08 2013
> @@ -20,8 +20,10 @@ package org.apache.jmeter.gui.action;
>  import java.awt.Toolkit;
>  import java.awt.datatransfer.Clipboard;
>  import java.awt.event.ActionEvent;
> +import java.util.ArrayList;
>  import java.util.Enumeration;
>  import java.util.HashSet;
> +import java.util.List;
>  import java.util.Set;
>
>  import javax.swing.JOptionPane;
> @@ -59,6 +61,7 @@ public class Copy extends AbstractAction
>      public void doAction(ActionEvent e) {
>          JMeterTreeListener treeListener =
> GuiPackage.getInstance().getTreeListener();
>          JMeterTreeNode[] nodes = treeListener.getSelectedNodes();
> +        nodes = filterNodes(nodes);
>          nodes = cloneTreeNodes(nodes);
>          setCopiedNodes(nodes);
>      }
> @@ -84,6 +87,30 @@ public class Copy extends AbstractAction
>          cloneChildren(treeNode, node);
>          return treeNode;
>      }
> +
> +    /**
> +     * If a child and one of its ancestors are selected : only keep the
> ancestor
> +     * @param currentNodes JMeterTreeNode[]
> +     * @return JMeterTreeNode[]
> +     */
> +    public static JMeterTreeNode[] filterNodes(JMeterTreeNode[]
> currentNodes) {
>

Why is this public?
Also I think the name needs to be more descriptive, particularly if it is
to remain public.


> +        List<JMeterTreeNode> nodes = new ArrayList<JMeterTreeNode>();
> +        for (int i = 0; i < currentNodes.length; i++) {
> +            boolean exclude = false;
> +            for (int j = 0; j < currentNodes.length; j++) {
> +                if(i!=j &&
> currentNodes[i].isNodeAncestor(currentNodes[j])) {
> +                    exclude = true;
> +                    break;
> +                }
> +            }
> +
> +            if(!exclude) {
> +                nodes.add(currentNodes[i]);
> +            }
> +        }
> +
> +        return nodes.toArray(new JMeterTreeNode[nodes.size()]);
> +    }
>
>      public static void setCopiedNodes(JMeterTreeNode nodes[]) {
>          Clipboard clipboard =
> Toolkit.getDefaultToolkit().getSystemClipboard();
>
> Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Cut.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Cut.java?rev=1468204&r1=1468203&r2=1468204&view=diff
>
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Cut.java (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Cut.java Mon Apr 15
> 19:52:08 2013
> @@ -51,6 +51,7 @@ public class Cut extends AbstractAction
>          GuiPackage guiPack = GuiPackage.getInstance();
>          JMeterTreeNode[] currentNodes =
> guiPack.getTreeListener().getSelectedNodes();
>
> +        currentNodes = Copy.filterNodes(currentNodes);
>          Copy.setCopiedNodes(currentNodes);
>          for (int i = 0; i < currentNodes.length; i++) {
>              guiPack.getTreeModel().removeNodeFromParent(currentNodes[i]);
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1468204&r1=1468203&r2=1468204&view=diff
>
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Mon Apr 15 19:52:08 2013
> @@ -138,6 +138,7 @@ Shortcut for Function Helper Dialog is n
>  <ul>
>  <li><bugzilla>54504</bugzilla> - Resource string not found:
> [clipboard_node_read_error]</li>
>  <li><bugzilla>54538</bugzilla> - GUI: context menu is too big</li>
> +<li><bugzilla>54847</bugzilla> - Cut & Paste is broken with tree
> multi-selection</li>
>  </ul>
>
>  <!-- =================== Improvements =================== -->
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message