use of org.apache.jmeter.gui.util.FilePanel in project jmeter by apache.
the class RespTimeGraphVisualizer method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
boolean forceReloadData = false;
final Object eventSource = event.getSource();
if (eventSource == displayButton) {
actionMakeGraph();
} else if (eventSource == saveGraph) {
saveGraphToFile = true;
try {
ActionRouter.getInstance().getAction(ActionNames.SAVE_GRAPHICS, SaveGraphics.class.getName()).doAction(new ActionEvent(this, event.getID(), ActionNames.SAVE_GRAPHICS));
} catch (Exception e) {
log.error(e.getMessage());
}
} else if (eventSource == syncWithName) {
graphTitle.setText(namePanel.getName());
} else if (eventSource == dynamicGraphSize) {
enableDynamicGraph(dynamicGraphSize.isSelected());
} else if (eventSource == samplerSelection) {
enableSamplerSelection(samplerSelection.isSelected());
if (!samplerSelection.isSelected()) {
// Force reload data
forceReloadData = true;
}
}
// Not 'else if' because forceReloadData
if (eventSource == applyFilterBtn || eventSource == intervalButton || forceReloadData) {
if (eventSource == intervalButton) {
intervalValue = Integer.parseInt(intervalField.getText());
}
if (eventSource == applyFilterBtn && samplerSelection.isSelected() && samplerMatchLabel.getText() != null && samplerMatchLabel.getText().length() > 0) {
pattern = createPattern(samplerMatchLabel.getText());
} else if (forceReloadData) {
pattern = null;
}
if (getFile() != null && getFile().length() > 0) {
// Reload data from file
clearData();
FilePanel filePanel = (FilePanel) getFilePanel();
filePanel.actionPerformed(event);
} else {
// Reload data form internal list of results
synchronized (lockInterval) {
if (internalList.size() >= 2) {
List<RespTimeGraphDataBean> tempList = new ArrayList<>();
tempList.addAll(internalList);
this.clearData();
for (RespTimeGraphDataBean data : tempList) {
SampleResult sr = new SampleResult(data.getStartTime(), data.getTime());
sr.setSampleLabel(data.getSamplerLabel());
this.add(sr);
}
}
}
}
}
}
use of org.apache.jmeter.gui.util.FilePanel in project jmeter by apache.
the class HTMLAssertionGui method init.
/**
* Inits the GUI.
*/
private void init() {
// WARNING: called from ctor so must not be overridden (i.e. must be private or final)
setLayout(new BorderLayout(0, 10));
setBorder(makeBorder());
add(makeTitlePanel(), BorderLayout.NORTH);
JPanel mainPanel = new JPanel(new BorderLayout());
// USER_INPUT
VerticalPanel assertionPanel = new VerticalPanel();
assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Tidy Settings"));
// doctype
HorizontalPanel docTypePanel = new HorizontalPanel();
docTypeBox = new JComboBox<>(new String[] { "omit", "auto", "strict", "loose" });
// docTypePanel.add(new
// JLabel(JMeterUtils.getResString("duration_assertion_label"))); //$NON-NLS-1$
docTypePanel.add(new JLabel("Doctype:"));
docTypePanel.add(docTypeBox);
assertionPanel.add(docTypePanel);
// format (HTML, XHTML, XML)
VerticalPanel formatPanel = new VerticalPanel();
formatPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Format"));
//$NON-NLS-1$
htmlRadioButton = new JRadioButton("HTML", true);
//$NON-NLS-1$
xhtmlRadioButton = new JRadioButton("XHTML", false);
//$NON-NLS-1$
xmlRadioButton = new JRadioButton("XML", false);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(htmlRadioButton);
buttonGroup.add(xhtmlRadioButton);
buttonGroup.add(xmlRadioButton);
formatPanel.add(htmlRadioButton);
formatPanel.add(xhtmlRadioButton);
formatPanel.add(xmlRadioButton);
assertionPanel.add(formatPanel);
// errors only
errorsOnly = new JCheckBox("Errors only", false);
errorsOnly.addActionListener(this);
assertionPanel.add(errorsOnly);
// thresholds
HorizontalPanel thresholdPanel = new HorizontalPanel();
thresholdPanel.add(new JLabel("Error threshold:"));
// $NON-NLS-1$
errorThresholdField = new JTextField("0", 5);
errorThresholdField.setName(ERROR_THRESHOLD_FIELD);
errorThresholdField.addKeyListener(this);
thresholdPanel.add(errorThresholdField);
thresholdPanel.add(new JLabel("Warning threshold:"));
// $NON-NLS-1$
warningThresholdField = new JTextField("0", 5);
warningThresholdField.setName(WARNING_THRESHOLD_FIELD);
warningThresholdField.addKeyListener(this);
thresholdPanel.add(warningThresholdField);
assertionPanel.add(thresholdPanel);
// file panel
//$NON-NLS-1$ //$NON-NLS-2$
filePanel = new FilePanel(JMeterUtils.getResString("html_assertion_file"), ".txt");
assertionPanel.add(filePanel);
mainPanel.add(assertionPanel, BorderLayout.NORTH);
add(mainPanel, BorderLayout.CENTER);
}
use of org.apache.jmeter.gui.util.FilePanel in project jmeter by apache.
the class StatGraphVisualizer method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
boolean forceReloadData = false;
final Object eventSource = event.getSource();
if (eventSource == displayButton) {
actionMakeGraph();
} else if (eventSource == saveGraph) {
saveGraphToFile = true;
try {
ActionRouter.getInstance().getAction(ActionNames.SAVE_GRAPHICS, SaveGraphics.class.getName()).doAction(new ActionEvent(this, event.getID(), ActionNames.SAVE_GRAPHICS));
} catch (Exception e) {
log.error("Error saving to file", e);
}
} else if (eventSource == saveTable) {
//$NON-NLS-1$
JFileChooser chooser = FileDialoger.promptToSaveFile("statistics.csv");
if (chooser == null) {
return;
}
try (FileOutputStream fo = new FileOutputStream(chooser.getSelectedFile());
OutputStreamWriter writer = new OutputStreamWriter(fo, Charset.forName("UTF-8"))) {
CSVSaveService.saveCSVStats(getAllTableData(model, getFormatters()), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null);
} catch (IOException e) {
// NOSONAR Error is reported in GUI
JMeterUtils.reportErrorToUser(e.getMessage(), "Error saving data");
}
} else if (eventSource == chooseForeColor) {
Color color = JColorChooser.showDialog(null, //$NON-NLS-1$
JMeterUtils.getResString("aggregate_graph_choose_color"), colorBarGraph);
if (color != null) {
colorForeGraph = color;
}
} else if (eventSource == syncWithName) {
graphTitle.setText(namePanel.getName());
} else if (eventSource == dynamicGraphSize) {
// if use dynamic graph size is checked, we disable the dimension fields
if (dynamicGraphSize.isSelected()) {
graphWidth.setEnabled(false);
graphHeight.setEnabled(false);
} else {
graphWidth.setEnabled(true);
graphHeight.setEnabled(true);
}
} else if (eventSource == columnSelection) {
if (columnSelection.isSelected()) {
columnMatchLabel.setEnabled(true);
applyFilterBtn.setEnabled(true);
caseChkBox.setEnabled(true);
regexpChkBox.setEnabled(true);
} else {
columnMatchLabel.setEnabled(false);
applyFilterBtn.setEnabled(false);
caseChkBox.setEnabled(false);
regexpChkBox.setEnabled(false);
// Force reload data
forceReloadData = true;
}
}
// Not 'else if' because forceReloadData
if (eventSource == applyFilterBtn || forceReloadData) {
if (columnSelection.isSelected() && columnMatchLabel.getText() != null && columnMatchLabel.getText().length() > 0) {
pattern = createPattern(columnMatchLabel.getText());
} else if (forceReloadData) {
pattern = null;
}
if (getFile() != null && getFile().length() > 0) {
clearData();
FilePanel filePanel = (FilePanel) getFilePanel();
filePanel.actionPerformed(event);
}
} else if (eventSource instanceof JButton) {
// Changing color for column
JButton btn = (JButton) eventSource;
if (btn.getName() != null) {
try {
BarGraph bar = eltList.get(Integer.parseInt(btn.getName()));
Color color = JColorChooser.showDialog(null, bar.getLabel(), bar.getBackColor());
if (color != null) {
bar.setBackColor(color);
btn.setBackground(bar.getBackColor());
}
} catch (NumberFormatException nfe) {
// nothing to do
}
}
}
}
Aggregations