You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by kh...@apache.org on 2001/10/07 18:59:40 UTC

cvs commit: jakarta-jmeter/src/org/apache/jmeter/protocol/http/proxy/gui ProxyControlGui.java

khammond    01/10/07 09:59:40

  Modified:    src/org/apache/jmeter/protocol/http/proxy/gui
                        ProxyControlGui.java
  Log:
  Added Apache license. New GUI style.
  
  Revision  Changes    Path
  1.3       +136 -18   jakarta-jmeter/src/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
  
  Index: ProxyControlGui.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProxyControlGui.java	2001/08/30 17:19:02	1.2
  +++ ProxyControlGui.java	2001/10/07 16:59:40	1.3
  @@ -1,3 +1,57 @@
  +/*
  + * ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + * notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + * if any, must include the following acknowledgment:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowledgment may appear in the software itself,
  + * if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + * "Apache JMeter" must not be used to endorse or promote products
  + * derived from this software without prior written permission. For
  + * written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + * "Apache JMeter", nor may "Apache" appear in their name, without
  + * prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
   package org.apache.jmeter.protocol.http.proxy.gui;
   
   import java.awt.*;
  @@ -30,14 +84,14 @@
   
   	ProxyControl model;
   	NamePanel namePanel;
  -	JTextField portField = new JTextField(8);
  +	JTextField portField;
   
  -	JTextField addIncludeField = new JTextField(15);
  -	JList includeList = new JList(new JMeterJListModel());
  +	JTextField addIncludeField;
  +	JList includeList;
   	JButton clearInclude;
   
  -	JTextField addExcludeField = new JTextField(15);
  -	JList excludeList = new JList(new JMeterJListModel());
  +	JTextField addExcludeField;
  +	JList excludeList;
   	JButton clearExclude;
   
   	JButton stop,start;
  @@ -61,37 +115,65 @@
   
   	private void init()
   	{
  -		this.setLayout(new VerticalLayout(1,VerticalLayout.LEFT));
  +		this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
  +
  +		// MAIN PANEL
  +		JPanel mainPanel = new JPanel();
  +		Border margin = new EmptyBorder(10, 10, 5, 10);
  +		mainPanel.setBorder(margin);
  +		mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
  +
  +		// 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);
  +
  +		// NAME
   		namePanel = new NamePanel(model);
  -		this.add(namePanel);
  -		this.add(createPortPanel());
  -		this.add(createIncludePanel());
  -		this.add(createExcludePanel());
  -		this.add(createControls());
  +		mainPanel.add(namePanel);
  +
  +		mainPanel.add(createPortPanel());
  +		mainPanel.add(createIncludePanel());
  +		mainPanel.add(createExcludePanel());
  +		mainPanel.add(createControls());
  +
  +		this.add(mainPanel);
  +
   	}
   
   	private JPanel createControls()
   	{
   		JPanel panel = new JPanel();
  -		stop = new JButton(JMeterUtils.getResString("stop"));
  -		stop.addActionListener(this);
  -		stop.setActionCommand(STOP);
  +
   		start = new JButton(JMeterUtils.getResString("start"));
   		start.addActionListener(this);
   		start.setActionCommand(START);
  +
  +		stop = new JButton(JMeterUtils.getResString("stop"));
  +		stop.addActionListener(this);
  +		stop.setActionCommand(STOP);
  +
   		panel.add(start);
   		panel.add(stop);
  +
   		return panel;
   	}
   
   	private JPanel createPortPanel()
   	{
   		JPanel panel = new JPanel();
  +
   		panel.add(new JLabel(JMeterUtils.getResString("port")));
  +
  +		portField = new JTextField(8);
   		portField.setName(ProxyControl.PORT);
   		portField.addKeyListener(this);
   		portField.setText(""+model.getPort());
   		panel.add(portField);
  +
   		return panel;
   	}
   
  @@ -101,18 +183,24 @@
   		panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
   				JMeterUtils.getResString("patterns_to_include")));
   		panel.add(new JLabel(JMeterUtils.getResString("add_pattern")));
  +
  +		addIncludeField = new JTextField(15);
   		addIncludeField.addActionListener(this);
   		addIncludeField.setActionCommand(ADD_INCLUDE);
   		panel.add(addIncludeField);
  +
  +		includeList = new JList(new JMeterJListModel());
   		((JMeterJListModel)includeList.getModel()).setData(model.getIncludePatterns());
   		includeList.setMinimumSize(new Dimension(20,10));
   		includeList.setBorder(BorderFactory.createEtchedBorder());
   		includeList.setVisibleRowCount(3);
   		panel.add(includeList);
  +
   		clearInclude = new JButton(JMeterUtils.getResString("clear"));
   		clearInclude.addActionListener(this);
   		clearInclude.setActionCommand(CLEAR_INCLUDE);
   		panel.add(clearInclude);
  +
   		return panel;
   	}
   
  @@ -122,24 +210,31 @@
   		panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
   				JMeterUtils.getResString("patterns_to_exclude")));
   		panel.add(new JLabel(JMeterUtils.getResString("add_pattern")));
  +
  +		addExcludeField = new JTextField(15);
   		addExcludeField.addActionListener(this);
   		addExcludeField.setActionCommand(ADD_EXCLUDE);
   		panel.add(addExcludeField);
  +
  +		excludeList = new JList(new JMeterJListModel());
   		((JMeterJListModel)excludeList.getModel()).setData(model.getExcludePatterns());
   		excludeList.setMinimumSize(new Dimension(20,10));
   		excludeList.setBorder(BorderFactory.createEtchedBorder());
   		excludeList.setVisibleRowCount(3);
   		panel.add(excludeList);
  +
   		clearExclude = new JButton(JMeterUtils.getResString("clear"));
   		clearExclude.addActionListener(this);
   		clearExclude.setActionCommand(CLEAR_EXCLUDE);
   		panel.add(clearExclude);
  +
   		return panel;
   	}
   
   	public void actionPerformed(ActionEvent action)
   	{
   		String command = action.getActionCommand();
  +
   		if(command.equals(STOP))
   		{
   			model.stopProxy();
  @@ -185,11 +280,34 @@
   	public void keyReleased(KeyEvent e)
   	{
   		String fieldName = e.getComponent().getName();
  -		if (fieldName.equals(ProxyControl.PORT)) {
  -			try {
  +
  +		if (fieldName.equals(ProxyControl.PORT)) 
  +		{
  +			try 
  +			{
   				model.setPort(Integer.parseInt(portField.getText()));
  -			} catch (NumberFormatException nfe) {
  -				// Ignore
  +			} 
  +			catch (NumberFormatException nfe) 
  +			{
  +				if (portField.getText().length() > 0)
  +				{
  +					JOptionPane.showMessageDialog(this, "You must enter a valid number",
  +							"Invalid data", JOptionPane.WARNING_MESSAGE);
  +					model.setPort(model.getDefaultPort());
  +
  +					// 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("");
  +				}
  +				else
  +				{
  +					model.setPort(model.getDefaultPort());
  +				}
   			}
   		}
   	}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org