1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jws2; |
22 |
|
|
23 |
|
import java.awt.event.ActionEvent; |
24 |
|
import java.awt.event.ActionListener; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import javax.swing.JCheckBoxMenuItem; |
28 |
|
import javax.swing.JMenu; |
29 |
|
import javax.swing.JMenuItem; |
30 |
|
import javax.swing.event.MenuEvent; |
31 |
|
import javax.swing.event.MenuListener; |
32 |
|
|
33 |
|
import compbio.metadata.Argument; |
34 |
|
import jalview.api.AlignCalcWorkerI; |
35 |
|
import jalview.bin.Console; |
36 |
|
import jalview.gui.AlignFrame; |
37 |
|
import jalview.gui.Desktop; |
38 |
|
import jalview.gui.JvSwingUtils; |
39 |
|
import jalview.gui.WebserviceInfo; |
40 |
|
import jalview.gui.WsJobParameters; |
41 |
|
import jalview.util.MessageManager; |
42 |
|
import jalview.ws.jws2.dm.AAConSettings; |
43 |
|
import jalview.ws.jws2.dm.JabaWsParamSet; |
44 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
45 |
|
import jalview.ws.params.WsParamSetI; |
46 |
|
import jalview.ws.uimodel.AlignAnalysisUIText; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@author |
52 |
|
|
53 |
|
|
|
|
| 0% |
Uncovered Elements: 166 (166) |
Complexity: 53 |
Complexity Density: 0.57 |
|
54 |
|
public abstract class Jws2Client extends jalview.ws.WSClient |
55 |
|
{ |
56 |
|
protected AlignFrame alignFrame; |
57 |
|
|
58 |
|
protected WsParamSetI preset; |
59 |
|
|
60 |
|
protected List<Argument> paramset; |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
62 |
0 |
public Jws2Client(AlignFrame _alignFrame, WsParamSetI preset,... |
63 |
|
List<Argument> arguments) |
64 |
|
{ |
65 |
0 |
alignFrame = _alignFrame; |
66 |
0 |
this.preset = preset; |
67 |
0 |
if (preset != null) |
68 |
|
{ |
69 |
0 |
if (!((preset instanceof JabaPreset) |
70 |
|
|| preset instanceof JabaWsParamSet)) |
71 |
|
{ |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
0 |
throw new Error(MessageManager.getString( |
82 |
|
"error.implementation_error_can_only_instantiate_jaba_param_sets")); |
83 |
|
} |
84 |
|
} |
85 |
|
else |
86 |
|
{ |
87 |
|
|
88 |
0 |
this.paramset = arguments; |
89 |
|
} |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
boolean processParams(Jws2Instance sh, boolean editParams)... |
93 |
|
{ |
94 |
0 |
return processParams(sh, editParams, false); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 9 |
Complexity Density: 0.6 |
|
97 |
0 |
protected boolean processParams(Jws2Instance sh, boolean editParams,... |
98 |
|
boolean adjustingExisting) |
99 |
|
{ |
100 |
|
|
101 |
0 |
if (editParams) |
102 |
|
{ |
103 |
0 |
if (sh.paramStore == null) |
104 |
|
{ |
105 |
0 |
sh.paramStore = new JabaParamStore(sh, |
106 |
|
Desktop.getUserParameterStore()); |
107 |
|
} |
108 |
0 |
WsJobParameters jobParams = (preset == null && paramset != null |
109 |
|
&& paramset.size() > 0) |
110 |
|
? new WsJobParameters(null, sh, null, paramset) |
111 |
|
: new WsJobParameters(sh, preset); |
112 |
0 |
if (adjustingExisting) |
113 |
|
{ |
114 |
0 |
jobParams.setName(MessageManager |
115 |
|
.getString("label.adjusting_parameters_for_calculation")); |
116 |
|
} |
117 |
0 |
if (!jobParams.showRunDialog()) |
118 |
|
{ |
119 |
0 |
return false; |
120 |
|
} |
121 |
0 |
WsParamSetI prset = jobParams.getPreset(); |
122 |
0 |
if (prset == null) |
123 |
|
{ |
124 |
0 |
paramset = |
125 |
|
|
126 |
|
|
127 |
|
JabaParamStore.getJabafromJwsArgs(jobParams.getJobParams()); |
128 |
0 |
this.preset = null; |
129 |
|
} |
130 |
|
else |
131 |
|
{ |
132 |
0 |
this.preset = prset; |
133 |
0 |
paramset = null; |
134 |
|
} |
135 |
|
} |
136 |
0 |
return true; |
137 |
|
|
138 |
|
} |
139 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
140 |
0 |
public Jws2Client()... |
141 |
|
{ |
142 |
|
|
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
145 |
0 |
protected WebserviceInfo setWebService(Jws2Instance serv, boolean b)... |
146 |
|
{ |
147 |
|
|
148 |
0 |
String serviceInstance = serv.action; |
149 |
0 |
WebServiceName = serv.serviceType; |
150 |
0 |
WebServiceJobTitle = serv.getActionText(); |
151 |
0 |
WsURL = serv.hosturl; |
152 |
0 |
if (!b) |
153 |
|
{ |
154 |
0 |
return new WebserviceInfo(WebServiceJobTitle, |
155 |
|
WebServiceJobTitle + " using service hosted at " |
156 |
|
+ serv.hosturl + "\n" |
157 |
0 |
+ (serv.description != null ? serv.description : ""), |
158 |
|
false); |
159 |
|
} |
160 |
0 |
return null; |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
@see |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
@param |
178 |
|
@param |
179 |
|
@param |
180 |
|
|
181 |
|
abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service, |
182 |
|
final AlignFrame alignFrame); |
183 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 9 |
Complexity Density: 0.36 |
|
184 |
0 |
protected boolean registerAAConWSInstance(final JMenu wsmenu,... |
185 |
|
final Jws2Instance service, final AlignFrame alignFrame) |
186 |
|
{ |
187 |
0 |
final AlignAnalysisUIText aaui = service.getAlignAnalysisUI(); |
188 |
|
|
189 |
0 |
if (aaui == null) |
190 |
|
{ |
191 |
|
|
192 |
0 |
return false; |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
0 |
JCheckBoxMenuItem _aaConEnabled = null; |
198 |
0 |
for (int i = 0; i < wsmenu.getItemCount(); i++) |
199 |
|
{ |
200 |
0 |
JMenuItem item = wsmenu.getItem(i); |
201 |
0 |
if (item instanceof JCheckBoxMenuItem |
202 |
|
&& item.getText().equals(aaui.getAAconToggle())) |
203 |
|
{ |
204 |
0 |
_aaConEnabled = (JCheckBoxMenuItem) item; |
205 |
|
} |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
{ |
210 |
0 |
List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport() |
211 |
|
.getCalcManager() |
212 |
|
.getRegisteredWorkersOfClass(aaui.getClient()); |
213 |
0 |
if (aaconClient != null && aaconClient.size() > 0) |
214 |
|
{ |
215 |
0 |
AbstractJabaCalcWorker worker = (AbstractJabaCalcWorker) aaconClient |
216 |
|
.get(0); |
217 |
0 |
if (!worker.service.hosturl.equals(service.hosturl)) |
218 |
|
{ |
219 |
|
|
220 |
|
{ |
221 |
|
|
222 |
|
|
223 |
|
{ |
224 |
0 |
removeCurrentAAConWorkerFor(aaui, alignFrame); |
225 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame, service); |
226 |
|
} |
227 |
|
} |
228 |
|
} |
229 |
|
} |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
0 |
if (_aaConEnabled == null) |
235 |
|
{ |
236 |
0 |
final JCheckBoxMenuItem aaConEnabled = new JCheckBoxMenuItem( |
237 |
|
aaui.getAAconToggle()); |
238 |
|
|
239 |
0 |
aaConEnabled.setToolTipText( |
240 |
|
JvSwingUtils.wrapTooltip(true, aaui.getAAconToggleTooltip())); |
241 |
0 |
aaConEnabled.addActionListener(new ActionListener() |
242 |
|
{ |
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
243 |
0 |
@Override... |
244 |
|
public void actionPerformed(ActionEvent arg0) |
245 |
|
{ |
246 |
0 |
List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport() |
247 |
|
.getCalcManager() |
248 |
|
.getRegisteredWorkersOfClass(aaui.getClient()); |
249 |
0 |
if (aaconClient != null && aaconClient.size() > 0) |
250 |
|
{ |
251 |
0 |
removeCurrentAAConWorkerFor(aaui, alignFrame); |
252 |
|
} |
253 |
|
else |
254 |
|
{ |
255 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame); |
256 |
|
|
257 |
|
} |
258 |
|
} |
259 |
|
|
260 |
|
}); |
261 |
0 |
wsmenu.add(aaConEnabled); |
262 |
0 |
final JMenuItem modifyParams = new JMenuItem( |
263 |
|
aaui.getAAeditSettings()); |
264 |
0 |
modifyParams.setToolTipText(JvSwingUtils.wrapTooltip(true, |
265 |
|
aaui.getAAeditSettingsTooltip())); |
266 |
0 |
modifyParams.addActionListener(new ActionListener() |
267 |
|
{ |
268 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
269 |
0 |
@Override... |
270 |
|
public void actionPerformed(ActionEvent arg0) |
271 |
|
{ |
272 |
0 |
showAAConAnnotationSettingsFor(aaui, alignFrame); |
273 |
|
} |
274 |
|
}); |
275 |
0 |
wsmenu.add(modifyParams); |
276 |
0 |
wsmenu.addMenuListener(new MenuListener() |
277 |
|
{ |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
279 |
0 |
@Override... |
280 |
|
public void menuSelected(MenuEvent arg0) |
281 |
|
{ |
282 |
|
|
283 |
0 |
if (alignFrame.getViewport().getAlignment().isNucleotide() |
284 |
|
? aaui.isNa() |
285 |
|
: aaui.isPr()) |
286 |
|
{ |
287 |
0 |
aaConEnabled.setEnabled(true); |
288 |
0 |
modifyParams.setEnabled(true); |
289 |
|
} |
290 |
|
else |
291 |
|
{ |
292 |
0 |
aaConEnabled.setEnabled(false); |
293 |
0 |
modifyParams.setEnabled(false); |
294 |
|
} |
295 |
0 |
List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport() |
296 |
|
.getCalcManager() |
297 |
|
.getRegisteredWorkersOfClass(aaui.getClient()); |
298 |
0 |
if (aaconClient != null && aaconClient.size() > 0) |
299 |
|
{ |
300 |
0 |
aaConEnabled.setSelected(true); |
301 |
|
} |
302 |
|
else |
303 |
|
{ |
304 |
0 |
aaConEnabled.setSelected(false); |
305 |
|
} |
306 |
|
} |
307 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
308 |
0 |
@Override... |
309 |
|
public void menuDeselected(MenuEvent arg0) |
310 |
|
{ |
311 |
|
|
312 |
|
|
313 |
|
} |
314 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
315 |
0 |
@Override... |
316 |
|
public void menuCanceled(MenuEvent arg0) |
317 |
|
{ |
318 |
|
|
319 |
|
|
320 |
|
} |
321 |
|
}); |
322 |
|
|
323 |
|
} |
324 |
0 |
return true; |
325 |
|
} |
326 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
327 |
0 |
private static void showAAConAnnotationSettingsFor(... |
328 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame) |
329 |
|
{ |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
0 |
AAConSettings fave = (AAConSettings) alignFrame.getViewport() |
336 |
|
.getCalcIdSettingsFor(aaui.getCalcId()); |
337 |
0 |
if (fave == null) |
338 |
|
{ |
339 |
0 |
fave = createDefaultAAConSettings(aaui); |
340 |
|
} |
341 |
0 |
new SequenceAnnotationWSClient(fave, alignFrame, true); |
342 |
|
|
343 |
|
} |
344 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
345 |
0 |
private static void buildCurrentAAConWorkerFor(... |
346 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame) |
347 |
|
{ |
348 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame, null); |
349 |
|
} |
350 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
351 |
0 |
private static void buildCurrentAAConWorkerFor(... |
352 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame, |
353 |
|
Jws2Instance service) |
354 |
|
{ |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
0 |
AAConSettings fave = (AAConSettings) alignFrame.getViewport() |
360 |
|
.getCalcIdSettingsFor(aaui.getCalcId()); |
361 |
0 |
if (fave == null) |
362 |
|
{ |
363 |
0 |
fave = createDefaultAAConSettings(aaui, service); |
364 |
|
} |
365 |
|
else |
366 |
|
{ |
367 |
0 |
if (service != null |
368 |
|
&& !fave.getService().hosturl.equals(service.hosturl)) |
369 |
|
{ |
370 |
0 |
Console.debug("Changing AACon service to " + service.hosturl |
371 |
|
+ " from " + fave.getService().hosturl); |
372 |
0 |
fave.setService(service); |
373 |
|
} |
374 |
|
} |
375 |
0 |
new SequenceAnnotationWSClient(fave, alignFrame, false); |
376 |
|
} |
377 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
378 |
0 |
private static AAConSettings createDefaultAAConSettings(... |
379 |
|
AlignAnalysisUIText aaui) |
380 |
|
{ |
381 |
0 |
return createDefaultAAConSettings(aaui, null); |
382 |
|
} |
383 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.55 |
|
384 |
0 |
private static AAConSettings createDefaultAAConSettings(... |
385 |
|
AlignAnalysisUIText aaui, Jws2Instance service) |
386 |
|
{ |
387 |
0 |
if (service != null) |
388 |
|
{ |
389 |
0 |
if (!service.serviceType.toString() |
390 |
|
.equals(compbio.ws.client.Services.AAConWS.toString())) |
391 |
|
{ |
392 |
0 |
Console.warn( |
393 |
|
"Ignoring invalid preferred service for AACon calculations (service type was " |
394 |
|
+ service.serviceType + ")"); |
395 |
0 |
service = null; |
396 |
|
} |
397 |
|
else |
398 |
|
{ |
399 |
|
|
400 |
|
|
401 |
0 |
if (!Jws2Discoverer.getDiscoverer().getServices().contains(service)) |
402 |
|
{ |
403 |
|
|
404 |
0 |
service = null; |
405 |
|
} |
406 |
|
} |
407 |
|
} |
408 |
0 |
if (service == null) |
409 |
|
{ |
410 |
|
|
411 |
0 |
service = Jws2Discoverer.getDiscoverer().getPreferredServiceFor(null, |
412 |
|
aaui.getServiceType()); |
413 |
|
} |
414 |
0 |
if (service == null) |
415 |
|
{ |
416 |
|
|
417 |
|
|
418 |
0 |
throw new Error( |
419 |
|
MessageManager.getString("error.no_aacon_service_found")); |
420 |
|
} |
421 |
0 |
return new AAConSettings(true, service, null, null); |
422 |
|
} |
423 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
424 |
0 |
private static void removeCurrentAAConWorkerFor(AlignAnalysisUIText aaui,... |
425 |
|
AlignFrame alignFrame) |
426 |
|
{ |
427 |
0 |
alignFrame.getViewport().getCalcManager() |
428 |
|
.removeRegisteredWorkersOfClass(aaui.getClient()); |
429 |
|
} |
430 |
|
|
431 |
|
} |