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: r1717618 - in /jmeter/trunk: src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java xdocs/changes.xml
Date Wed, 02 Dec 2015 12:54:26 GMT
On 2 December 2015 at 12:16,  <pmouawad@apache.org> wrote:
> Author: pmouawad
> Date: Wed Dec  2 12:16:14 2015
> New Revision: 1717618
>
> URL: http://svn.apache.org/viewvc?rev=1717618&view=rev
> Log:
> Bug 58679 - Replace the xpp pull parser in xstream with a java6+ standard solution
> Bugzilla Id: 58679

The log message does not agree with the changes.

Please fix.

> Modified:
>     jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
>     jmeter/trunk/xdocs/changes.xml
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java?rev=1717618&r1=1717617&r2=1717618&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
(original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
Wed Dec  2 12:16:14 2015
> @@ -43,6 +43,7 @@ import javax.swing.event.TreeSelectionLi
>  import javax.swing.tree.DefaultMutableTreeNode;
>  import javax.swing.tree.DefaultTreeCellRenderer;
>  import javax.swing.tree.DefaultTreeModel;
> +import javax.swing.tree.DefaultTreeSelectionModel;
>  import javax.swing.tree.TreeNode;
>  import javax.swing.tree.TreePath;
>  import javax.swing.tree.TreeSelectionModel;
> @@ -112,7 +113,60 @@ public class ModuleControllerGui extends
>          moduleToRunTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
>          moduleToRunTreeNodes = new JTree(moduleToRunTreeModel);
>          moduleToRunTreeNodes.setCellRenderer(new ModuleControllerCellRenderer());
> -        moduleToRunTreeNodes.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
> +
> +        // this custom TreeSelectionModel forbid the selection of some test elements
(test plan, thread group, etc..)
> +        TreeSelectionModel tsm =  new DefaultTreeSelectionModel() {
> +
> +            private static final long serialVersionUID = 4062816201792954617L;
> +
> +            private boolean isSelectedPathAllowed(DefaultMutableTreeNode lastSelected)
{
> +                JMeterTreeNode tn = null;
> +                if (lastSelected != null && lastSelected.getUserObject() instanceof
JMeterTreeNode) {
> +                    tn = (JMeterTreeNode) lastSelected.getUserObject();
> +                }
> +                if(tn != null && isTestElementAllowed(tn.getTestElement()))
{
> +                    return true;
> +                }
> +
> +                return false;
> +            }
> +
> +            @Override
> +            public void setSelectionPath(TreePath path) {
> +                DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode) path.getLastPathComponent();
> +
> +                if(isSelectedPathAllowed(lastSelected)) {
> +                    super.setSelectionPath(path);
> +                }
> +            }
> +
> +            @Override
> +            public void setSelectionPaths(TreePath[] pPaths) {
> +                DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode) pPaths[pPaths.length-1].getLastPathComponent();
> +                if(isSelectedPathAllowed(lastSelected)) {
> +                    super.setSelectionPaths(pPaths);
> +                }
> +            }
> +
> +            @Override
> +            public void addSelectionPath(TreePath path) {
> +                DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode) path.getLastPathComponent();
> +                if(isSelectedPathAllowed(lastSelected)) {
> +                    super.addSelectionPath(path);
> +                }
> +            }
> +
> +            @Override
> +            public void addSelectionPaths(TreePath[] paths) {
> +                DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode) paths[paths.length-1].getLastPathComponent();
> +                if(isSelectedPathAllowed(lastSelected)) {
> +                    super.addSelectionPaths(paths);
> +                }
> +            }
> +
> +        };
> +        tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
> +        moduleToRunTreeNodes.setSelectionModel(tsm);
>
>          ImageIcon image = JMeterUtils.getImage("warning.png");
>          warningLabel = new JLabel("", image, SwingConstants.LEFT); // $NON-NLS-1$
> @@ -123,6 +177,7 @@ public class ModuleControllerGui extends
>
>          init();
>
> +        // the listener is used to hide the error messsage when a target element is
selected
>          TreeSelectionListener tsl = new TreeSelectionListener() {
>              @Override
>              public void valueChanged(TreeSelectionEvent e) {
> @@ -196,12 +251,22 @@ public class ModuleControllerGui extends
>              selected = tn;
>              //prevent from selecting thread group or test plan elements
>              if (selected != null
> -                    && !(selected.getTestElement() instanceof AbstractThreadGroup)
> -                    && !(selected.getTestElement() instanceof TestPlan)) {
> +                    && isTestElementAllowed(selected.getTestElement())) {
>                  ((ModuleController) element).setSelectedNode(selected);
>              }
>          }
>      }
> +
> +    // check if a given test element can be selected as the target of a module controller
> +    private static boolean isTestElementAllowed(TestElement testElement) {
> +        if (testElement != null
> +                && !(testElement instanceof AbstractThreadGroup)
> +                && !(testElement instanceof TestPlan)) {
> +            return true;
> +        }
> +
> +        return false;
> +    }
>
>      /** {@inheritDoc}} */
>      @Override
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1717618&r1=1717617&r2=1717618&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Wed Dec  2 12:16:14 2015
> @@ -178,6 +178,7 @@ Summary
>  <h3>Controllers</h3>
>  <ul>
>      <li><bug>58600</bug>Display correct filenames, when they are searched
by IncludeController</li>
> +    <li><bug>58678</bug>Module Controller : limit target element selection.
Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
>  </ul>
>
>  <h3>Listeners</h3>
>
>

Mime
View raw message