@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("summary.csv"); // $NON-NLS-1$ if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); CSVSaveService.saveCSVStats(model, writer, saveHeaders.isSelected()); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
@Override public void saveGraphToCSV(File file) throws IOException { log.info("Saving CSV to " + file.getAbsolutePath()); FileWriter writer = null; try { writer = new FileWriter(file); CSVSaveService.saveCSVStats( getAllTableData(model, FORMATS), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { try { writer.close(); } catch (IOException ex) { log.warn("There was problem closing file stream", ex); } } }
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("synthesis.csv"); // $NON-NLS-1$ if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats( getAllTableData(model, FORMATS), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
@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, 1, ActionNames.SAVE_GRAPHICS)); } catch (Exception e) { log.error(e.getMessage()); } } else if (eventSource == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("statistics.csv"); // $NON-NLS-1$ if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO Charset ? CSVSaveService.saveCSVStats( getAllTableData(), writer, saveHeaders.isSelected() ? COLUMNS : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } else if (eventSource == chooseForeColor) { Color color = JColorChooser.showDialog( null, JMeterUtils.getResString("aggregate_graph_choose_color"), // $NON-NLS-1$ 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; matcher = 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 } } }