| 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 jalview.api.AlignCalcWorkerI; |
| 24 |
|
import jalview.gui.AlignFrame; |
| 25 |
|
import jalview.gui.Desktop; |
| 26 |
|
import jalview.gui.JvSwingUtils; |
| 27 |
|
import jalview.util.MessageManager; |
| 28 |
|
import jalview.ws.api.ServiceWithParameters; |
| 29 |
|
import jalview.ws.params.AutoCalcSetting; |
| 30 |
|
import jalview.ws.params.WsParamSetI; |
| 31 |
|
import jalview.ws.uimodel.AlignAnalysisUIText; |
| 32 |
|
|
| 33 |
|
import java.awt.event.ActionEvent; |
| 34 |
|
import java.awt.event.ActionListener; |
| 35 |
|
import java.util.List; |
| 36 |
|
import java.util.Locale; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
import javax.swing.JMenu; |
| 40 |
|
import javax.swing.JMenuItem; |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@author |
| 44 |
|
|
| 45 |
|
|
| |
|
| 26.5% |
Uncovered Elements: 83 (113) |
Complexity: 29 |
Complexity Density: 0.4 |
|
| 46 |
|
public class SequenceAnnotationWSClient extends Jws2Client |
| 47 |
|
{ |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 51 |
3148 |
public SequenceAnnotationWSClient()... |
| 52 |
|
{ |
| 53 |
|
|
| 54 |
|
} |
| 55 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 56 |
0 |
public SequenceAnnotationWSClient(final ServiceWithParameters sh,... |
| 57 |
|
AlignFrame alignFrame, WsParamSetI preset, boolean editParams) |
| 58 |
|
{ |
| 59 |
0 |
super(alignFrame, preset, null); |
| 60 |
0 |
initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| |
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 10 |
Complexity Density: 0.3 |
|
| 66 |
0 |
private void initSequenceAnnotationWSClient(final ServiceWithParameters sh,... |
| 67 |
|
AlignFrame alignFrame, final WsParamSetI preset, boolean editParams) |
| 68 |
|
{ |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
0 |
AlignAnalysisUIText aaui = sh.getAlignAnalysisUI(); |
| 79 |
0 |
if (aaui != null) |
| 80 |
|
{ |
| 81 |
0 |
Class clientClass = aaui.getClient(); |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
0 |
List<AlignCalcWorkerI> clnts = alignFrame.getViewport() |
| 87 |
|
.getCalcManager() |
| 88 |
|
.getWorkersOfClass(SeqAnnotationServiceCalcWorker.class); |
| 89 |
|
|
| 90 |
0 |
SeqAnnotationServiceCalcWorker tmpworker = null; |
| 91 |
0 |
if (clnts != null) |
| 92 |
|
{ |
| 93 |
0 |
for (AlignCalcWorkerI _worker : clnts) |
| 94 |
|
{ |
| 95 |
0 |
tmpworker = (SeqAnnotationServiceCalcWorker) _worker; |
| 96 |
0 |
if (tmpworker.hasService() |
| 97 |
|
&& tmpworker.getService().getClass().equals(clientClass)) |
| 98 |
|
{ |
| 99 |
0 |
break; |
| 100 |
|
} |
| 101 |
0 |
tmpworker = null; |
| 102 |
|
} |
| 103 |
|
} |
| 104 |
0 |
final var worker = tmpworker; |
| 105 |
0 |
if (worker == null) |
| 106 |
|
{ |
| 107 |
0 |
processParams(sh, editParams).thenAccept((startJob) -> { |
| 108 |
0 |
if (startJob) |
| 109 |
|
{ |
| 110 |
0 |
final SeqAnnotationServiceCalcWorker worker_; |
| 111 |
0 |
try |
| 112 |
|
{ |
| 113 |
0 |
worker_ = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset, |
| 114 |
|
paramset); |
| 115 |
|
} catch (Exception x) |
| 116 |
|
{ |
| 117 |
0 |
x.printStackTrace(); |
| 118 |
0 |
throw new Error( |
| 119 |
|
MessageManager.getString("error.implementation_error"), |
| 120 |
|
x); |
| 121 |
|
} |
| 122 |
0 |
alignFrame.getViewport().getCalcManager().registerWorker(worker_); |
| 123 |
|
|
| 124 |
0 |
startSeqAnnotationWorker(sh, alignFrame, preset, editParams); |
| 125 |
|
} |
| 126 |
|
}); |
| 127 |
|
|
| 128 |
|
} |
| 129 |
|
else |
| 130 |
|
{ |
| 131 |
0 |
WsParamSetI preset_; |
| 132 |
0 |
if (editParams) |
| 133 |
|
{ |
| 134 |
0 |
paramset = worker.getArguments(); |
| 135 |
0 |
preset_ = worker.getPreset(); |
| 136 |
|
} |
| 137 |
|
else |
| 138 |
|
{ |
| 139 |
0 |
preset_ = preset; |
| 140 |
|
} |
| 141 |
0 |
processParams(sh, editParams, true).thenAccept((startJob) -> { |
| 142 |
0 |
if (startJob) |
| 143 |
|
{ |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
0 |
alignFrame.getViewport().getCalcManager().enableWorker(worker); |
| 148 |
0 |
worker.updateParameters(this.preset, paramset); |
| 149 |
0 |
startSeqAnnotationWorker(sh, alignFrame, preset_, editParams); |
| 150 |
|
} |
| 151 |
|
}); |
| 152 |
|
} |
| 153 |
|
} |
| 154 |
|
else |
| 155 |
|
{ |
| 156 |
0 |
startSeqAnnotationWorker(sh, alignFrame, preset, editParams); |
| 157 |
|
} |
| 158 |
|
} |
| 159 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 160 |
0 |
private void startSeqAnnotationWorker(ServiceWithParameters sh,... |
| 161 |
|
AlignFrame alignFrame, WsParamSetI preset, boolean editParams) |
| 162 |
|
{ |
| 163 |
0 |
if (!sh.isInteractiveUpdate()) |
| 164 |
|
{ |
| 165 |
|
|
| 166 |
|
|
| 167 |
0 |
processParams(sh, editParams).thenAccept((startJob) -> { |
| 168 |
0 |
if (startJob) |
| 169 |
|
{ |
| 170 |
0 |
alignFrame.getViewport().getCalcManager().startWorker( |
| 171 |
|
new SeqAnnotationServiceCalcWorker(sh, alignFrame, preset, paramset)); |
| 172 |
|
} |
| 173 |
|
}); |
| 174 |
|
} |
| 175 |
|
} |
| 176 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 177 |
0 |
public SequenceAnnotationWSClient(AutoCalcSetting fave,... |
| 178 |
|
AlignFrame alignFrame, boolean b) |
| 179 |
|
{ |
| 180 |
0 |
super(alignFrame, fave.getPreset(), fave.getArgumentSet()); |
| 181 |
0 |
initSequenceAnnotationWSClient(fave.getService(), alignFrame, |
| 182 |
|
fave.getPreset(), b); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@see |
| 189 |
|
|
| 190 |
|
|
| |
|
| 70% |
Uncovered Elements: 12 (40) |
Complexity: 9 |
Complexity Density: 0.32 |
|
| 191 |
3148 |
@Override... |
| 192 |
|
public void attachWSMenuEntry(JMenu wsmenu, |
| 193 |
|
final ServiceWithParameters service, |
| 194 |
|
final AlignFrame alignFrame) |
| 195 |
|
{ |
| 196 |
3148 |
if (Jws2ClientFactory.registerAAConWSInstance(wsmenu, |
| 197 |
|
service, alignFrame)) |
| 198 |
|
{ |
| 199 |
|
|
| 200 |
1066 |
return; |
| 201 |
|
} |
| 202 |
2082 |
boolean hasparams = service.hasParameters(); |
| 203 |
2082 |
String calcName = service.getName(); |
| 204 |
2082 |
if (calcName.endsWith("WS")) |
| 205 |
|
{ |
| 206 |
|
|
| 207 |
2082 |
calcName = calcName.substring(0, calcName.length() - 2); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
2082 |
JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage( |
| 211 |
|
"label.calcname_with_default_settings", new String[] |
| 212 |
|
{ calcName })); |
| 213 |
2082 |
annotservice.addActionListener(new ActionListener() |
| 214 |
|
{ |
| 215 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 216 |
0 |
@Override... |
| 217 |
|
public void actionPerformed(ActionEvent e) |
| 218 |
|
{ |
| 219 |
0 |
new SequenceAnnotationWSClient(service, alignFrame, |
| 220 |
|
null, false); |
| 221 |
|
} |
| 222 |
|
}); |
| 223 |
2082 |
wsmenu.add(annotservice); |
| 224 |
2082 |
if (hasparams) |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
|
|
| 228 |
519 |
annotservice = new JMenuItem( |
| 229 |
|
MessageManager.getString("label.edit_settings_and_run")); |
| 230 |
519 |
annotservice.setToolTipText(MessageManager.getString( |
| 231 |
|
"label.view_and_change_parameters_before_running_calculation")); |
| 232 |
|
|
| 233 |
519 |
annotservice.addActionListener(new ActionListener() |
| 234 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 235 |
0 |
@Override... |
| 236 |
|
public void actionPerformed(ActionEvent e) |
| 237 |
|
{ |
| 238 |
0 |
new SequenceAnnotationWSClient(service, alignFrame, |
| 239 |
|
null, true); |
| 240 |
|
} |
| 241 |
|
}); |
| 242 |
519 |
wsmenu.add(annotservice); |
| 243 |
519 |
List<WsParamSetI> presets = service.getParamStore().getPresets(); |
| 244 |
519 |
if (presets != null && presets.size() > 0) |
| 245 |
|
{ |
| 246 |
0 |
JMenu presetlist = new JMenu(MessageManager |
| 247 |
|
.formatMessage("label.run_with_preset", new String[] |
| 248 |
|
{ calcName })); |
| 249 |
|
|
| 250 |
0 |
for (final WsParamSetI preset : presets) |
| 251 |
|
{ |
| 252 |
0 |
final JMenuItem methodR = new JMenuItem(preset.getName()); |
| 253 |
0 |
methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>" |
| 254 |
0 |
+ (preset.isModifiable() |
| 255 |
|
? MessageManager.getString("label.user_preset") |
| 256 |
|
: MessageManager |
| 257 |
|
.getString("label.service_preset")) |
| 258 |
|
+ "</strong><br/>" + preset.getDescription())); |
| 259 |
0 |
methodR.addActionListener(new ActionListener() |
| 260 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 261 |
0 |
@Override... |
| 262 |
|
public void actionPerformed(ActionEvent e) |
| 263 |
|
{ |
| 264 |
0 |
new SequenceAnnotationWSClient(service, |
| 265 |
|
alignFrame, preset, |
| 266 |
|
false); |
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
}); |
| 270 |
0 |
presetlist.add(methodR); |
| 271 |
|
} |
| 272 |
0 |
wsmenu.add(presetlist); |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
} |
| 276 |
|
else |
| 277 |
|
{ |
| 278 |
1563 |
annotservice = new JMenuItem( |
| 279 |
|
MessageManager.getString("label.view_documentation")); |
| 280 |
1563 |
if (service != null && service.hasDocumentationUrl()) |
| 281 |
|
{ |
| 282 |
1563 |
annotservice.addActionListener(new ActionListener() |
| 283 |
|
{ |
| 284 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 285 |
0 |
@Override... |
| 286 |
|
public void actionPerformed(ActionEvent arg0) |
| 287 |
|
{ |
| 288 |
0 |
Desktop.getInstance().showUrl(service.getDocumentationUrl()); |
| 289 |
|
} |
| 290 |
|
}); |
| 291 |
1563 |
annotservice.setToolTipText( |
| 292 |
|
JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage( |
| 293 |
|
"label.view_service_doc_url", new String[] |
| 294 |
|
{ service.getDocumentationUrl(), |
| 295 |
|
service.getDocumentationUrl() }))); |
| 296 |
1563 |
wsmenu.add(annotservice); |
| 297 |
|
} |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
} |