diff --git a/core/.classpath b/core/.classpath index b21c5e70c..c2a0e6ca0 100644 --- a/core/.classpath +++ b/core/.classpath @@ -39,5 +39,6 @@ + diff --git a/core/lib/commons-text-1.10.0.jar b/core/lib/commons-text-1.10.0.jar new file mode 100644 index 000000000..beada0274 Binary files /dev/null and b/core/lib/commons-text-1.10.0.jar differ diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 128f876fc..1d2541919 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -536,7 +536,7 @@ simpanel.pop.plot = Plot / Export simpanel.pop.run = Run simpanel.pop.delete = Delete simpanel.pop.duplicate = Duplicate -simpanel.pop.export_to_csv = Export to csv file +simpanel.pop.export_to_csv = Export table to csv file simpanel.checkbox.donotask = Do not ask me again simpanel.lbl.defpref = You can change the default operation in the preferences. simpanel.dlg.lbl.DeleteSim1 = Delete the selected simulations? @@ -1441,6 +1441,7 @@ main.menu.file.quit = Quit main.menu.file.quit.desc = Quit the program main.menu.file.exportDecal = Save decal image\u2026 main.menu.file.exportDecal.desc = Save a decal from the current rocket design to a file for editing. +main.menu.file.table.export_to_csv = Export sim table to csv file main.menu.edit = Edit main.menu.edit.desc = Rocket editing diff --git a/swing/.classpath b/swing/.classpath index e2bf65e9a..3c8f1a5ec 100644 --- a/swing/.classpath +++ b/swing/.classpath @@ -39,5 +39,6 @@ + diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index 82a6fb014..c2db125e5 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -566,6 +566,17 @@ public class BasicFrame extends JFrame { //// END CREATE and implement File > "Encode 3D" menu and submenu */ + // export sim table... + JMenuItem exportSimTableToCSVMenuItem = new JMenuItem(trans.get("main.menu.file.table.export_to_csv")); + exportSimTableToCSVMenuItem.setIcon(Icons.FILE_EXPORT_AS); + menu.add(exportSimTableToCSVMenuItem); + exportSimTableToCSVMenuItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exportSimulationTableToCSVAction(); + } + }); + exportSimTableToCSVMenuItem.setEnabled(simulationPanel.isReadyToExportSimTableToCSV()); menu.addSeparator(); //// Close @@ -1430,7 +1441,10 @@ public class BasicFrame extends JFrame { } // END ROCKSIM Export Action - + public boolean exportSimulationTableToCSVAction() { + simulationPanel.runExportSimTableToCSVAction(); + return false; + } /** * Perform the writing of the design to the given file in RockSim format. * diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index a65443bcf..79d0a9434 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -17,10 +17,8 @@ import java.awt.event.MouseEvent; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -45,6 +43,7 @@ import javax.swing.filechooser.FileFilter; import javax.swing.table.DefaultTableCellRenderer; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -724,7 +723,8 @@ public class SimulationPanel extends JPanel { int nullCnt = 0; rowColumnElement.clear(); - // get the simulation's warning text if any... this bypasses + // get the simulation's warning text if any... this bypasses the need to use + // the column 0 stuff which is kind of difficult to use! WarningSet ws = document.getSimulation(i).getSimulatedWarnings(); String warningsText = ""; for (Warning w : ws) { @@ -738,7 +738,8 @@ public class SimulationPanel extends JPanel { for (int j=1; j