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.lib.old;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30 import org.utgenome.gwt.utgb.client.RPCServiceManager;
31 import org.utgenome.gwt.utgb.client.track.Track;
32 import org.utgenome.gwt.utgb.client.track.TrackGroup;
33 import org.utgenome.gwt.utgb.client.track.TrackGroupProperty;
34 import org.utgenome.gwt.utgb.client.track.TrackWindow;
35 import org.utgenome.gwt.utgb.client.track.operation.Operation;
36 import org.utgenome.gwt.utgb.client.track.operation.OperationParser;
37 import org.utgenome.gwt.utgb.client.track.operation.SubOperation;
38
39 import com.google.gwt.user.client.rpc.AsyncCallback;
40 import com.google.gwt.user.client.ui.Widget;
41 import com.google.gwt.xml.client.Document;
42 import com.google.gwt.xml.client.Node;
43 import com.google.gwt.xml.client.NodeList;
44 import com.google.gwt.xml.client.XMLParser;
45
46
47
48
49
50 public class OldUTGBSubOperationImpl extends SubOperation {
51
52
53
54
55
56 public OldUTGBSubOperationImpl(Node subOperationNode, Track track) {
57 super(subOperationNode, track);
58 }
59
60 public void execute(Widget sender, int x, int y) {
61 final TrackGroup trackGroup = getTrack().getTrackGroup();
62
63 final Map<String, String> parameterMap = new HashMap<String, String>();
64
65 final String[] propertyNameArray = OldUTGBProperty.getPropertyNameArray();
66
67 final TrackGroupProperty propertyReader = trackGroup.getPropertyReader();
68
69 for (int i = 0; i < propertyNameArray.length; i++) {
70 final String key = propertyNameArray[i];
71 final String value = propertyReader.getProperty(key);
72
73 parameterMap.put(key, value);
74 }
75
76 final TrackWindow trackWindow = trackGroup.getTrackWindow();
77
78 final long startIndex = trackWindow.getStartOnGenome();
79 final long endIndex = trackWindow.getEndOnGenome();
80
81 parameterMap.put("start", Long.toString(startIndex));
82 parameterMap.put("end", Long.toString(endIndex));
83 parameterMap.put("width", Integer.toString(((OldUTGBTrack) track).getMainPanelWidth()));
84
85 {
86 final Widget absoluteParentPanel = sender.getParent();
87
88 final int parentAbsX = absoluteParentPanel.getAbsoluteLeft();
89 final int parentAbsY = absoluteParentPanel.getAbsoluteTop();
90
91 final int selfAbsX = sender.getAbsoluteLeft();
92 final int selfAbsY = sender.getAbsoluteTop();
93
94 final int relativeX = selfAbsX - parentAbsX + x;
95 final int relativeY = selfAbsY - parentAbsY + y;
96
97 parameterMap.put("pos", Integer.toString(relativeX) + "," + Integer.toString(relativeY));
98
99 }
100
101 final String fullURL = url.getURL(parameterMap);
102
103 RPCServiceManager.getRPCService().getHTTPContent(fullURL, new Command(sender, x, y));
104 }
105
106 private class Command implements AsyncCallback<String> {
107 private final Widget sender;
108 private final int x;
109 private final int y;
110
111 Command(final Widget sender, final int x, final int y) {
112 this.sender = sender;
113 this.x = x;
114 this.y = y;
115 }
116
117 public void onFailure(Throwable caught) {
118 }
119
120 public void onSuccess(String text) {
121 if (text.length() <= 0) {
122 return;
123 }
124 {
125 final Document dom = XMLParser.parse(text);
126
127 final NodeList suboperation_layerNodeList = dom.getElementsByTagName("suboperation_layer");
128 if (suboperation_layerNodeList.getLength() != 1) {
129 throw new AssertionError();
130 }
131
132 final Node suboperation_layerNode = suboperation_layerNodeList.item(0);
133
134 final NodeList operationNodeList = Utilities.getTagChildNodes(suboperation_layerNode);
135 for (int k = 0; k < operationNodeList.getLength(); k++) {
136 final Node operationNode = operationNodeList.item(k);
137
138 final OperationParser parser = OldUTGBOperationParser.getParser();
139 final Operation operation = parser.parseOperationNode(operationNode, track);
140
141 operation.execute(sender, x, y);
142 }
143 }
144 }
145
146 }
147
148 }