|
|
@@ -2,8 +2,11 @@ package gui.simulator;
|
|
|
|
|
|
import agenda.Agenda;
|
|
|
import agenda.Stage;
|
|
|
+import gui.simulator.facilities.SimulatorStage;
|
|
|
|
|
|
import javax.swing.*;
|
|
|
+import java.awt.event.ActionEvent;
|
|
|
+import java.awt.event.ActionListener;
|
|
|
|
|
|
/**
|
|
|
* Created by gjoosen on 26/03/15.
|
|
|
@@ -11,8 +14,11 @@ import javax.swing.*;
|
|
|
public class StageDialog extends JDialog {
|
|
|
|
|
|
private Agenda agenda;
|
|
|
+ private DrawEngine drawEngine;
|
|
|
+ private JComboBox<Stage> comboBox;
|
|
|
|
|
|
- public StageDialog(Agenda agenda){
|
|
|
+ public StageDialog(DrawEngine drawEngine, Agenda agenda){
|
|
|
+ this.drawEngine = drawEngine;
|
|
|
this.agenda = agenda;
|
|
|
super.setContentPane(this.panel());
|
|
|
super.pack();
|
|
|
@@ -25,8 +31,39 @@ public class StageDialog extends JDialog {
|
|
|
//TODO dialog
|
|
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
|
|
panel.add(new JLabel("Stage: "));
|
|
|
- panel.add(this.comboBox());
|
|
|
+ this.comboBox = this.comboBox();
|
|
|
+ panel.add(this.comboBox);
|
|
|
+ panel.add(this.buttons());
|
|
|
+ return panel;
|
|
|
+ }
|
|
|
+
|
|
|
+ private JPanel buttons(){
|
|
|
+ JPanel panel = new JPanel();
|
|
|
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
|
|
+
|
|
|
+ JButton save = new JButton("save");
|
|
|
+ save.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ //TODO save
|
|
|
+ if(drawEngine instanceof SimulatorStage){
|
|
|
+ SimulatorStage stage = (SimulatorStage) drawEngine;
|
|
|
+
|
|
|
+ //if stage isn't set
|
|
|
+ if(stage.getStage() == null){
|
|
|
+ stage.setStage((Stage) comboBox.getSelectedItem());
|
|
|
+ stage.getStage().setInUse(true);
|
|
|
+ }else{
|
|
|
+ stage.getStage().setInUse(false);
|
|
|
+ stage.setStage((Stage) comboBox.getSelectedItem());
|
|
|
+ stage.getStage().setInUse(true);
|
|
|
+ }
|
|
|
|
|
|
+ dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ panel.add(save);
|
|
|
return panel;
|
|
|
}
|
|
|
|
|
|
@@ -35,7 +72,9 @@ public class StageDialog extends JDialog {
|
|
|
DefaultComboBoxModel<Stage> defaultComboBoxModel = new DefaultComboBoxModel<>();
|
|
|
|
|
|
for(Stage stage: this.agenda.getStages()){
|
|
|
- defaultComboBoxModel.addElement(stage);
|
|
|
+ if(!stage.inUse()){
|
|
|
+ defaultComboBoxModel.addElement(stage);
|
|
|
+ }
|
|
|
}
|
|
|
JComboBox<Stage> stages = new JComboBox<>(defaultComboBoxModel);
|
|
|
return stages;
|