khammond    01/10/07 08:37:27

  Modified:    src/org/apache/jmeter/protocol/http/config/gui
                        MultipartUrlConfigGui.java
  Log:
  New GUI style.
  
  Revision  Changes    Path
  1.7       +235 -53   
jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/gui/MultipartUrlConfigGui.java
  
  Index: MultipartUrlConfigGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/gui/MultipartUrlConfigGui.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MultipartUrlConfigGui.java        2001/08/09 18:48:50     1.6
  +++ MultipartUrlConfigGui.java        2001/10/07 15:37:27     1.7
  @@ -1,8 +1,65 @@
  +/*
  + * ====================================================================
  + * 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 [EMAIL PROTECTED]
  + *
  + * 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.config.gui;
   
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
  +import javax.swing.border.*;
  +import java.io.*;
   
   import org.apache.jmeter.gui.VerticalLayout;
   import org.apache.jmeter.gui.NamePanel;
  @@ -22,14 +79,19 @@
   public class MultipartUrlConfigGui extends UrlConfigGui
   {
        private static String FILENAME = "filename";
  -     private static String BROWSE = "Browse";
  -     private static String FIELDNAME = "fieldname";
  +     private static String BROWSE = "browse";
  +     private static String PARAMNAME = "paramname";
        private static String MIMETYPE = "mimetype";
  +     private static String SENDFILE = "sendfile";
   
  -     JTextField filenameField = new JTextField(15);
  -     JButton browse = new JButton(JMeterUtils.getResString("browse"));
  -     JTextField fieldNameField = new JTextField(15);
  -     JTextField mimetypeField = new JTextField(15);
  +     JTextField filenameField;
  +     JTextField paramNameField;
  +     JTextField mimetypeField;
  +     JLabel filenameLabel;
  +     JLabel paramNameLabel;
  +     JLabel mimetypeLabel;
  +     JButton browseFileButton;
  +     JCheckBox sendFileCheckBox;
   
        public MultipartUrlConfigGui()
        {
  @@ -40,60 +102,143 @@
                super(displayName);
        }
   
  -             public void updateGui()
  +     public void updateGui()
        {
                super.updateGui();
        }
   
  -             protected void init()
  +     protected void init()
        {
  -             this.setLayout(new VerticalLayout(2,VerticalLayout.LEFT));
  -             if(displayName)
  +             this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, 
VerticalLayout.TOP));
  +
  +             // WEB SERVER PANEL
  +             JPanel webServerPanel = new JPanel();
  +             webServerPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, 
VerticalLayout.TOP));
  +             
webServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
 JMeterUtils.getResString("web_server")));
  +             webServerPanel.add(getDomainPanel());
  +             webServerPanel.add(getPortPanel());
  +
  +             // WEB REQUEST PANEL
  +             JPanel webRequestPanel = new JPanel();
  +             webRequestPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, 
VerticalLayout.TOP));
  +             
webRequestPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
 JMeterUtils.getResString("web_request")));
  +             webRequestPanel.add(getProtocolAndMethodPanel());
  +             webRequestPanel.add(getPathPanel());
  +             webRequestPanel.add(getParameterPanel());
  +             webRequestPanel.add(getFilePanel());
  +
  +             // If displayName is TRUE, then this GUI is not embedded in another 
GUI.
  +             if (displayName)
  +             {
  +                     // 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("url_full_config_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);
  +                     mainPanel.add(namePanel);
  +
  +                     mainPanel.add(webServerPanel);
  +                     mainPanel.add(webRequestPanel);
  +
  +                     this.add(mainPanel);
  +             }
  +             else // Embed this GUI in the parent GUI
                {
  -                     namePanel = new NamePanel();
  -                     namePanel.setModel(model);
  -                     this.add(namePanel);
  -             }
  -             this.add(getProtocolPanel());
  -             this.add(getMethodPanel());
  -             this.add(getDomainPanel());
  -             this.add(getPortPanel());
  -             this.add(getPathPanel());
  -             this.add(getFilePanel());
  -             this.add(getParameterPanel());
  -     }
  -
  -     private JPanel getFilePanel()
  -     {
  -             JPanel panel = new JPanel(new VerticalLayout(1,VerticalLayout.LEFT));
  -             
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),JMeterUtils.getResString("upload")));
  -             JPanel tempPanel = new JPanel();
  -             tempPanel.add(new JLabel(JMeterUtils.getResString("file")));
  +                     this.add(webServerPanel);
  +                     this.add(webRequestPanel);
  +             }
  +     }
  +
  +     protected JPanel getFilePanel()
  +     {
  +             // FILE PANEL (all main components are add to this panel)
  +             JPanel filePanel = new JPanel();
  +             filePanel.setLayout(new VerticalLayout(1, VerticalLayout.LEFT));
  +             filePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
  +
  +             // SEND FILE CHECKBOX
  +             sendFileCheckBox = new 
JCheckBox(JMeterUtils.getResString("send_file"));
  +             sendFileCheckBox.setActionCommand(SENDFILE);
  +             sendFileCheckBox.addActionListener(this);
  +             filePanel.add(sendFileCheckBox);
  +
  +             // FILENAME PANEL (contains filename label and text field and Browse 
button)
  +             JPanel filenamePanel = new JPanel();
  +             filenamePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
  +
  +             // --- FILENAME LABEL
  +             filenameLabel = new 
JLabel(JMeterUtils.getResString("send_file_filename_label"));
  +             filenameLabel.setEnabled(false);
  +             
  +             // --- FILENAME TEXT FIELD
  +             filenameField = new JTextField(15);
  +             filenameField.setEnabled(false);
                filenameField.setText(((MultipartUrlConfig)model).getFilename());
                filenameField.setName(FILENAME);
                filenameField.addKeyListener(this);
  -             tempPanel.add(filenameField);
  -             browse.setActionCommand(BROWSE);
  -             browse.addActionListener(this);
  -             tempPanel.add(browse);
  -             panel.add(tempPanel);
  -
  -             tempPanel = new JPanel();
  -             tempPanel.add(new JLabel(JMeterUtils.getResString("field_name")));
  -             fieldNameField.setText(((MultipartUrlConfig)model).getFileFieldName());
  -             fieldNameField.setName(FIELDNAME);
  -             fieldNameField.addKeyListener(this);
  -             tempPanel.add(fieldNameField);
  -             panel.add(tempPanel);
   
  -             tempPanel = new JPanel();
  -             tempPanel.add(new JLabel(JMeterUtils.getResString("mimetype")));
  +             // --- BROWSE BUTTON
  +             browseFileButton = new 
JButton(JMeterUtils.getResString("send_file_browse"));
  +             browseFileButton.setEnabled(false);
  +             browseFileButton.setActionCommand(BROWSE);
  +             browseFileButton.addActionListener(this);
  +
  +             filenamePanel.add(filenameLabel);
  +             filenamePanel.add(filenameField);
  +             filenamePanel.add(browseFileButton);
  +
  +             // PARAM NAME PANEL (contains param name label and text field)
  +             JPanel paramNamePanel = new JPanel();
  +             paramNamePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
  +
  +             // --- PARAM NAME LABEL
  +             paramNameLabel = new 
JLabel(JMeterUtils.getResString("send_file_param_name_label"));
  +             paramNameLabel.setEnabled(false);
  +
  +             // --- PARAM NAME TEXT FIELD
  +             paramNameField = new JTextField(15);
  +             paramNameField.setText(((MultipartUrlConfig)model).getFileFieldName());
  +             paramNameField.setName(PARAMNAME);
  +             paramNameField.addKeyListener(this);
  +             paramNameField.setEnabled(false);
  +
  +             paramNamePanel.add(paramNameLabel);
  +             paramNamePanel.add(paramNameField);
  +
  +             // MIME TYPE PANEL (contains mime type label and text field)
  +             JPanel mimePanel = new JPanel();
  +             mimePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
  +
  +             // --- MIME TYPE LABEL
  +             mimetypeLabel = new 
JLabel(JMeterUtils.getResString("send_file_mime_label"));
  +             mimetypeLabel.setEnabled(false);
  +
  +             // --- MIME TYPE TEXT FIELD
  +             mimetypeField = new JTextField(15);
  +             mimetypeField.setEnabled(false);
                mimetypeField.setText(((MultipartUrlConfig)model).getMimeType());
                mimetypeField.setName(MIMETYPE);
                mimetypeField.addKeyListener(this);
  -             tempPanel.add(mimetypeField);
  -             panel.add(tempPanel);
  -             return panel;
  +
  +             mimePanel.add(mimetypeLabel);
  +             mimePanel.add(mimetypeField);
  +
  +             filePanel.add(filenamePanel);
  +             filePanel.add(paramNamePanel);
  +             filePanel.add(mimePanel);
  +
  +             return filePanel;
        }
   
        public void keyReleased(KeyEvent e)
  @@ -104,9 +249,9 @@
                {
                        
((MultipartUrlConfig)model).setFilename(filenameField.getText());
                }
  -             else if(name.equals(FIELDNAME))
  +             else if(name.equals(PARAMNAME))
                {
  -                     
((MultipartUrlConfig)model).setFileFieldName(fieldNameField.getText());
  +                     
((MultipartUrlConfig)model).setFileFieldName(paramNameField.getText());
                }
                else if (name.equals(MIMETYPE)) {
                        
((MultipartUrlConfig)model).setMimeType(mimetypeField.getText());
  @@ -116,12 +261,49 @@
        public void actionPerformed(ActionEvent e)
        {
                String name = e.getActionCommand();
  -             if(name.equals(BROWSE))
  +             if (name.equals(BROWSE))
                {
                        JFileChooser chooser = FileDialoger.promptToOpenFile();
  -                     
((MultipartUrlConfig)model).setFilename(chooser.getSelectedFile().getPath());
  -                     filenameField.setText(chooser.getSelectedFile().getPath());
  +
  +                     File file = chooser.getSelectedFile();
  +                     if (file != null)
  +                     {
  +                             
((MultipartUrlConfig)model).setFilename(file.getPath());
  +                             filenameField.setText(file.getPath());
  +                     }
  +             }
  +             else if (name.equals(SENDFILE))
  +             {
  +                     if (sendFileCheckBox.isSelected())
  +                     {
  +                             filenameLabel.setEnabled(true);
  +                             filenameField.setEnabled(true);
  +                             mimetypeLabel.setEnabled(true);
  +                             mimetypeField.setEnabled(true);
  +                             paramNameLabel.setEnabled(true);
  +                             paramNameField.setEnabled(true);
  +                             browseFileButton.setEnabled(true);
  +                     }
  +                     else
  +                     {
  +                             filenameLabel.setEnabled(false);
  +                             filenameField.setEnabled(false);
  +                             mimetypeLabel.setEnabled(false);
  +                             mimetypeField.setEnabled(false);
  +                             paramNameLabel.setEnabled(false);
  +                             paramNameField.setEnabled(false);
  +                             browseFileButton.setEnabled(false);
  +
  +                             filenameField.setText("");
  +                             paramNameField.setText("");
  +                             mimetypeField.setText("");
  +
  +                             ((MultipartUrlConfig)model).setFilename("");
  +                             ((MultipartUrlConfig)model).setFileFieldName("");
  +                             ((MultipartUrlConfig)model).setMimeType("");
  +                     }
                }
  +
                super.actionPerformed(e);
        }
  -}
  \ No newline at end of file
  +}
  
  
  

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

Reply via email to