1 package nl.tudelft.goal.ut2004.visualizer.gui.action;
2
3 import javax.swing.JDialog;
4
5 import nl.tudelft.goal.ut2004.visualizer.controller.ServerController;
6 import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
7 import cz.cuni.amis.utils.flag.FlagListener;
8
9
10
11
12
13
14
15
16
17 public class ShowServerDependentDialogueAction extends ShowDialogueAction {
18
19
20
21
22
23
24
25
26
27
28
29 public ShowServerDependentDialogueAction(final JDialog dialog, String name,
30 String description) {
31 super(dialog, name, description);
32
33 ServerController controller = ServerController.getInstance();
34 controller.getServerDefinition().getServerFlag()
35 .addListener(new FlagListener<IUT2004Server>() {
36
37 @Override
38 public void flagChanged(IUT2004Server changedValue) {
39 if (changedValue == null) {
40 setEnabled(false);
41 dialog.setVisible(false);
42 } else {
43 setEnabled(true);
44 }
45 }
46 });
47
48 setEnabled(controller.getServer() != null);
49 }
50
51 }