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