1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.utgb.client.track.operation;
26
27 import org.utgenome.gwt.utgb.client.track.lib.old.Utilities;
28
29 import com.google.gwt.event.dom.client.ClickEvent;
30 import com.google.gwt.event.dom.client.ClickHandler;
31 import com.google.gwt.user.client.ui.Button;
32 import com.google.gwt.user.client.ui.PopupPanel;
33 import com.google.gwt.user.client.ui.Widget;
34 import com.google.gwt.xml.client.Node;
35
36
37
38
39
40 public class MenuOperationItem extends EventImpl implements ClickHandler {
41 public String caption;
42 private PopupPanel _popupPanel;
43
44 public MenuOperationItem(final Node menuItemNode) {
45 this(Utilities.getAttributeValue(menuItemNode, "caption"));
46 }
47
48 public MenuOperationItem(final String caption) {
49 this.caption = caption;
50 }
51
52 public Widget getWidget(final PopupPanel popupPanel) {
53 final Button widget = new Button(caption);
54 widget.addClickHandler(this);
55
56 _popupPanel = popupPanel;
57
58 return widget;
59 }
60
61 public void onClick(ClickEvent e) {
62 final int operationSize = operations.size();
63 for (int i = 0; i < operationSize; i++) {
64 final Operation operation = (Operation) (operations.get(i));
65 operation.execute((Widget) e.getSource(), -1, -1);
66 }
67
68 _popupPanel.hide();
69 }
70 }