1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.vectomatic.client.rep.controller;
19
20 import org.vectomatic.client.rep.view.DrawingView;
21
22 import com.google.gwt.user.client.Command;
23 import com.google.gwt.user.client.ui.MenuItem;
24
25
26
27
28
29 public class ControllerMenuItem extends MenuItem implements Command {
30 private IController _controller;
31 private boolean _enabled;
32 private DrawingView _view;
33 public ControllerMenuItem(DrawingView view, String text, IController controller) {
34 super(text, (Command)null);
35 setCommand(this);
36 _view = view;
37 _controller = controller;
38 _enabled = true;
39 }
40 public void execute() {
41 if (_enabled) {
42 _controller.activate(_view);
43 }
44 }
45 public boolean isEnabled() {
46 return _enabled;
47 }
48 public void setEnabled(boolean enabled) {
49 if (_enabled != enabled) {
50 _enabled = enabled;
51 if (enabled) {
52 removeStyleName("gwt-MenuItem-disabled");
53 } else {
54 addStyleName("gwt-MenuItem-disabled");
55 }
56 }
57 }
58 }