You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by mi...@apache.org on 2012/08/23 01:30:14 UTC
svn commit: r1376315 -
/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
Author: milamber
Date: Wed Aug 22 23:30:13 2012
New Revision: 1376315
URL: http://svn.apache.org/viewvc?rev=1376315&view=rev
Log:
Moves the pattern filter on reload data action
Force the reloaded data (to remove filter) when unchecked the filter checkbox
Add a change listener on JTabbedPane to make the graph when clic on Graph tab (without clic on Display Graph button)
Reorganise some methods in source file
Bugzilla Id: 53718
Modified:
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java?rev=1376315&r1=1376314&r2=1376315&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java Wed Aug 22 23:30:13 2012
@@ -55,6 +55,8 @@ import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import org.apache.jmeter.gui.action.ActionNames;
import org.apache.jmeter.gui.action.ActionRouter;
@@ -183,6 +185,10 @@ public class RespTimeGraphVisualizer ext
private int colorIdx = 0;
+ private Pattern pattern = null;
+
+ private Matcher matcher = null;
+
private final List<Color> listColors = Colors.getColors();
// Use implementation instead of Interface as we need it to be cloneable
@@ -199,11 +205,8 @@ public class RespTimeGraphVisualizer ext
internalMap.put(Long.valueOf(sampleResult.getStartTime()), Long.valueOf(sampleResult.getTime()));
}
- Matcher matcher = null;
// Sampler selection
- if (samplerSelection.isSelected() && samplerMatchLabel.getText() != null
- && samplerMatchLabel.getText().length() > 0) {
- Pattern pattern = createPattern(samplerMatchLabel.getText());
+ if (samplerSelection.isSelected() && pattern != null) {
matcher = pattern.matcher(sampleLabel);
}
if ((matcher == null) || (matcher.find())) {
@@ -395,71 +398,26 @@ public class RespTimeGraphVisualizer ext
tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane); //$NON-NLS-1$
tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel); //$NON-NLS-1$
+
+ // If clic on the Graph tab, make the graph (without apply interval or filter)
+ ChangeListener changeListener = new ChangeListener() {
+ public void stateChanged(ChangeEvent changeEvent) {
+ JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
+ int index = srcTab.getSelectedIndex();
+ if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { //$NON-NLS-1$
+ actionMakeGraph();
+ }
+ }
+ };
+ tabbedGraph.addChangeListener(changeListener);
this.add(mainPanel, BorderLayout.NORTH);
this.add(tabbedGraph, BorderLayout.CENTER);
}
- @Override
- public JComponent getPrintableComponent() {
- if (saveGraphToFile == true) {
- saveGraphToFile = false;
- graphPanel.setBounds(graphPanel.getLocation().x,graphPanel.getLocation().y,
- graphPanel.width,graphPanel.height);
- return graphPanel;
- }
- return this;
- }
-
- private JPanel createGraphActionsPane() {
- JPanel buttonPanel = new JPanel(new BorderLayout());
- JPanel displayPane = new JPanel();
- displayPane.add(displayButton);
- displayButton.addActionListener(this);
- buttonPanel.add(displayPane, BorderLayout.WEST);
-
- JPanel savePane = new JPanel();
- savePane.add(saveGraph);
- saveGraph.addActionListener(this);
- syncWithName.addActionListener(this);
- buttonPanel.add(savePane, BorderLayout.EAST);
-
- return buttonPanel;
- }
-
- public String[] getXAxisLabels() {
- SimpleDateFormat formatter = new SimpleDateFormat(xAxisTimeFormat.getText()); //$NON-NLS-1$
- String[] xAxisLabels = new String[durationTest];
- for (int j = 0; j < durationTest; j++) {
- xAxisLabels[j] = formatter.format(new Date((minStartTime + j) * intervalValue));
- }
- return xAxisLabels;
- }
-
- private String[] getLegendLabels() {
- String[] legends = new String[seriesNames.size()];
- int i = 0;
- for (Map.Entry<String, RespTimeGraphLineBean> entry : seriesNames.entrySet()) {
- RespTimeGraphLineBean val = entry.getValue();
- legends[i] = val.getLabel();
- i++;
- }
- return legends;
- }
-
- private Color[] getLinesColors() {
- Color[] linesColors = new Color[seriesNames.size()];
- int i = 0;
- for (Map.Entry<String, RespTimeGraphLineBean> entry : seriesNames.entrySet()) {
- RespTimeGraphLineBean val = entry.getValue();
- linesColors[i] = val.getLineColor();
- i++;
- }
- return linesColors;
- }
-
public void actionPerformed(ActionEvent event) {
+ boolean forceReloadData = false;
final Object eventSource = event.getSource();
if (eventSource == displayButton) {
actionMakeGraph();
@@ -494,12 +452,24 @@ public class RespTimeGraphVisualizer ext
reloadButton.setEnabled(false);
caseChkBox.setEnabled(false);
regexpChkBox.setEnabled(false);
+ // Force reload data
+ forceReloadData = true;
}
- } else if (eventSource == reloadButton || eventSource == intervalButton) {
+ }
+ // Not 'else if' because forceReloadData
+ if (eventSource == reloadButton || eventSource == intervalButton || forceReloadData) {
if (eventSource == intervalButton) {
intervalValue = Integer.parseInt(intervalField.getText());
}
+ if (eventSource == reloadButton && samplerSelection.isSelected() && samplerMatchLabel.getText() != null
+ && samplerMatchLabel.getText().length() > 0) {
+ pattern = createPattern(samplerMatchLabel.getText());
+ } else if (forceReloadData) {
+ pattern = null;
+ matcher = null;
+ }
if (getFile() != null && getFile().length() > 0) {
+ // Reload data from file
clearData();
FilePanel filePanel = (FilePanel) getFilePanel();
filePanel.actionPerformed(event);
@@ -519,9 +489,8 @@ public class RespTimeGraphVisualizer ext
}
}
}
-
}
-
+
private void actionMakeGraph() {
String msgErr = null;
// Calculate the test duration. Needs to xAxis Labels and getData.
@@ -539,6 +508,64 @@ public class RespTimeGraphVisualizer ext
}
}
+ @Override
+ public JComponent getPrintableComponent() {
+ if (saveGraphToFile == true) {
+ saveGraphToFile = false;
+ graphPanel.setBounds(graphPanel.getLocation().x,graphPanel.getLocation().y,
+ graphPanel.width,graphPanel.height);
+ return graphPanel;
+ }
+ return this;
+ }
+
+ private JPanel createGraphActionsPane() {
+ JPanel buttonPanel = new JPanel(new BorderLayout());
+ JPanel displayPane = new JPanel();
+ displayPane.add(displayButton);
+ displayButton.addActionListener(this);
+ buttonPanel.add(displayPane, BorderLayout.WEST);
+
+ JPanel savePane = new JPanel();
+ savePane.add(saveGraph);
+ saveGraph.addActionListener(this);
+ syncWithName.addActionListener(this);
+ buttonPanel.add(savePane, BorderLayout.EAST);
+
+ return buttonPanel;
+ }
+
+ public String[] getXAxisLabels() {
+ SimpleDateFormat formatter = new SimpleDateFormat(xAxisTimeFormat.getText()); //$NON-NLS-1$
+ String[] xAxisLabels = new String[durationTest];
+ for (int j = 0; j < durationTest; j++) {
+ xAxisLabels[j] = formatter.format(new Date((minStartTime + j) * intervalValue));
+ }
+ return xAxisLabels;
+ }
+
+ private String[] getLegendLabels() {
+ String[] legends = new String[seriesNames.size()];
+ int i = 0;
+ for (Map.Entry<String, RespTimeGraphLineBean> entry : seriesNames.entrySet()) {
+ RespTimeGraphLineBean val = entry.getValue();
+ legends[i] = val.getLabel();
+ i++;
+ }
+ return legends;
+ }
+
+ private Color[] getLinesColors() {
+ Color[] linesColors = new Color[seriesNames.size()];
+ int i = 0;
+ for (Map.Entry<String, RespTimeGraphLineBean> entry : seriesNames.entrySet()) {
+ RespTimeGraphLineBean val = entry.getValue();
+ linesColors[i] = val.getLineColor();
+ i++;
+ }
+ return linesColors;
+ }
+
private JPanel createGraphSettingsPane() {
JPanel settingsPane = new JPanel(new BorderLayout());
settingsPane.setBorder(BorderFactory.createTitledBorder(