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/03 15:33:10 UTC
cvs commit: jakarta-jmeter/src/org/apache/jmeter/visualizers FileVisualizer.java
khammond 01/10/03 06:33:10
Modified: src/org/apache/jmeter/visualizers FileVisualizer.java
Log:
New GUI style. Bug fix #3637.
Revision Changes Path
1.21 +187 -310 jakarta-jmeter/src/org/apache/jmeter/visualizers/FileVisualizer.java
Index: FileVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/visualizers/FileVisualizer.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FileVisualizer.java 2001/08/16 18:17:56 1.20
+++ FileVisualizer.java 2001/10/03 13:33:10 1.21
@@ -1,424 +1,301 @@
/*
-
* ====================================================================
-
* 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.visualizers;
-
-
import java.io.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.*;
+import javax.swing.border.*;
import org.apache.jmeter.util.JMeterUtils;
-
import org.apache.jmeter.samplers.SampleResult;
-
import org.apache.jmeter.samplers.Sampler;
-
import org.apache.jmeter.gui.*;
-
import org.apache.jmeter.reporters.Filer;
/**
-
* This class implements a visualizer that writes the samples to a file.
-
*
-
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
-
- * @version $Revision: 1.20 $ $Date: 2001/08/16 18:17:56 $
-
+ * @version $Revision: 1.21 $ $Date: 2001/10/03 13:33:10 $
*/
-
-public class FileVisualizer extends JPanel implements ActionListener,ModelSupported {
-
-
-
- Filer model;
-
-
-
- JButton browseButton, openButton, flushButton, closeButton;
-
- JFileChooser fileChooser;
-
- JCheckBox appendCheck, verboseCheck, autoFlushCheck, viewSubmitDataCheck;
-
- JComboBox fileList;
-
-
-
- public FileVisualizer() {
-
- super();
-
-
-
+public class FileVisualizer extends JPanel implements ActionListener,ModelSupported
+{
+ Filer model;
+ JButton browseButton, openButton, flushButton, closeButton;
+ //JFileChooser fileChooser;
+ JCheckBox appendCheck, verboseCheck, autoFlushCheck, viewSubmitDataCheck;
+ JComboBox fileList;
+
+ public FileVisualizer()
+ {
+ super();
+ }
+
+ private void init()
+ {
+ 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("file_visualizer_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 namePanel = new NamePanel(model);
+ mainPanel.add(namePanel);
+
+ // FILENAME
+ JLabel filenameLabel = new JLabel(JMeterUtils.getResString("file_visualizer_filename"));
+ mainPanel.add(filenameLabel);
+ JPanel filenamePanel = new JPanel();
+ filenamePanel.setLayout(new BoxLayout(filenamePanel, BoxLayout.X_AXIS));
+ fileList = new JComboBox();
+ fileList.setEditable(true);
-
- }
-
-
-
- private void init()
-
- {
-
- // File panel
-
- JPanel filePanel = new JPanel();
-
- filePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Output File"));
-
- GridBagLayout g = new GridBagLayout();
-
- filePanel.setLayout(g);
-
- GridBagConstraints c = new GridBagConstraints();
-
- c.fill = c.BOTH;
-
-
-
- fileList = new JComboBox();
-
- fileList.setEditable(true);
- if(model.getFile() != null)
- {
+ if(model.getFile() != null)
+ {
fileList.addItem(model.getFile());
fileList.setSelectedItem(model.getFile());
- }
-
- fileList.addActionListener(this);
-
- c.gridx = 0;
-
- c.gridy = 0;
-
- c.gridwidth = 4;
-
- c.gridheight = 1;
-
- c.weightx = 1.0;
-
- c.weighty = 0.0;
-
- c.insets = new Insets(3, 3, 3, 3);
-
- g.setConstraints(fileList, c);
-
- filePanel.add(fileList);
-
-
-
- browseButton = new JButton("Browse");
-
- browseButton.addActionListener(this);
-
- browseButton.setEnabled(true);
-
- c.gridwidth = 1;
-
- c.gridx = 4;
-
- g.setConstraints(browseButton, c);
-
- filePanel.add(browseButton);
-
-
-
- appendCheck = new JCheckBox("Append", model.getAppend());
-
- appendCheck.addActionListener(this);
-
- c.gridx = 0;
-
- c.gridy = 1;
-
- g.setConstraints(appendCheck, c);
-
- filePanel.add(appendCheck);
-
+ }
+ fileList.addActionListener(this);
+ filenamePanel.add(fileList);
+ filenamePanel.add(Box.createRigidArea(new Dimension(10, 0)));
- verboseCheck = new JCheckBox("Verbose Output", model.getVerbose());
- verboseCheck.addActionListener(this);
- c.gridx = 1;
- g.setConstraints(verboseCheck, c);
- filePanel.add(verboseCheck);
-
- autoFlushCheck = new JCheckBox("Auto Flush", model.getAutoFlush());
- autoFlushCheck.addActionListener(this);
- c.gridx = 2;
- g.setConstraints(autoFlushCheck, c);
- filePanel.add(autoFlushCheck);
-
- viewSubmitDataCheck = new JCheckBox("Submit Data", model.getViewSubmitData());
- viewSubmitDataCheck.addActionListener(this);
- c.gridx = 3;
- g.setConstraints(viewSubmitDataCheck, c);
- filePanel.add(viewSubmitDataCheck);
- viewSubmitDataCheck.setEnabled(model.getVerbose());
-
- c.gridy = 2;
- openButton = new JButton("Open");
- openButton.addActionListener(this);
- openButton.setEnabled(true);
- c.gridx = 2;
- g.setConstraints(openButton, c);
- filePanel.add(openButton);
-
-
-
- flushButton = new JButton("Flush");
-
- flushButton.addActionListener(this);
-
- flushButton.setEnabled(false);
-
- c.gridx = 3;
-
- g.setConstraints(flushButton, c);
-
- filePanel.add(flushButton);
-
-
-
- closeButton = new JButton("Close");
-
- closeButton.addActionListener(this);
-
- closeButton.setEnabled(false);
-
- c.gridx = 4;
-
- g.setConstraints(closeButton, c);
-
- filePanel.add(closeButton);
+ browseButton = new JButton(JMeterUtils.getResString("file_visualizer_browse"));
+ browseButton.addActionListener(this);
+ browseButton.setEnabled(true);
+ filenamePanel.add(browseButton);
+ mainPanel.add(filenamePanel);
+ // FILE OPTIONS
+ JPanel fileOptionsPanel = new JPanel();
+ fileOptionsPanel.setLayout(new VerticalLayout(5,VerticalLayout.LEFT));
+ fileOptionsPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("file_visualizer_file_options")));
+ appendCheck = new JCheckBox(JMeterUtils.getResString("file_visualizer_append"), model.getAppend());
+ appendCheck.addActionListener(this);
+ fileOptionsPanel.add(appendCheck);
- fileChooser = new JFileChooser();
+ autoFlushCheck = new JCheckBox(JMeterUtils.getResString("file_visualizer_auto_flush"), model.getAutoFlush());
+ autoFlushCheck.addActionListener(this);
+ fileOptionsPanel.add(autoFlushCheck);
+ verboseCheck = new JCheckBox(JMeterUtils.getResString("file_visualizer_verbose"), model.getVerbose());
+ verboseCheck.addActionListener(this);
+ fileOptionsPanel.add(verboseCheck);
+ viewSubmitDataCheck = new JCheckBox(JMeterUtils.getResString("file_visualizer_submit_data"), model.getViewSubmitData());
+ viewSubmitDataCheck.addActionListener(this);
+ viewSubmitDataCheck.setEnabled(model.getVerbose());
+ fileOptionsPanel.add(viewSubmitDataCheck);
- this.add(filePanel);
+ mainPanel.add(fileOptionsPanel);
- }
+ JPanel buttonPanel = new JPanel();
+ openButton = new JButton(JMeterUtils.getResString("file_visualizer_open"));
+ openButton.addActionListener(this);
+ openButton.setEnabled(true);
+ flushButton = new JButton(JMeterUtils.getResString("file_visualizer_flush"));
+ flushButton.addActionListener(this);
+ flushButton.setEnabled(false);
- public void setModel(Object model)
+ closeButton = new JButton(JMeterUtils.getResString("file_visualizer_close"));
+ closeButton.addActionListener(this);
+ closeButton.setEnabled(false);
- {
+ buttonPanel.add(openButton);
+ buttonPanel.add(flushButton);
+ buttonPanel.add(closeButton);
+ mainPanel.add(buttonPanel);
+
+ //fileChooser = new JFileChooser();
+
+/*
+
+ fileChooser = new JFileChooser();
+ mainPanel.add(filePanel);
+*/
+ this.add(mainPanel);
+ }
+ public void setModel(Object model)
+ {
this.model = (Filer)model;
-
this.model.setListener(this);
-
init();
-
- }
-
-
+ }
- public void open()
-
- {
-
+ public void open()
+ {
browseButton.setEnabled(false);
openButton.setEnabled(false);
flushButton.setEnabled(true);
closeButton.setEnabled(true);
model.open();
- }
-
-
-
- public void close()
+ }
- {
+ public void close()
+ {
browseButton.setEnabled(true);
openButton.setEnabled(true);
flushButton.setEnabled(false);
closeButton.setEnabled(false);
model.close();
- }
+ }
-
-
- public void setFile(String file)
-
- {
+ public void setFile(String file)
+ {
fileList.removeItem(file);
fileList.addItem(file);
fileList.getEditor().setItem(file);
model.setFile(file);
- }
-
-
-
- public void updateGui()
+ }
- {
+ public void updateGui()
+ {
- }
+ }
-
-
- public void actionPerformed(ActionEvent e) {
-
- try {
- JComponent c = (JComponent) e.getSource();
- if(c == fileList) {
- setFile((String) fileList.getSelectedItem());
- } else if (c == appendCheck) {
- model.setAppend(appendCheck.isSelected());
- }else if (c == browseButton) {
- File tmp = FileDialoger.promptToOpenFile().getSelectedFile();
- if( tmp != null ) {
- setFile(tmp.toString());
- }
- } else if (c == openButton) {
- open();
- } else if (c == flushButton) {
- model.flush();
- } else if (c == closeButton) {
- close();
- } else if (c == verboseCheck) {
- model.setVerbose(verboseCheck.isSelected());
- if(!verboseCheck.isSelected()){
- viewSubmitDataCheck.setSelected(false);
- model.setViewSubmitData(false);
- viewSubmitDataCheck.setEnabled(false);
- }else
- viewSubmitDataCheck.setEnabled(true);
- } else if(c == viewSubmitDataCheck){
- model.setViewSubmitData(viewSubmitDataCheck.isSelected());
- } else if(c == autoFlushCheck){
- model.setAutoFlush(autoFlushCheck.isSelected());
- } else {
- // do nothing!
- }
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(this, ex, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- }
-
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ JComponent c = (JComponent) e.getSource();
+
+ if (c == fileList)
+ {
+ setFile((String) fileList.getSelectedItem());
+ }
+ else if (c == appendCheck)
+ {
+ model.setAppend(appendCheck.isSelected());
+ }
+ else if (c == browseButton)
+ {
+ File tmp = FileDialoger.promptToOpenFile().getSelectedFile();
+ if (tmp != null)
+ {
+ setFile(tmp.toString());
+ }
+ }
+ else if (c == openButton)
+ {
+ String filename = (String) fileList.getSelectedItem();
+ if ((filename != null) && (filename.trim().length() > 0))
+ {
+ open();
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(this, JMeterUtils.getResString("file_visualizer_missing_filename"), "Error", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+ else if (c == flushButton)
+ {
+ model.flush();
+ }
+ else if (c == closeButton)
+ {
+ close();
+ }
+ else if (c == verboseCheck)
+ {
+ model.setVerbose(verboseCheck.isSelected());
+ if (!verboseCheck.isSelected())
+ {
+ viewSubmitDataCheck.setSelected(false);
+ model.setViewSubmitData(false);
+ viewSubmitDataCheck.setEnabled(false);
+ }
+ else
+ {
+ viewSubmitDataCheck.setEnabled(true);
+ }
+ }
+ else if (c == viewSubmitDataCheck)
+ {
+ model.setViewSubmitData(viewSubmitDataCheck.isSelected());
+ }
+ else if (c == autoFlushCheck)
+ {
+ model.setAutoFlush(autoFlushCheck.isSelected());
+ }
+ else
+ {
+ // do nothing!
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog(this, ex, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org