Explicitly create the plot with a parent window so the configuration
window can be dismissed automatically.
This commit is contained in:
parent
9107566b38
commit
4716030d1b
@ -16,28 +16,19 @@ import net.sf.openrocket.document.OpenRocketDocument;
|
|||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.Configuration;
|
|
||||||
import net.sf.openrocket.simulation.FlightData;
|
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
public class SimulationPlotExportDialog extends JDialog {
|
public class SimulationPlotExportDialog extends JDialog {
|
||||||
|
|
||||||
private final Window parentWindow;
|
private final Window parentWindow;
|
||||||
private final Simulation simulation;
|
private final Simulation simulation;
|
||||||
private final OpenRocketDocument document;
|
|
||||||
private final SimulationOptions conditions;
|
|
||||||
private final Configuration configuration;
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
public SimulationPlotExportDialog(Window parent, OpenRocketDocument document, Simulation s) {
|
public SimulationPlotExportDialog(Window parent, OpenRocketDocument document, Simulation s) {
|
||||||
//// Plot/Export simulation
|
//// Plot/Export simulation
|
||||||
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
||||||
this.document = document;
|
|
||||||
this.parentWindow = parent;
|
this.parentWindow = parent;
|
||||||
this.simulation = s;
|
this.simulation = s;
|
||||||
this.conditions = simulation.getOptions();
|
|
||||||
configuration = simulation.getConfiguration();
|
|
||||||
|
|
||||||
JPanel mainPanel = new JPanel(new MigLayout("fill", "[grow]"));
|
JPanel mainPanel = new JPanel(new MigLayout("fill", "[grow]"));
|
||||||
|
|
||||||
@ -50,10 +41,10 @@ public class SimulationPlotExportDialog extends JDialog {
|
|||||||
final JTabbedPane tabbedPane = new JTabbedPane();
|
final JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
|
||||||
//// Plot data
|
//// Plot data
|
||||||
final SimulationPlotPanel plotTab = plotTab();
|
final SimulationPlotPanel plotTab = new SimulationPlotPanel(simulation);
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Plotdata"), plotTab);
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Plotdata"), plotTab);
|
||||||
//// Export data
|
//// Export data
|
||||||
final SimulationExportPanel exportTab = exportTab();
|
final SimulationExportPanel exportTab = new SimulationExportPanel(simulation);
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Exportdata"), exportTab);
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Exportdata"), exportTab);
|
||||||
|
|
||||||
mainPanel.add(tabbedPane, "grow, wrap");
|
mainPanel.add(tabbedPane, "grow, wrap");
|
||||||
@ -64,7 +55,7 @@ public class SimulationPlotExportDialog extends JDialog {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
if (tabbedPane.getSelectedIndex() == 0) {
|
if (tabbedPane.getSelectedIndex() == 0) {
|
||||||
JDialog plot = plotTab.doPlot();
|
JDialog plot = plotTab.doPlot(SimulationPlotExportDialog.this.parentWindow);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
SimulationPlotExportDialog.this.dispose();
|
SimulationPlotExportDialog.this.dispose();
|
||||||
plot.setVisible(true);
|
plot.setVisible(true);
|
||||||
@ -98,40 +89,4 @@ public class SimulationPlotExportDialog extends JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A panel for plotting the previously calculated data.
|
|
||||||
*/
|
|
||||||
private SimulationPlotPanel plotTab() {
|
|
||||||
|
|
||||||
// Check that data exists
|
|
||||||
// FIXME -
|
|
||||||
/*
|
|
||||||
if (simulation.getSimulatedData() == null ||
|
|
||||||
simulation.getSimulatedData().getBranchCount() == 0) {
|
|
||||||
return noDataPanel();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return new SimulationPlotPanel(simulation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A panel for exporting the data.
|
|
||||||
*/
|
|
||||||
private SimulationExportPanel exportTab() {
|
|
||||||
FlightData data = simulation.getSimulatedData();
|
|
||||||
|
|
||||||
// Check that data exists
|
|
||||||
// FIXME -
|
|
||||||
/*
|
|
||||||
if (data == null || data.getBranchCount() == 0 ||
|
|
||||||
data.getBranch(0).getTypes().length == 0) {
|
|
||||||
return noDataPanel();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return new SimulationExportPanel(simulation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import javax.swing.table.TableColumnModel;
|
import javax.swing.table.TableColumnModel;
|
||||||
@ -321,7 +320,7 @@ public class SimulationPlotPanel extends JPanel {
|
|||||||
updatePlots();
|
updatePlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JDialog doPlot() {
|
public JDialog doPlot(Window parent) {
|
||||||
if (configuration.getTypeCount() == 0) {
|
if (configuration.getTypeCount() == 0) {
|
||||||
JOptionPane.showMessageDialog(SimulationPlotPanel.this,
|
JOptionPane.showMessageDialog(SimulationPlotPanel.this,
|
||||||
trans.get("error.noPlotSelected"),
|
trans.get("error.noPlotSelected"),
|
||||||
@ -330,8 +329,7 @@ public class SimulationPlotPanel extends JPanel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
defaultConfiguration = configuration.clone();
|
defaultConfiguration = configuration.clone();
|
||||||
return SimulationPlotDialog.getPlot((Window) SwingUtilities.getRoot(SimulationPlotPanel.this),
|
return SimulationPlotDialog.getPlot(parent, simulation, configuration);
|
||||||
simulation, configuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConfiguration(PlotConfiguration conf) {
|
private void setConfiguration(PlotConfiguration conf) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user