mstover1    2003/02/06 16:36:26

  Modified:    src/core/org/apache/jmeter/gui GuiPackage.java
               src/protocol/http/org/apache/jmeter/protocol/http/proxy
                        ProxyControl.java
               src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui
                        ProxyControlGui.java
  Log:
  Minor updates to gui-related issues
  
  Revision  Changes    Path
  1.8       +11 -4     jakarta-jmeter/src/core/org/apache/jmeter/gui/GuiPackage.java
  
  Index: GuiPackage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/GuiPackage.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- GuiPackage.java   3 Feb 2003 16:08:35 -0000       1.7
  +++ GuiPackage.java   7 Feb 2003 00:36:25 -0000       1.8
  @@ -139,10 +139,7 @@
                try
                {
                        JMeterGUIComponent comp = 
getGui(treeListener.getCurrentNode().createTestElement());
  -                     if(!(comp instanceof UnsharedComponent))
  -                     {
  -                             
comp.configure(treeListener.getCurrentNode().createTestElement());
  -                     }
  +                     
comp.configure(treeListener.getCurrentNode().createTestElement());
                        return comp;
                }
                catch (Exception e)
  @@ -183,6 +180,16 @@
                        return null;
                }
        }
  +    
  +    public void updateCurrentGui()
  +    {
  +        if(currentNode != null)
  +        {
  +            JMeterGUIComponent comp = getGui(currentNode.createTestElement());
  +            comp.configure(currentNode.createTestElement());
  +        }
  +    }
  +    
        public void updateCurrentNode()
        {
                try
  
  
  
  1.12      +314 -336  
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
  
  Index: ProxyControl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ProxyControl.java 3 Feb 2003 16:08:36 -0000       1.11
  +++ ProxyControl.java 7 Feb 2003 00:36:25 -0000       1.12
  @@ -55,9 +55,10 @@
   package org.apache.jmeter.protocol.http.proxy;
   import java.io.Serializable;
   import java.net.UnknownHostException;
  +import java.util.Collection;
   import java.util.Enumeration;
  +import java.util.HashSet;
   import java.util.Iterator;
  -import java.util.LinkedList;
   import java.util.List;
   
   import junit.framework.TestCase;
  @@ -78,7 +79,7 @@
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.log.Hierarchy;
   import org.apache.log.Logger;
  -import org.apache.oro.text.regex.MalformedPatternException;
  +import org.apache.oro.text.PatternCacheLRU;
   import org.apache.oro.text.regex.Pattern;
   import org.apache.oro.text.regex.Perl5Compiler;
   import org.apache.oro.text.regex.Perl5Matcher;
  @@ -92,233 +93,228 @@
    ***********************************************************/
   public class ProxyControl extends ConfigTestElement implements Serializable
   {
  -     transient private static Logger log =
  -             Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.protocol.http");
  -     Daemon server;
  -     private final int DEFAULT_PORT = 8080;
  -     transient Perl5Compiler compiler;
  -     transient Perl5Matcher matcher;
  -     public final static String PORT = "ProxyControlGui.port";
  -     public final static String EXCLUDE_LIST = "ProxyControlGui.exclude_list";
  -     public final static String INCLUDE_LIST = "ProxyControlGui.include_list";
  -     /************************************************************
  -      *  !ToDo (Constructor description)
  -      ***********************************************************/
  -     public ProxyControl()
  -     {
  -             matcher = new Perl5Matcher();
  -             compiler = new Perl5Compiler();
  -             setPort(DEFAULT_PORT);
  -             setExcludeList(new LinkedList());
  -             setIncludeList(new LinkedList());
  -     }
  -     /************************************************************
  -      *  !ToDo (Method description)
  -      *
  -      *@param  port  !ToDo (Parameter description)
  -      ***********************************************************/
  -     public void setPort(int port)
  -     {
  -             this.setProperty(PORT, new Integer(port));
  -     }
  -     public void setIncludeList(List list)
  -     {
  -             setProperty(INCLUDE_LIST, list);
  -     }
  -     public void setExcludeList(List list)
  -     {
  -             setProperty(EXCLUDE_LIST, list);
  -     }
  -     /************************************************************
  -      *  !ToDoo (Method description)
  -      *
  -      *@return    !ToDo (Return description)
  -      ***********************************************************/
  -     public String getClassLabel()
  -     {
  -             return JMeterUtils.getResString("proxy_title");
  -     }
  -     /************************************************************
  -      *  !ToDoo (Method description)
  -      *
  -      *@return    !ToDo (Return description)
  -      ***********************************************************/
  -     public int getPort()
  -     {
  -             if (this.getProperty(PORT) instanceof String)
  -             {
  -                     setPort(Integer.parseInt((String) getProperty(PORT)));
  -                     return ((Integer) this.getProperty(PORT)).intValue();
  -             }
  -             else
  -             {
  -                     return ((Integer) this.getProperty(PORT)).intValue();
  -             }
  -     }
  -     /************************************************************
  -      *  !ToDoo (Method description)
  -      *
  -      *@return    !ToDo (Return description)
  -      ***********************************************************/
  -     public int getDefaultPort()
  -     {
  -             return DEFAULT_PORT;
  -     }
  -     public Class getGuiClass()
  -     {
  -             return org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.class;
  -     }
  +    transient private static Logger log = 
Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.protocol.http");
  +    Daemon server;
  +    private final int DEFAULT_PORT = 8080;
  +    private static PatternCacheLRU patternCache = new PatternCacheLRU(1000, new 
Perl5Compiler());
  +    transient Perl5Matcher matcher;
  +    public final static String PORT = "ProxyControlGui.port";
  +    public final static String EXCLUDE_LIST = "ProxyControlGui.exclude_list";
  +    public final static String INCLUDE_LIST = "ProxyControlGui.include_list";
  +    /************************************************************
  +     *  !ToDo (Constructor description)
  +     ***********************************************************/
  +    public ProxyControl()
  +    {
  +        matcher = new Perl5Matcher();
  +        setPort(DEFAULT_PORT);
  +        setExcludeList(new HashSet());
  +        setIncludeList(new HashSet());
  +    }
  +    /************************************************************
  +     *  !ToDo (Method description)
  +     *
  +     *@param  port  !ToDo (Parameter description)
  +     ***********************************************************/
  +    public void setPort(int port)
  +    {
  +        this.setProperty(PORT, new Integer(port));
  +    }
  +    public void setIncludeList(Collection list)
  +    {
  +        setProperty(INCLUDE_LIST, new HashSet(list));
  +    }
  +    public void setExcludeList(Collection list)
  +    {
  +        setProperty(EXCLUDE_LIST, new HashSet(list));
  +    }
  +    /************************************************************
  +     *  !ToDoo (Method description)
  +     *
  +     *@return    !ToDo (Return description)
  +     ***********************************************************/
  +    public String getClassLabel()
  +    {
  +        return JMeterUtils.getResString("proxy_title");
  +    }
  +    /************************************************************
  +     *  !ToDoo (Method description)
  +     *
  +     *@return    !ToDo (Return description)
  +     ***********************************************************/
  +    public int getPort()
  +    {
  +        if (this.getProperty(PORT) instanceof String)
  +        {
  +            setPort(Integer.parseInt((String) getProperty(PORT)));
  +            return ((Integer) this.getProperty(PORT)).intValue();
  +        }
  +        else
  +        {
  +            return ((Integer) this.getProperty(PORT)).intValue();
  +        }
  +    }
  +    /************************************************************
  +     *  !ToDoo (Method description)
  +     *
  +     *@return    !ToDo (Return description)
  +     ***********************************************************/
  +    public int getDefaultPort()
  +    {
  +        return DEFAULT_PORT;
  +    }
  +    public Class getGuiClass()
  +    {
  +        return org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.class;
  +    }
   
  -     /************************************************************
  -      *  !ToDo
  -      *
  -      *@param  config  !ToDo
  -      ***********************************************************/
  -     public void addConfigElement(ConfigElement config)
  -     {
  -     }
  -     /************************************************************
  -      *  !ToDo (Method description)
  -      ***********************************************************/
  -     public void startProxy()
  -     {
  -             try
  -             {
  -                     server = new Daemon(getPort(), this);
  -                     server.start();
  -             }
  -             catch (UnknownHostException e)
  -             {
  -                     log.error("", e);
  -             }
  -     }
  -     /************************************************************
  -      *  !ToDo
  -      *
  -      *@param  pattern  !ToDo
  -      ***********************************************************/
  -     public void addExcludedPattern(String pattern)
  -     {
  -             getExcludePatterns().add(pattern);
  -     }
  -     public List getExcludePatterns()
  -     {
  -             return (List) getProperty(EXCLUDE_LIST);
  -     }
  -     /************************************************************
  -      *  !ToDo
  -      *
  -      *@param  pattern  !ToDo
  -      ***********************************************************/
  -     public void addIncludedPattern(String pattern)
  -     {
  -             getIncludePatterns().add(pattern);
  -     }
  -     public List getIncludePatterns()
  -     {
  -             return (List) getProperty(INCLUDE_LIST);
  -     }
  -     /************************************************************
  -      *  !ToDo (Method description)
  -      ***********************************************************/
  -     public void clearExcludedPatterns()
  -     {
  -             getExcludePatterns().clear();
  -     }
  -     /************************************************************
  -      *  !ToDo (Method description)
  -      ***********************************************************/
  -     public void clearIncludedPatterns()
  -     {
  -             getIncludePatterns().clear();
  -     }
  -     
  -     /**
  -      * Receives the recorded sampler from the proxy server for placing in the
  -      * test tree
  -      * @param sampler
  -      * @param subConfigs
  -      * @param serverResponse Added to allow saving of the server's response while
  -      * recording.  A future consideration.
  -      */
  -     public void deliverSampler(HTTPSampler sampler, TestElement[] subConfigs,
  -                     byte[] serverResponse)
  -     {
  -             if (filterUrl(sampler))
  -             {
  -                     placeConfigElement(sampler, subConfigs);
  -             }
  -     }
  -     /************************************************************
  -      *  !ToDo (Method description)
  -      ***********************************************************/
  -     public void stopProxy()
  -     {
  -             if (server != null)
  -             {
  -                     server.stopServer();
  -             }
  -     }
  -     protected boolean filterUrl(HTTPSampler sampler)
  -     {
  -             boolean ok = false;
  -             if (sampler.getDomain() == null || sampler.getDomain().equals(""))
  -             {
  -                     return false;
  -             }
  -             if (getIncludePatterns().size() == 0)
  -             {
  -                     ok = true;
  -             }
  -             else
  -             {
  -                     ok = checkIncludes(sampler);
  -             }
  -             if (!ok)
  -             {
  -                     return ok;
  -             }
  -             else
  -             {
  -                     if (getExcludePatterns().size() == 0)
  -                     {
  -                             return ok;
  -                     }
  -                     else
  -                     {
  -                             ok = checkExcludes(sampler);
  -                     }
  -             }
  -             return ok;
  -     }
  -     private void placeConfigElement(
  -             HTTPSampler sampler,
  -             TestElement[] subConfigs)
  -     {
  -             ValueReplacer replacer = GuiPackage.getInstance().getReplacer();
  -             TestElement urlConfig = null;
  -             JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
  -             List nodes = treeModel.getNodesOfType(RecordingController.class);
  -             if (nodes.size() == 0)
  -             {
  -                     nodes = treeModel.getNodesOfType(ThreadGroup.class);
  -             }
  -             Iterator iter = nodes.iterator();
  -             while (iter.hasNext())
  -             {
  -                     JMeterTreeNode node = (JMeterTreeNode) iter.next();
  +    /************************************************************
  +     *  !ToDo
  +     *
  +     *@param  config  !ToDo
  +     ***********************************************************/
  +    public void addConfigElement(ConfigElement config)
  +    {}
  +    /************************************************************
  +     *  !ToDo (Method description)
  +     ***********************************************************/
  +    public void startProxy()
  +    {
  +        try
  +        {
  +            server = new Daemon(getPort(), this);
  +            server.start();
  +        }
  +        catch (UnknownHostException e)
  +        {
  +            log.error("", e);
  +        }
  +    }
  +    /************************************************************
  +     *  !ToDo
  +     *
  +     *@param  pattern  !ToDo
  +     ***********************************************************/
  +    public void addExcludedPattern(String pattern)
  +    {
  +        getExcludePatterns().add(pattern);
  +    }
  +    public Collection getExcludePatterns()
  +    {
  +        return (Collection) getProperty(EXCLUDE_LIST);
  +    }
  +    /************************************************************
  +     *  !ToDo
  +     *
  +     *@param  pattern  !ToDo
  +     ***********************************************************/
  +    public void addIncludedPattern(String pattern)
  +    {
  +        getIncludePatterns().add(pattern);
  +    }
  +    public Collection getIncludePatterns()
  +    {
  +        return (Collection) getProperty(INCLUDE_LIST);
  +    }
  +    /************************************************************
  +     *  !ToDo (Method description)
  +     ***********************************************************/
  +    public void clearExcludedPatterns()
  +    {
  +        getExcludePatterns().clear();
  +    }
  +    /************************************************************
  +     *  !ToDo (Method description)
  +     ***********************************************************/
  +    public void clearIncludedPatterns()
  +    {
  +        getIncludePatterns().clear();
  +    }
  +
  +    /**
  +     * Receives the recorded sampler from the proxy server for placing in the
  +     * test tree
  +     * @param sampler
  +     * @param subConfigs
  +     * @param serverResponse Added to allow saving of the server's response while
  +     * recording.  A future consideration.
  +     */
  +    public void deliverSampler(HTTPSampler sampler, TestElement[] subConfigs, 
byte[] serverResponse)
  +    {
  +        if (filterUrl(sampler))
  +        {
  +            placeConfigElement(sampler, subConfigs);
  +        }
  +    }
  +    /************************************************************
  +     *  !ToDo (Method description)
  +     ***********************************************************/
  +    public void stopProxy()
  +    {
  +        if (server != null)
  +        {
  +            server.stopServer();
  +        }
  +    }
  +    protected boolean filterUrl(HTTPSampler sampler)
  +    {
  +        boolean ok = false;
  +        if (sampler.getDomain() == null || sampler.getDomain().equals(""))
  +        {
  +            return false;
  +        }
  +        if (getIncludePatterns().size() == 0)
  +        {
  +            ok = true;
  +        }
  +        else
  +        {
  +            ok = checkIncludes(sampler);
  +        }
  +        if (!ok)
  +        {
  +            return ok;
  +        }
  +        else
  +        {
  +            if (getExcludePatterns().size() == 0)
  +            {
  +                return ok;
  +            }
  +            else
  +            {
  +                ok = checkExcludes(sampler);
  +            }
  +        }
  +        return ok;
  +    }
  +    private void placeConfigElement(HTTPSampler sampler, TestElement[] subConfigs)
  +    {
  +        ValueReplacer replacer = GuiPackage.getInstance().getReplacer();
  +        TestElement urlConfig = null;
  +        JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
  +        List nodes = treeModel.getNodesOfType(RecordingController.class);
  +        if (nodes.size() == 0)
  +        {
  +            nodes = treeModel.getNodesOfType(ThreadGroup.class);
  +        }
  +        Iterator iter = nodes.iterator();
  +        while (iter.hasNext())
  +        {
  +            JMeterTreeNode node = (JMeterTreeNode) iter.next();
   
  -            if (! node.isEnabled()) {
  +            if (!node.isEnabled())
  +            {
                   continue;
  -            } else {
  +            }
  +            else
  +            {
                   Enumeration enum = node.children();
                   while (enum.hasMoreElements())
                   {
                       JMeterTreeNode subNode = (JMeterTreeNode) enum.nextElement();
  -                    TestElement sample =
  -                        (TestElement) subNode.createTestElement();
  -                    if (sample.getPropertyAsString(TestElement.GUI_CLASS).equals(
  -                                                                     
"org.apache.jmeter.protocol.http.config.gui.UrlConfigGui"))
  +                    TestElement sample = (TestElement) subNode.createTestElement();
  +                    if 
(sample.getPropertyAsString(TestElement.GUI_CLASS).equals("org.apache.jmeter.protocol.http.config.gui.UrlConfigGui"))
                       {
                           urlConfig = sample;
                           break;
  @@ -330,7 +326,7 @@
                       replacer.reverseReplace(sampler);
                       HttpTestSampleGui test = new HttpTestSampleGui();
                       test.configure(sampler);
  -                    sampler = (HTTPSampler)test.createTestElement();
  +                    sampler = (HTTPSampler) test.createTestElement();
                       try
                       {
                           JMeterTreeNode newNode = treeModel.addComponent(sampler, 
node);
  @@ -353,116 +349,98 @@
                   return;
               }
           }
  -     }
  -     private void removeValuesFromSampler(
  -             HTTPSampler sampler,
  -             TestElement urlConfig)
  -     {
  -             if (urlConfig != null
  -                     && 
sampler.getDomain().equals(urlConfig.getProperty(HTTPSampler.DOMAIN)))
  -             {
  -                     sampler.setDomain("");
  -             }
  -             if (urlConfig != null
  -                     && 
sampler.getPath().equals(urlConfig.getProperty(HTTPSampler.PATH)))
  -             {
  -                     sampler.setPath("");
  -             }
  -     }
  -     private boolean areMatched(HTTPSampler sampler, TestElement urlConfig)
  -     {
  -             return urlConfig == null
  -                     || (urlConfig.getProperty(HTTPSampler.DOMAIN) == null
  -                             || urlConfig.getProperty(HTTPSampler.DOMAIN).equals("")
  -                             || 
urlConfig.getProperty(HTTPSampler.DOMAIN).equals(sampler.getDomain()))
  -                     && (urlConfig.getProperty(HTTPSampler.PATH) == null
  -                             || urlConfig.getProperty(HTTPSampler.PATH).equals("")
  -                             || 
urlConfig.getProperty(HTTPSampler.PATH).equals(sampler.getPath()));
  -     }
  -     private boolean checkIncludes(HTTPSampler sampler)
  -     {
  -             boolean ok = false;
  -             Iterator iter = getIncludePatterns().iterator();
  -             while (iter.hasNext())
  -             {
  -                     String item = (String) iter.next();
  -                     try
  -                     {
  -                             Pattern pattern = compiler.compile(item);
  -                             StringBuffer url = new 
StringBuffer(sampler.getDomain());
  -                             url.append(":");
  -                             url.append(sampler.getPort());
  -                             url.append(sampler.getPath());
  -                             if (sampler.getQueryString().length() > 0)
  -                             {
  -                                     url.append("?");
  -                                     url.append(sampler.getQueryString());
  -                             }
  -                             ok = matcher.matches(url.toString(), pattern);
  -                     }
  -                     catch (MalformedPatternException e)
  -                     {
  -                             JMeterUtils.reportErrorToUser("Bad Regular expression: 
" + item);
  -                     }
  -                     if (ok)
  -                     {
  -                             break;
  -                     }
  -             }
  -             return ok;
  -     }
  -     private boolean checkExcludes(HTTPSampler sampler)
  -     {
  -             boolean ok = true;
  -             Iterator iter = getExcludePatterns().iterator();
  -             while (iter.hasNext())
  -             {
  -                     String item = (String) iter.next();
  -                     try
  -                     {
  -                             Pattern pattern = compiler.compile(item);
  -                             StringBuffer url = new 
StringBuffer(sampler.getDomain());
  -                             url.append(":");
  -                             url.append(sampler.getPort());
  -                             url.append(sampler.getPath());
  -                             if (sampler.getQueryString().length() > 0)
  -                             {
  -                                     url.append("?");
  -                                     url.append(sampler.getQueryString());
  -                             }
  -                             ok = ok && !matcher.matches(url.toString(), pattern);
  -                     }
  -                     catch (MalformedPatternException e)
  -                     {
  -                             JMeterUtils.reportErrorToUser("Bad Regular expression: 
" + item);
  -                     }
  -                     if (!ok)
  -                     {
  -                             return ok;
  -                     }
  -             }
  -             return ok;
  -     }
  -     public static class Test extends TestCase
  -     {
  -             public Test(String name)
  -             {
  -                     super(name);
  -             }
  -             public void testFiltering() throws Exception
  -             {
  -                     ProxyControl control = new ProxyControl();
  -                     control.addIncludedPattern(".*\\.jsp");
  -                     control.addExcludedPattern(".*apache.org.*");
  -                     HTTPSampler sampler = new HTTPSampler();
  -                     sampler.setDomain("jakarta.org");
  -                     sampler.setPath("index.jsp");
  -                     assertTrue(control.filterUrl(sampler));
  -                     sampler.setDomain("www.apache.org");
  -                     assertTrue(!control.filterUrl(sampler));
  -                     sampler.setPath("header.gif");
  -                     sampler.setDomain("jakarta.org");
  -                     assertTrue(!control.filterUrl(sampler));
  -             }
  -     }
  +    }
  +    private void removeValuesFromSampler(HTTPSampler sampler, TestElement urlConfig)
  +    {
  +        if (urlConfig != null && 
sampler.getDomain().equals(urlConfig.getProperty(HTTPSampler.DOMAIN)))
  +        {
  +            sampler.setDomain("");
  +        }
  +        if (urlConfig != null && 
sampler.getPath().equals(urlConfig.getProperty(HTTPSampler.PATH)))
  +        {
  +            sampler.setPath("");
  +        }
  +    }
  +    private boolean areMatched(HTTPSampler sampler, TestElement urlConfig)
  +    {
  +        return urlConfig == null
  +            || (urlConfig.getProperty(HTTPSampler.DOMAIN) == null
  +                || urlConfig.getProperty(HTTPSampler.DOMAIN).equals("")
  +                || 
urlConfig.getProperty(HTTPSampler.DOMAIN).equals(sampler.getDomain()))
  +            && (urlConfig.getProperty(HTTPSampler.PATH) == null
  +                || urlConfig.getProperty(HTTPSampler.PATH).equals("")
  +                || 
urlConfig.getProperty(HTTPSampler.PATH).equals(sampler.getPath()));
  +    }
  +    private boolean checkIncludes(HTTPSampler sampler)
  +    {
  +        boolean ok = false;
  +        Iterator iter = getIncludePatterns().iterator();
  +        while (iter.hasNext())
  +        {
  +            String item = (String) iter.next();
  +            Pattern pattern = patternCache.getPattern(item, 
Perl5Compiler.READ_ONLY_MASK & Perl5Compiler.SINGLELINE_MASK);
  +            StringBuffer url = new StringBuffer(sampler.getDomain());
  +            url.append(":");
  +            url.append(sampler.getPort());
  +            url.append(sampler.getPath());
  +            if (sampler.getQueryString().length() > 0)
  +            {
  +                url.append("?");
  +                url.append(sampler.getQueryString());
  +            }
  +            ok = matcher.matches(url.toString(), pattern);
  +            if (ok)
  +            {
  +                break;
  +            }
  +        }
  +        return ok;
  +    }
  +    private boolean checkExcludes(HTTPSampler sampler)
  +    {
  +        boolean ok = true;
  +        Iterator iter = getExcludePatterns().iterator();
  +        while (iter.hasNext())
  +        {
  +            String item = (String) iter.next();
  +            Pattern pattern = patternCache.getPattern(item, 
Perl5Compiler.READ_ONLY_MASK & Perl5Compiler.SINGLELINE_MASK);
  +            StringBuffer url = new StringBuffer(sampler.getDomain());
  +            url.append(":");
  +            url.append(sampler.getPort());
  +            url.append(sampler.getPath());
  +            if (sampler.getQueryString().length() > 0)
  +            {
  +                url.append("?");
  +                url.append(sampler.getQueryString());
  +            }
  +            ok = ok && !matcher.matches(url.toString(), pattern);
  +            if (!ok)
  +            {
  +                return ok;
  +            }
  +        }
  +        return ok;
  +    }
  +    public static class Test extends TestCase
  +    {
  +        public Test(String name)
  +        {
  +            super(name);
  +        }
  +        public void testFiltering() throws Exception
  +        {
  +            ProxyControl control = new ProxyControl();
  +            control.addIncludedPattern(".*\\.jsp");
  +            control.addExcludedPattern(".*apache.org.*");
  +            HTTPSampler sampler = new HTTPSampler();
  +            sampler.setDomain("jakarta.org");
  +            sampler.setPath("index.jsp");
  +            assertTrue(control.filterUrl(sampler));
  +            sampler.setDomain("www.apache.org");
  +            assertTrue(!control.filterUrl(sampler));
  +            sampler.setPath("header.gif");
  +            sampler.setDomain("jakarta.org");
  +            assertTrue(!control.filterUrl(sampler));
  +        }
  +    }
   }
  
  
  
  1.7       +414 -408  
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
  
  Index: ProxyControlGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProxyControlGui.java      3 Feb 2003 16:08:36 -0000       1.6
  +++ ProxyControlGui.java      7 Feb 2003 00:36:25 -0000       1.7
  @@ -94,6 +94,8 @@
   import org.apache.jmeter.protocol.http.proxy.ProxyControl;
   import org.apache.jmeter.testelement.TestElement;
   import org.apache.jmeter.util.JMeterUtils;
  +import org.apache.log.Hierarchy;
  +import org.apache.log.Logger;
   
   /****************************************
    * Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
  @@ -104,423 +106,427 @@
    *@version   1.0
    ***************************************/
   
  -public class ProxyControlGui extends JPanel implements JMeterGUIComponent, 
ActionListener,
  -             KeyListener,FocusListener,UnsharedComponent
  +public class ProxyControlGui extends JPanel implements JMeterGUIComponent, 
ActionListener, KeyListener, FocusListener, UnsharedComponent
   {
  +    transient private static Logger log =
  +            Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.gui");
  +    NamePanel namePanel;
  +    JTextField portField;
  +
  +    ProxyControl model;
  +
  +    JTable excludeTable;
  +    PowerTableModel excludeModel;
  +    JTable includeTable;
  +    PowerTableModel includeModel;
  +    JButton addExclude, deleteExclude, addInclude, deleteInclude;
  +
  +    JButton stop, start, restart;
  +    private final static String STOP = "stop";
  +    private final static String START = "start";
  +    private final static String RESTART = "restart";
  +    private final static String ADD_INCLUDE = "add_include";
  +    private final static String ADD_EXCLUDE = "add_exclude";
  +    private final static String DELETE_INCLUDE = "delete_include";
  +    private final static String DELETE_EXCLUDE = "delete_exclude";
  +
  +    private final static String INCLUDE_COL = 
JMeterUtils.getResString("patterns_to_include");
  +    private final static String EXCLUDE_COL = 
JMeterUtils.getResString("patterns_to_exclude");
  +
  +    /****************************************
  +     * !ToDo (Constructor description)
  +     ***************************************/
  +    public ProxyControlGui()
  +    {
  +        namePanel = new NamePanel();
  +        setName(getStaticLabel());
  +        init();
  +    }
  +
  +    public JPopupMenu createPopupMenu()
  +    {
  +        return MenuFactory.getDefaultTimerMenu();
  +    }
  +
  +    public TestElement createTestElement()
  +    {
  +        if (model == null)
  +        {
  +            model = new ProxyControl();
  +            model.setProperty(TestElement.GUI_CLASS, this.getClass().getName());
  +            model.setProperty(TestElement.TEST_CLASS, model.getClass().getName());
  +        }
  +        log.debug("creating/configuring model = " + model);
  +        model.setProperty(TestElement.NAME, getName());
  +        model.setPort(Integer.parseInt(portField.getText()));
  +        setIncludeListInProxyControl(model);
  +        setExcludeListInProxyControl(model);
  +        return model;
  +    }
  +
  +    protected void setIncludeListInProxyControl(ProxyControl element)
  +    {
  +        List includeList = getDataList(includeModel, INCLUDE_COL);
  +        element.setIncludeList(includeList);
  +    }
  +
  +    protected void setExcludeListInProxyControl(ProxyControl element)
  +    {
  +        List excludeList = getDataList(excludeModel, EXCLUDE_COL);
  +        element.setExcludeList(excludeList);
  +    }
  +
  +    private List getDataList(PowerTableModel model, String colName)
  +    {
  +        String[] dataArray = model.getData().getColumn(colName);
  +        List list = new LinkedList();
  +        for (int i = 0; i < dataArray.length; i++)
  +        {
  +            list.add(dataArray[i]);
  +        }
  +        return list;
  +    }
  +
  +    public void setName(String name)
  +    {
  +        super.setName(name);
  +        namePanel.setName(name);
  +    }
  +
  +    public String getName()
  +    {
  +        return namePanel.getName();
  +    }
  +
  +    public String getStaticLabel()
  +    {
  +        return JMeterUtils.getResString("proxy_title");
  +    }
  +
  +    public Collection getMenuCategories()
  +    {
  +        return Arrays.asList(new String[] { MenuFactory.NON_TEST_ELEMENTS });
  +    }
   
  -     NamePanel namePanel;
  -     JTextField portField;
  +    public void configure(TestElement element)
  +    {
  +        log.debug("Configuring gui with " + element);
  +        if (model != null && model != element)
  +        {
  +            model.addTestElement(element);
  +        }
  +        if(model == null)
  +        {
  +            model = (ProxyControl)element;
  +        }
  +        setName(model.getProperty(TestElement.NAME).toString());
  +        portField.setText(model.getProperty(ProxyControl.PORT).toString());
  +        populateTable(includeModel, model.getIncludePatterns().iterator());
  +        populateTable(excludeModel, model.getExcludePatterns().iterator());
  +        repaint();
  +    }
   
  -     ProxyControl model;
  +    private void populateTable(PowerTableModel model, Iterator iter)
  +    {
  +        model.clearData();
  +        while (iter.hasNext())
  +        {
  +            model.addRow(new Object[] { iter.next()});
  +        }
  +        model.fireTableDataChanged();
  +    }
   
  -     JTable excludeTable;
  -     PowerTableModel excludeModel;
  -     JTable includeTable;
  -     PowerTableModel includeModel;
  -     JButton addExclude,deleteExclude,addInclude,deleteInclude;
  -
  -     JButton stop, start,restart;
  -     private final static String STOP = "stop";
  -     private final static String START = "start";
  -     private final static String RESTART = "restart";
  -     private final static String ADD_INCLUDE = "add_include";
  -     private final static String ADD_EXCLUDE = "add_exclude";
  -     private final static String DELETE_INCLUDE = "delete_include";
  -     private final static String DELETE_EXCLUDE = "delete_exclude";
  -
  -     private final static String INCLUDE_COL = 
JMeterUtils.getResString("patterns_to_include");
  -     private final static String EXCLUDE_COL = 
JMeterUtils.getResString("patterns_to_exclude");
  -
  -     /****************************************
  -      * !ToDo (Constructor description)
  -      ***************************************/
  -     public ProxyControlGui()
  -     {
  -             namePanel = new NamePanel();
  -             setName(getStaticLabel());
  -             init();
  -     }
  -
  -     public JPopupMenu createPopupMenu()
  -     {
  -             return MenuFactory.getDefaultTimerMenu();
  -     }
  -
  -     public TestElement createTestElement()
  -     {
  -             if(model == null)
  -             {
  -                     model = new ProxyControl();
  -                     model.setProperty(TestElement.GUI_CLASS, 
this.getClass().getName());
  -                     model.setProperty(TestElement.TEST_CLASS, 
model.getClass().getName());
  -             }
  -             model.setProperty(TestElement.NAME,getName());
  -             model.setPort(Integer.parseInt(portField.getText()));
  -             setIncludeListInProxyControl(model);
  -             setExcludeListInProxyControl(model);
  -             return model;
  -     }
  -
  -     protected void setIncludeListInProxyControl(ProxyControl element) {
  -             List includeList = getDataList(includeModel,INCLUDE_COL);
  -             element.setIncludeList(includeList);
  -     }
  -
  -     protected void setExcludeListInProxyControl(ProxyControl element)
  -     {
  -             List excludeList = getDataList(excludeModel,EXCLUDE_COL);
  -             element.setExcludeList(excludeList);
  -     }
  -
  -     private List getDataList(PowerTableModel model,String colName) {
  -             String[] dataArray = model.getData().getColumn(colName);
  -             List list = new LinkedList();
  -             for(int i = 0;i < dataArray.length;i++)
  -             {
  -                     list.add(dataArray[i]);
  -             }
  -             return list;
  -     }
  -
  -
  -
  -     public void setName(String name)
  -     {
  -             super.setName(name);
  -             namePanel.setName(name);
  -     }
  -
  -     public String getName()
  -     {
  -             return namePanel.getName();
  -     }
  -
  -     public String getStaticLabel()
  -     {
  -             return JMeterUtils.getResString("proxy_title");
  -     }
  -
  -     public Collection getMenuCategories()
  -     {
  -             return Arrays.asList(new String[]{MenuFactory.NON_TEST_ELEMENTS});
  -     }
  -
  -     public void configure(TestElement element)
  -     {
  -             ProxyControl el = (ProxyControl)element;
  -             setName(element.getProperty(TestElement.NAME).toString());
  -             portField.setText(element.getProperty(ProxyControl.PORT).toString());
  -             populateTable(includeModel,el.getIncludePatterns().iterator());
  -             populateTable(excludeModel,el.getExcludePatterns().iterator());
  -             model = el;
  -     }
  -
  -     private void populateTable(PowerTableModel model,Iterator iter) {
  -             while(iter.hasNext())
  -             {
  -                     model.addRow(new Object[]{iter.next()});
  -             }
  -     }
  -
  -     public void focusLost(FocusEvent e)
  -     {
  -             try
  -             {
  -                     ((JTable)e.getSource()).getCellEditor().stopCellEditing();
  -             }
  -             catch(Exception err)
  -             {
  -             }
  -     }
  -
  -     public void focusGained(FocusEvent e)
  -     {
  -     }
  -
  -     /****************************************
  -      * !ToDo (Method description)
  -      *
  -      *@param action  !ToDo (Parameter description)
  -      ***************************************/
  -     public void actionPerformed(ActionEvent action)
  -     {
  -             String command = action.getActionCommand();
  -
  -             if(command.equals(STOP))
  -             {
  -                     model.stopProxy();
  -                     stop.setEnabled(false);
  -                     start.setEnabled(true);
  -                     model = null;
  -             }
  -             else if(command.equals(START))
  -             {
  -                     model = (ProxyControl)createTestElement();
  -                     startProxy();
  -             }
  -             else if(command.equals(RESTART))
  -             {
  -                     model.stopProxy();
  -                     model = (ProxyControl)createTestElement();
  -                     startProxy();
  -             }
  -             else if(command.equals(this.ADD_EXCLUDE))
  -             {
  -                     excludeModel.addNewRow();
  -                     excludeModel.fireTableDataChanged();
  -                     if(model != null)
  -                     enableRestart();
  -             }
  -             else if(command.equals(this.ADD_INCLUDE))
  -             {
  -                     includeModel.addNewRow();
  -                     includeModel.fireTableDataChanged();
  -                     enableRestart();
  -             }
  -             else if(command.equals(this.DELETE_EXCLUDE))
  -             {
  -                     excludeModel.removeRow(excludeTable.getSelectedRow());
  -                     excludeModel.fireTableDataChanged();
  -                     enableRestart();
  -             }
  -             else if(command.equals(this.DELETE_INCLUDE))
  -             {
  -                     includeModel.removeRow(includeTable.getSelectedRow());
  -                     includeModel.fireTableDataChanged();
  -                     enableRestart();
  -             }
  -     }
  -
  -     private void startProxy()
  -     {
  -             ValueReplacer replacer = GuiPackage.getInstance().getReplacer();
  -             try
  -             {
  -                     replacer.replaceValues(model);
  -                     model.startProxy();
  -                     start.setEnabled(false);
  -                     stop.setEnabled(true);
  -                     restart.setEnabled(false);
  -             }
  -             catch (InvalidVariableException e)
  -             {
  -                     JOptionPane.showMessageDialog(this,JMeterUtils.getResString(
  -                                     
"invalid_variables"),"Error",JOptionPane.ERROR_MESSAGE);
  -             }
  -     }
  -
  -     private void enableRestart()
  -     {
  -             if(stop.isEnabled())
  -             {
  -                     restart.setEnabled(true);
  -             }
  -     }
  -
  -     /****************************************
  -      * !ToDo (Method description)
  -      *
  -      *@param e  !ToDo (Parameter description)
  -      ***************************************/
  -     public void keyPressed(KeyEvent e) { }
  -
  -     /****************************************
  -      * !ToDo (Method description)
  -      *
  -      *@param e  !ToDo (Parameter description)
  -      ***************************************/
  -     public void keyTyped(KeyEvent e) { }
  -
  -     /****************************************
  -      * !ToDo (Method description)
  -      *
  -      *@param e  !ToDo (Parameter description)
  -      ***************************************/
  -     public void keyReleased(KeyEvent e)
  -     {
  -             String fieldName = e.getComponent().getName();
  -
  -             if(fieldName.equals(ProxyControl.PORT))
  -             {
  -                     try
  -                     {
  -                             Integer.parseInt(portField.getText());
  -                     }
  -                     catch(NumberFormatException nfe)
  -                     {
  -                             if(portField.getText().length() > 0)
  -                             {
  -                                     JOptionPane.showMessageDialog(this, "You must 
enter a valid number",
  -                                                     "Invalid data", 
JOptionPane.WARNING_MESSAGE);
  -
  -                                     // Right now, the cleanest thing to do is 
simply clear the
  -                                     // entire text field. We do not want to set 
the text to
  -                                     // the default because that would be confusing 
to the user.
  -                                     // For example, the user typed "5t" instead of 
"56". After
  -                                     // the user closes the error dialog, the text 
would change
  -                                     // from "5t" to "1".  A litle confusing. If 
anything, it
  -                                     // should display just "5". Future 
enhancement...
  -                                     portField.setText("");
  -                             }
  -                     }
  -             }
  -     }
  -
  -     private void init()
  -     {
  -             this.setLayout(new GridBagLayout());
  -             GridBagConstraints gbc = new GridBagConstraints();
  -             gbc.anchor = gbc.WEST;
  -             gbc.fill = gbc.BOTH;
  -             gbc.gridheight = 1;
  -             gbc.gridwidth = 1;
  -             gbc.gridx = 0;
  -             gbc.gridy = 0;
  -             gbc.weightx = 1;
  -             gbc.weighty = 1;
  -
  -             // MAIN PANEL
  -             JPanel mainPanel = new JPanel();
  -             add(mainPanel,gbc.clone());
  -             Border margin = new EmptyBorder(10, 10, 5, 10);
  -             mainPanel.setBorder(margin);
  -             mainPanel.setLayout(new GridBagLayout());
  -             //gbc.fill = gbc.NONE;
  -             gbc.weighty = 0;
  -
  -             // TITLE
  -             JLabel panelTitleLabel = new 
JLabel(JMeterUtils.getResString("proxy_title"));
  -             Font curFont = panelTitleLabel.getFont();
  -             int curFontSize = curFont.getSize();
  -             curFontSize += 4;
  -             panelTitleLabel.setFont(new Font(curFont.getFontName(), 
curFont.getStyle(), curFontSize));
  -             mainPanel.add(panelTitleLabel,gbc.clone());
  -             gbc.gridy++;
  -
  -             // NAME
  -             mainPanel.add(namePanel,gbc.clone());
  -             gbc.gridy++;
  -
  -             mainPanel.add(createPortPanel(),gbc.clone());
  -             gbc.gridy++;
  -             gbc.fill = gbc.BOTH;
  -             gbc.weighty = .5;
  -             mainPanel.add(createIncludePanel(),gbc.clone());
  -             gbc.gridy++;
  -             mainPanel.add(createExcludePanel(),gbc.clone());
  -             gbc.gridy++;
  -             gbc.fill = gbc.NONE;
  -             gbc.weighty = 0;
  -             mainPanel.add(createControls(),gbc.clone());
  -
  -     }
  -
  -     private JPanel createControls()
  -     {
  -             JPanel panel = new JPanel();
  -
  -             start = new JButton(JMeterUtils.getResString("start"));
  -             start.addActionListener(this);
  -             start.setActionCommand(START);
  -
  -             stop = new JButton(JMeterUtils.getResString("stop"));
  -             stop.addActionListener(this);
  -             stop.setActionCommand(STOP);
  -
  -             restart = new JButton(JMeterUtils.getResString("restart"));
  -             restart.addActionListener(this);
  -             restart.setActionCommand(RESTART);
  -
  -             panel.add(start);
  -             panel.add(stop);
  -             panel.add(restart);
  -             start.setEnabled(true);
  -             stop.setEnabled(false);
  -             restart.setEnabled(false);
  -
  -             return panel;
  -     }
  -
  -     private JPanel createPortPanel()
  -     {
  -             JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
  -
  -             panel.add(new JLabel(JMeterUtils.getResString("port")));
  -
  -             portField = new JTextField(8);
  -             portField.setName(ProxyControl.PORT);
  -             portField.addKeyListener(this);
  -             portField.setText("8080");
  -             panel.add(portField);
  -             panel.revalidate();
  -             return panel;
  -     }
  -
  -     private JPanel createIncludePanel()
  -     {
  -             JPanel panel = new JPanel(new BorderLayout());
  -             
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
  -                             JMeterUtils.getResString("patterns_to_include")));
  -             includeTable = new JTable();
  -             includeModel = new PowerTableModel(new String[]{INCLUDE_COL},
  -                                     new Class[]{String.class});
  -             JScrollPane scroller = new JScrollPane(includeTable);
  -             scroller.setBackground(panel.getBackground());
  -             includeTable.setModel(includeModel);
  -             addInclude = new JButton(JMeterUtils.getResString("add"));
  -             deleteInclude = new JButton(JMeterUtils.getResString("delete"));
  -             addInclude.setActionCommand(ADD_INCLUDE);
  -             deleteInclude.setActionCommand(DELETE_INCLUDE);
  -             addInclude.addActionListener(this);
  -             deleteInclude.addActionListener(this);
  -             panel.add(scroller,BorderLayout.CENTER);
  -             JPanel buttonPanel = new JPanel();
  -             buttonPanel.add(addInclude);
  -             buttonPanel.add(deleteInclude);
  -             panel.add(buttonPanel,BorderLayout.SOUTH);
  -             includeTable.addFocusListener(this);
  -             return panel;
  -     }
  -
  -     private JPanel createExcludePanel()
  -     {
  -             JPanel panel = new JPanel(new BorderLayout());
  -             
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
  -                             JMeterUtils.getResString("patterns_to_exclude")));
  -             excludeTable = new JTable();
  -             excludeModel = new PowerTableModel(new String[]{EXCLUDE_COL},
  -                                     new Class[]{String.class});
  -             JScrollPane scroller = new JScrollPane(excludeTable);
  -             scroller.setBackground(panel.getBackground());
  -             excludeTable.setModel(excludeModel);
  -             addExclude = new JButton(JMeterUtils.getResString("add"));
  -             deleteExclude = new JButton(JMeterUtils.getResString("delete"));
  -             addExclude.setActionCommand(ADD_EXCLUDE);
  -             deleteExclude.setActionCommand(DELETE_EXCLUDE);
  -             addExclude.addActionListener(this);
  -             deleteExclude.addActionListener(this);
  -             panel.add(scroller,BorderLayout.CENTER);
  -             JPanel buttonPanel = new JPanel();
  -             buttonPanel.add(addExclude);
  -             buttonPanel.add(deleteExclude);
  -             panel.add(buttonPanel,BorderLayout.SOUTH);
  -             excludeTable.addFocusListener(this);
  -             return panel;
  -     }
  +    public void focusLost(FocusEvent e)
  +    {
  +        try
  +        {
  +            ((JTable) e.getSource()).getCellEditor().stopCellEditing();
  +        }
  +        catch (Exception err)
  +        {}
  +    }
   
  +    public void focusGained(FocusEvent e)
  +    {}
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@param action  !ToDo (Parameter description)
  +     ***************************************/
  +    public void actionPerformed(ActionEvent action)
  +    {
  +        String command = action.getActionCommand();
  +
  +        if (command.equals(STOP))
  +        {
  +            model.stopProxy();
  +            stop.setEnabled(false);
  +            start.setEnabled(true);
  +        }
  +        else if (command.equals(START))
  +        {
  +            model = (ProxyControl) createTestElement();
  +            startProxy();
  +        }
  +        else if (command.equals(RESTART))
  +        {
  +            model.stopProxy();
  +            model = (ProxyControl) createTestElement();
  +            startProxy();
  +        }
  +        else if (command.equals(this.ADD_EXCLUDE))
  +        {
  +            excludeModel.addNewRow();
  +            excludeModel.fireTableDataChanged();
  +            if (stop.isEnabled())
  +                enableRestart();
  +        }
  +        else if (command.equals(this.ADD_INCLUDE))
  +        {
  +            includeModel.addNewRow();
  +            includeModel.fireTableDataChanged();
  +            enableRestart();
  +        }
  +        else if (command.equals(this.DELETE_EXCLUDE))
  +        {
  +            excludeModel.removeRow(excludeTable.getSelectedRow());
  +            excludeModel.fireTableDataChanged();
  +            enableRestart();
  +        }
  +        else if (command.equals(this.DELETE_INCLUDE))
  +        {
  +            includeModel.removeRow(includeTable.getSelectedRow());
  +            includeModel.fireTableDataChanged();
  +            enableRestart();
  +        }
  +    }
  +
  +    private void startProxy()
  +    {
  +        ValueReplacer replacer = GuiPackage.getInstance().getReplacer();
  +        try
  +        {
  +            replacer.replaceValues(model);
  +            model.startProxy();
  +            start.setEnabled(false);
  +            stop.setEnabled(true);
  +            restart.setEnabled(false);
  +        }
  +        catch (InvalidVariableException e)
  +        {
  +            JOptionPane.showMessageDialog(this, 
JMeterUtils.getResString("invalid_variables"), "Error", JOptionPane.ERROR_MESSAGE);
  +        }
  +    }
  +
  +    private void enableRestart()
  +    {
  +        if (stop.isEnabled())
  +        {
  +            restart.setEnabled(true);
  +        }
  +    }
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@param e  !ToDo (Parameter description)
  +     ***************************************/
  +    public void keyPressed(KeyEvent e)
  +    {}
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@param e  !ToDo (Parameter description)
  +     ***************************************/
  +    public void keyTyped(KeyEvent e)
  +    {}
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@param e  !ToDo (Parameter description)
  +     ***************************************/
  +    public void keyReleased(KeyEvent e)
  +    {
  +        String fieldName = e.getComponent().getName();
  +
  +        if (fieldName.equals(ProxyControl.PORT))
  +        {
  +            try
  +            {
  +                Integer.parseInt(portField.getText());
  +            }
  +            catch (NumberFormatException nfe)
  +            {
  +                if (portField.getText().length() > 0)
  +                {
  +                    JOptionPane.showMessageDialog(this, "You must enter a valid 
number", "Invalid data", JOptionPane.WARNING_MESSAGE);
  +
  +                    // Right now, the cleanest thing to do is simply clear the
  +                    // entire text field. We do not want to set the text to
  +                    // the default because that would be confusing to the user.
  +                    // For example, the user typed "5t" instead of "56". After
  +                    // the user closes the error dialog, the text would change
  +                    // from "5t" to "1".  A litle confusing. If anything, it
  +                    // should display just "5". Future enhancement...
  +                    portField.setText("");
  +                }
  +            }
  +        }
  +    }
  +
  +    private void init()
  +    {
  +        this.setLayout(new GridBagLayout());
  +        GridBagConstraints gbc = new GridBagConstraints();
  +        gbc.anchor = gbc.WEST;
  +        gbc.fill = gbc.BOTH;
  +        gbc.gridheight = 1;
  +        gbc.gridwidth = 1;
  +        gbc.gridx = 0;
  +        gbc.gridy = 0;
  +        gbc.weightx = 1;
  +        gbc.weighty = 1;
  +
  +        // MAIN PANEL
  +        JPanel mainPanel = new JPanel();
  +        add(mainPanel, gbc.clone());
  +        Border margin = new EmptyBorder(10, 10, 5, 10);
  +        mainPanel.setBorder(margin);
  +        mainPanel.setLayout(new GridBagLayout());
  +        //gbc.fill = gbc.NONE;
  +        gbc.weighty = 0;
  +
  +        // TITLE
  +        JLabel panelTitleLabel = new 
JLabel(JMeterUtils.getResString("proxy_title"));
  +        Font curFont = panelTitleLabel.getFont();
  +        int curFontSize = curFont.getSize();
  +        curFontSize += 4;
  +        panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), 
curFontSize));
  +        mainPanel.add(panelTitleLabel, gbc.clone());
  +        gbc.gridy++;
  +
  +        // NAME
  +        mainPanel.add(namePanel, gbc.clone());
  +        gbc.gridy++;
  +
  +        mainPanel.add(createPortPanel(), gbc.clone());
  +        gbc.gridy++;
  +        gbc.fill = gbc.BOTH;
  +        gbc.weighty = .5;
  +        mainPanel.add(createIncludePanel(), gbc.clone());
  +        gbc.gridy++;
  +        mainPanel.add(createExcludePanel(), gbc.clone());
  +        gbc.gridy++;
  +        gbc.fill = gbc.NONE;
  +        gbc.weighty = 0;
  +        mainPanel.add(createControls(), gbc.clone());
  +
  +    }
  +
  +    private JPanel createControls()
  +    {
  +        JPanel panel = new JPanel();
  +
  +        start = new JButton(JMeterUtils.getResString("start"));
  +        start.addActionListener(this);
  +        start.setActionCommand(START);
  +
  +        stop = new JButton(JMeterUtils.getResString("stop"));
  +        stop.addActionListener(this);
  +        stop.setActionCommand(STOP);
  +
  +        restart = new JButton(JMeterUtils.getResString("restart"));
  +        restart.addActionListener(this);
  +        restart.setActionCommand(RESTART);
  +
  +        panel.add(start);
  +        panel.add(stop);
  +        panel.add(restart);
  +        start.setEnabled(true);
  +        stop.setEnabled(false);
  +        restart.setEnabled(false);
  +
  +        return panel;
  +    }
  +
  +    private JPanel createPortPanel()
  +    {
  +        JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
  +
  +        panel.add(new JLabel(JMeterUtils.getResString("port")));
  +
  +        portField = new JTextField(8);
  +        portField.setName(ProxyControl.PORT);
  +        portField.addKeyListener(this);
  +        portField.setText("8080");
  +        panel.add(portField);
  +        panel.revalidate();
  +        return panel;
  +    }
  +
  +    private JPanel createIncludePanel()
  +    {
  +        JPanel panel = new JPanel(new BorderLayout());
  +        
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), 
JMeterUtils.getResString("patterns_to_include")));
  +        includeTable = new JTable();
  +        includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new 
Class[] { String.class });
  +        JScrollPane scroller = new JScrollPane(includeTable);
  +        scroller.setBackground(panel.getBackground());
  +        includeTable.setModel(includeModel);
  +        addInclude = new JButton(JMeterUtils.getResString("add"));
  +        deleteInclude = new JButton(JMeterUtils.getResString("delete"));
  +        addInclude.setActionCommand(ADD_INCLUDE);
  +        deleteInclude.setActionCommand(DELETE_INCLUDE);
  +        addInclude.addActionListener(this);
  +        deleteInclude.addActionListener(this);
  +        panel.add(scroller, BorderLayout.CENTER);
  +        JPanel buttonPanel = new JPanel();
  +        buttonPanel.add(addInclude);
  +        buttonPanel.add(deleteInclude);
  +        panel.add(buttonPanel, BorderLayout.SOUTH);
  +        includeTable.addFocusListener(this);
  +        return panel;
  +    }
  +
  +    private JPanel createExcludePanel()
  +    {
  +        JPanel panel = new JPanel(new BorderLayout());
  +        
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), 
JMeterUtils.getResString("patterns_to_exclude")));
  +        excludeTable = new JTable();
  +        excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new 
Class[] { String.class });
  +        JScrollPane scroller = new JScrollPane(excludeTable);
  +        scroller.setBackground(panel.getBackground());
  +        excludeTable.setModel(excludeModel);
  +        addExclude = new JButton(JMeterUtils.getResString("add"));
  +        deleteExclude = new JButton(JMeterUtils.getResString("delete"));
  +        addExclude.setActionCommand(ADD_EXCLUDE);
  +        deleteExclude.setActionCommand(DELETE_EXCLUDE);
  +        addExclude.addActionListener(this);
  +        deleteExclude.addActionListener(this);
  +        panel.add(scroller, BorderLayout.CENTER);
  +        JPanel buttonPanel = new JPanel();
  +        buttonPanel.add(addExclude);
  +        buttonPanel.add(deleteExclude);
  +        panel.add(buttonPanel, BorderLayout.SOUTH);
  +        excludeTable.addFocusListener(this);
  +        return panel;
  +    }
   
       public void setNode(JMeterTreeNode node)
       {
           namePanel.setNode(node);
       }
   
  -     /**
  -      * Returns the portField.
  -      * @return JTextField
  -      */
  -     protected JTextField getPortField()
  -     {
  -             return portField;
  -     }
  +    /**
  +     * Returns the portField.
  +     * @return JTextField
  +     */
  +    protected JTextField getPortField()
  +    {
  +        return portField;
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to