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.RPCServiceManager;
28 import org.utgenome.gwt.utgb.client.track.Track;
29 import org.utgenome.gwt.utgb.client.track.lib.old.Utilities;
30 import org.utgenome.gwt.utgb.client.util.GETMethodURL;
31
32 import com.google.gwt.user.client.rpc.AsyncCallback;
33 import com.google.gwt.user.client.ui.Widget;
34 import com.google.gwt.xml.client.Document;
35 import com.google.gwt.xml.client.Node;
36 import com.google.gwt.xml.client.NodeList;
37 import com.google.gwt.xml.client.XMLParser;
38
39
40
41
42
43 public class SubOperation extends OperationImpl {
44 protected final GETMethodURL url;
45
46 public SubOperation(final Node subOperationNode, final Track track) {
47 super(track);
48
49 this.url = GETMethodURL.newInstance(Utilities.getAttributeValue(subOperationNode, "url"));
50 }
51
52 public void execute(Widget sender, int x, int y) {
53 final String fullURL = url.getURL();
54
55 RPCServiceManager.getRPCService().getHTTPContent(fullURL, new Command(sender, x, y));
56 }
57
58 private class Command implements AsyncCallback<String> {
59 private final Widget sender;
60 private final int x;
61 private final int y;
62
63 Command(final Widget sender, final int x, final int y) {
64 this.sender = sender;
65 this.x = x;
66 this.y = y;
67 }
68
69 public void onFailure(Throwable caught) {
70 }
71
72 public void onSuccess(String result) {
73 if (result.length() <= 0) {
74 return;
75 }
76 {
77 final Document dom = XMLParser.parse(result);
78
79 final NodeList suboperation_layerNodeList = dom.getElementsByTagName("suboperation_layer");
80 if (suboperation_layerNodeList.getLength() != 1) {
81 throw new AssertionError();
82 }
83
84 final Node suboperation_layerNode = suboperation_layerNodeList.item(0);
85
86 final NodeList operationNodeList = Utilities.getTagChildNodes(suboperation_layerNode);
87 for (int k = 0; k < operationNodeList.getLength(); k++) {
88 final Node operationNode = operationNodeList.item(k);
89
90 final OperationParser parser = OperationParser.getParser();
91 final Operation operation = parser.parseOperationNode(operationNode, track);
92
93 operation.execute(sender, x, y);
94 }
95 }
96 }
97
98 }
99
100 }