Merge pull request #135 from kruland2607/simexport
Added ability to export different branches from simulations. Change the ok button text based on selected tab.
This commit is contained in:
commit
788301be81
@ -387,6 +387,7 @@ simedtdlg.IntensityDesc.Veryhigh = Very high
|
||||
simedtdlg.IntensityDesc.Extreme = Extreme
|
||||
|
||||
SimulationEditDialog.btn.plot = Plot
|
||||
SimulationEditDialog.btn.export = Export
|
||||
SimulationEditDialog.btn.edit = Edit
|
||||
SimulationEditDialog.btn.simulateAndPlot = Simulate & Plot
|
||||
|
||||
|
@ -14,6 +14,8 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
@ -264,7 +266,25 @@ public class SimulationEditDialog extends JDialog {
|
||||
|
||||
plotExportPanel.add(button, "spanx, split 3, align left");
|
||||
|
||||
JButton ok = new JButton(trans.get("SimulationEditDialog.btn.plot"));
|
||||
final JButton ok = new JButton(trans.get("SimulationEditDialog.btn.plot"));
|
||||
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
int selectedIndex = tabbedPane.getSelectedIndex();
|
||||
switch (selectedIndex) {
|
||||
case 0:
|
||||
ok.setText(trans.get("SimulationEditDialog.btn.plot"));
|
||||
break;
|
||||
case 1:
|
||||
ok.setText(trans.get("SimulationEditDialog.btn.export"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -3,11 +3,15 @@ package net.sf.openrocket.gui.simulation;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@ -23,6 +27,7 @@ import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.gui.components.CsvOptionPanel;
|
||||
import net.sf.openrocket.gui.components.UnitCellEditor;
|
||||
import net.sf.openrocket.gui.plot.Util;
|
||||
import net.sf.openrocket.gui.util.FileHelper;
|
||||
import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.gui.util.SaveCSVWorker;
|
||||
@ -50,7 +55,7 @@ public class SimulationExportPanel extends JPanel {
|
||||
private final JLabel selectedCountLabel;
|
||||
|
||||
private final Simulation simulation;
|
||||
private final FlightDataBranch branch;
|
||||
private FlightDataBranch branch;
|
||||
|
||||
private final boolean[] selected;
|
||||
private final FlightDataType[] types;
|
||||
@ -65,11 +70,8 @@ public class SimulationExportPanel extends JPanel {
|
||||
JPanel panel;
|
||||
JButton button;
|
||||
|
||||
|
||||
this.simulation = sim;
|
||||
|
||||
// TODO: MEDIUM: Only exports primary branch
|
||||
|
||||
final FlightData data = simulation.getSimulatedData();
|
||||
|
||||
// Check that data exists
|
||||
@ -173,6 +175,27 @@ public class SimulationExportPanel extends JPanel {
|
||||
|
||||
this.add(csvOptions, "spany, split, growx 1");
|
||||
|
||||
//// Add series selection box
|
||||
ArrayList<String> stages = new ArrayList<String>();
|
||||
stages.addAll(Util.generateSeriesLabels(simulation));
|
||||
|
||||
final JComboBox stageSelection = new JComboBox(stages.toArray(new String[0]));
|
||||
stageSelection.addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
int selectedStage = stageSelection.getSelectedIndex();
|
||||
branch = data.getBranch(selectedStage);
|
||||
}
|
||||
|
||||
});
|
||||
if (stages.size() > 1) {
|
||||
// Only show the combo box if there are at least 2 entries (ie, "Main", and one other one
|
||||
JPanel stagePanel = new JPanel(new MigLayout("fill"));
|
||||
stagePanel.setBorder(BorderFactory.createTitledBorder(trans.get("SimExpPan.border.Stage")));
|
||||
stagePanel.add(stageSelection, "growx");
|
||||
this.add(stagePanel, "spany, split, growx 1");
|
||||
}
|
||||
|
||||
// Space-filling panel
|
||||
panel = new JPanel();
|
||||
@ -191,7 +214,6 @@ public class SimulationExportPanel extends JPanel {
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public boolean doExport() {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setFileFilter(FileHelper.CSV_FILE_FILTER);
|
||||
|
Loading…
x
Reference in New Issue
Block a user