[#2148] Apply sim changes when window closes
This commit is contained in:
parent
5fcf3e9850
commit
f7a66472d5
@ -5,6 +5,9 @@ import java.awt.CardLayout;
|
|||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
@ -42,6 +45,8 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
JPanel cards;
|
JPanel cards;
|
||||||
private final static String EDITMODE = "EDIT";
|
private final static String EDITMODE = "EDIT";
|
||||||
private final static String PLOTMODE = "PLOT";
|
private final static String PLOTMODE = "PLOT";
|
||||||
|
|
||||||
|
private WindowListener applyChangesToSimsListener;
|
||||||
|
|
||||||
public SimulationEditDialog(Window parent, final OpenRocketDocument document, Simulation... sims) {
|
public SimulationEditDialog(Window parent, final OpenRocketDocument document, Simulation... sims) {
|
||||||
//// Edit simulation
|
//// Edit simulation
|
||||||
@ -59,6 +64,14 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
this.pack();
|
this.pack();
|
||||||
|
|
||||||
this.setLocationByPlatform(true);
|
this.setLocationByPlatform(true);
|
||||||
|
|
||||||
|
this.applyChangesToSimsListener = new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
copyChangesToAllSims();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.addWindowListener(applyChangesToSimsListener);
|
||||||
|
|
||||||
GUIUtil.setDisposableDialogOptions(this, null);
|
GUIUtil.setDisposableDialogOptions(this, null);
|
||||||
}
|
}
|
||||||
@ -75,12 +88,14 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
CardLayout cl = (CardLayout) (cards.getLayout());
|
CardLayout cl = (CardLayout) (cards.getLayout());
|
||||||
cl.show(cards, EDITMODE);
|
cl.show(cards, EDITMODE);
|
||||||
cards.validate();
|
cards.validate();
|
||||||
|
this.addWindowListener(applyChangesToSimsListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlotMode() {
|
public void setPlotMode() {
|
||||||
if (!allowsPlotMode()) {
|
if (!allowsPlotMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.removeWindowListener(applyChangesToSimsListener);
|
||||||
setTitle(trans.get("simplotpanel.title.Plotsim"));
|
setTitle(trans.get("simplotpanel.title.Plotsim"));
|
||||||
CardLayout cl = (CardLayout) (cards.getLayout());
|
CardLayout cl = (CardLayout) (cards.getLayout());
|
||||||
cl.show(cards, PLOTMODE);
|
cl.show(cards, PLOTMODE);
|
||||||
@ -223,7 +238,6 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
close.addActionListener(new ActionListener() {
|
close.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
copyChangesToAllSims();
|
|
||||||
SimulationEditDialog.this.dispose();
|
SimulationEditDialog.this.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user