@Override public void actionPerformed(final ActionEvent e) { JFileChooser chooser = savePath != null ? new JFileChooser(new File(savePath)) : new JFileChooser(new File(".")); chooser.setFileFilter(new FileNameExtensionFilter("CSV Files", "csv")); int returnVal = chooser.showSaveDialog(GraphPanelChart.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.getAbsolutePath().toUpperCase().endsWith(".CSV")) { file = new File(file.getAbsolutePath() + ".csv"); } savePath = file.getParent(); boolean doSave = true; if (file.exists()) { int choice = JOptionPane.showConfirmDialog(GraphPanelChart.this, "Do you want to overwrite " + file.getAbsolutePath() + "?", "Export to CSV File", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); doSave = (choice == JOptionPane.YES_OPTION); } if (doSave) { try { saveGraphToCSV(file); } catch (IOException ex) { JOptionPane.showConfirmDialog(GraphPanelChart.this, "Impossible to write the CSV file:\n" + ex.getMessage(), "Export to CSV File", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } } } } }
@Override public void actionPerformed(final ActionEvent e) { JFileChooser chooser = savePath != null ? new JFileChooser(new File(savePath)) : new JFileChooser(new File(".")); chooser.setFileFilter(new FileNameExtensionFilter("CSV Files", "csv")); int returnVal = chooser.showSaveDialog(GraphPanelChart.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.getAbsolutePath().toUpperCase().endsWith(".CSV")) { file = new File(file.getAbsolutePath() + ".csv"); } savePath = file.getParent(); boolean doSave = true; if (file.exists()) { int choice = JOptionPane.showConfirmDialog(GraphPanelChart.this, "Do you want to overwrite " + file.getAbsolutePath() + "?", "Export to CSV File", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); doSave = (choice == JOptionPane.YES_OPTION); } if (doSave) { try { saveGraphToCSV(file); } catch (IOException ex) { JOptionPane.showConfirmDialog(GraphPanelChart.this, "Impossible to write the CSV file:\n" + ex.getMessage(), "Export to CSV File", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } } } } }
pluginInstance.getGraphPanelChart().saveGraphToCSV(csvFile); } catch (IOException ex) { throw new RuntimeException(ex);
pluginInstance.getGraphPanelChart().saveGraphToCSV(csvFile); } catch (IOException ex) { throw new RuntimeException(ex);