| 1 |
|
package jalview.ws.jws2; |
| 2 |
|
|
| 3 |
|
import jalview.api.AlignCalcManagerI2; |
| 4 |
|
import jalview.api.AlignCalcWorkerI; |
| 5 |
|
import jalview.bin.Cache; |
| 6 |
|
import jalview.bin.Console; |
| 7 |
|
import jalview.gui.AlignFrame; |
| 8 |
|
import jalview.gui.JvSwingUtils; |
| 9 |
|
import jalview.util.MessageManager; |
| 10 |
|
import jalview.ws.api.ServiceWithParameters; |
| 11 |
|
import jalview.ws.jws2.dm.AAConSettings; |
| 12 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
| 13 |
|
import jalview.ws.params.AutoCalcSetting; |
| 14 |
|
import jalview.ws.uimodel.AlignAnalysisUIText; |
| 15 |
|
|
| 16 |
|
import java.awt.event.ActionEvent; |
| 17 |
|
import java.awt.event.ActionListener; |
| 18 |
|
import java.util.List; |
| 19 |
|
|
| 20 |
|
import javax.swing.JCheckBoxMenuItem; |
| 21 |
|
import javax.swing.JMenu; |
| 22 |
|
import javax.swing.JMenuItem; |
| 23 |
|
import javax.swing.event.MenuEvent; |
| 24 |
|
import javax.swing.event.MenuListener; |
| 25 |
|
|
| |
|
| 25.6% |
Uncovered Elements: 93 (125) |
Complexity: 37 |
Complexity Density: 0.52 |
|
| 26 |
|
public class Jws2ClientFactory |
| 27 |
|
{ |
| |
|
| 75.6% |
Uncovered Elements: 10 (41) |
Complexity: 10 |
Complexity Density: 0.37 |
|
| 28 |
12315 |
static boolean registerAAConWSInstance(final JMenu wsmenu,... |
| 29 |
|
final ServiceWithParameters service, final AlignFrame alignFrame) |
| 30 |
|
{ |
| 31 |
12315 |
final AlignAnalysisUIText aaui = service.getAlignAnalysisUI(); |
| 32 |
|
|
| 33 |
|
|
| 34 |
12315 |
if (aaui == null) |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
11351 |
return false; |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
964 |
JCheckBoxMenuItem _aaConEnabled = null; |
| 43 |
2410 |
for (int i = 0; i < wsmenu.getItemCount(); i++) |
| 44 |
|
{ |
| 45 |
1446 |
JMenuItem item = wsmenu.getItem(i); |
| 46 |
1446 |
if (item instanceof JCheckBoxMenuItem |
| 47 |
|
&& item.getText().equals(aaui.getAAconToggle())) |
| 48 |
|
{ |
| 49 |
0 |
_aaConEnabled = (JCheckBoxMenuItem) item; |
| 50 |
|
} |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
{ |
| 55 |
964 |
AlignCalcManagerI2 mger = alignFrame.getViewport() |
| 56 |
|
.getCalcManager(); |
| 57 |
964 |
if (mger != null) |
| 58 |
|
{ |
| 59 |
948 |
List<AlignCalcWorkerI> aaconClient = mger |
| 60 |
|
.getWorkersOfClass(aaui.getClient()); |
| 61 |
948 |
if (aaconClient != null && aaconClient.size() > 0) |
| 62 |
|
{ |
| 63 |
0 |
SeqAnnotationServiceCalcWorker worker = (SeqAnnotationServiceCalcWorker) aaconClient |
| 64 |
|
.get(0); |
| 65 |
0 |
if (!worker.service.getHostURL().equals(service.getHostURL())) |
| 66 |
|
{ |
| 67 |
|
|
| 68 |
|
{ |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
{ |
| 72 |
0 |
removeCurrentAAConWorkerFor(aaui, alignFrame); |
| 73 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame, service); |
| 74 |
|
} |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
964 |
if (_aaConEnabled == null) |
| 84 |
|
{ |
| 85 |
964 |
final JCheckBoxMenuItem aaConEnabled = new JCheckBoxMenuItem( |
| 86 |
|
aaui.getAAconToggle()); |
| 87 |
|
|
| 88 |
964 |
aaConEnabled.setToolTipText( |
| 89 |
|
JvSwingUtils.wrapTooltip(true, aaui.getAAconToggleTooltip())); |
| 90 |
964 |
aaConEnabled.addActionListener(new ActionListener() |
| 91 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 92 |
0 |
@Override... |
| 93 |
|
public void actionPerformed(ActionEvent arg0) |
| 94 |
|
{ |
| 95 |
|
|
| 96 |
0 |
List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport() |
| 97 |
|
.getCalcManager() |
| 98 |
|
.getWorkersOfClass(SeqAnnotationServiceCalcWorker.class); |
| 99 |
0 |
if (aaconClient != null) |
| 100 |
|
{ |
| 101 |
0 |
for (AlignCalcWorkerI worker : aaconClient) |
| 102 |
|
{ |
| 103 |
0 |
if (((SeqAnnotationServiceCalcWorker) worker).getService() |
| 104 |
|
.getClass().equals(aaui.getClient())) |
| 105 |
|
{ |
| 106 |
0 |
removeCurrentAAConWorkerFor(aaui, alignFrame); |
| 107 |
0 |
return; |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
}); |
| 115 |
964 |
wsmenu.add(aaConEnabled); |
| 116 |
964 |
final JMenuItem modifyParams = new JMenuItem( |
| 117 |
|
aaui.getAAeditSettings()); |
| 118 |
964 |
modifyParams.setToolTipText(JvSwingUtils.wrapTooltip(true, |
| 119 |
|
aaui.getAAeditSettingsTooltip())); |
| 120 |
964 |
modifyParams.addActionListener(new ActionListener() |
| 121 |
|
{ |
| 122 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0 |
@Override... |
| 124 |
|
public void actionPerformed(ActionEvent arg0) |
| 125 |
|
{ |
| 126 |
0 |
showAAConAnnotationSettingsFor(aaui, alignFrame); |
| 127 |
|
} |
| 128 |
|
}); |
| 129 |
964 |
wsmenu.add(modifyParams); |
| 130 |
964 |
wsmenu.addMenuListener(new MenuListener() |
| 131 |
|
{ |
| 132 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 133 |
0 |
@Override... |
| 134 |
|
public void menuSelected(MenuEvent arg0) |
| 135 |
|
{ |
| 136 |
|
|
| 137 |
0 |
if (alignFrame.getViewport().getAlignment().isNucleotide() |
| 138 |
|
? aaui.isNa() |
| 139 |
|
: aaui.isPr()) |
| 140 |
|
{ |
| 141 |
0 |
aaConEnabled.setEnabled(true); |
| 142 |
0 |
modifyParams.setEnabled(true); |
| 143 |
|
} |
| 144 |
|
else |
| 145 |
|
{ |
| 146 |
0 |
aaConEnabled.setEnabled(false); |
| 147 |
0 |
modifyParams.setEnabled(false); |
| 148 |
0 |
return; |
| 149 |
|
} |
| 150 |
0 |
List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport() |
| 151 |
|
.getCalcManager() |
| 152 |
|
.getWorkersOfClass(SeqAnnotationServiceCalcWorker.class); |
| 153 |
|
|
| 154 |
0 |
boolean serviceEnabled = false; |
| 155 |
0 |
if (aaconClient != null) |
| 156 |
|
{ |
| 157 |
|
|
| 158 |
0 |
for (AlignCalcWorkerI _worker : aaconClient) |
| 159 |
|
{ |
| 160 |
0 |
SeqAnnotationServiceCalcWorker worker = (SeqAnnotationServiceCalcWorker) _worker; |
| 161 |
|
|
| 162 |
0 |
if (worker.hasService() |
| 163 |
|
&& aaui.getClient() |
| 164 |
|
.equals(worker.getService().getClass())) |
| 165 |
|
{ |
| 166 |
0 |
serviceEnabled = true; |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
0 |
aaConEnabled.setSelected(serviceEnabled); |
| 171 |
|
} |
| 172 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 173 |
0 |
@Override... |
| 174 |
|
public void menuDeselected(MenuEvent arg0) |
| 175 |
|
{ |
| 176 |
|
|
| 177 |
|
|
| 178 |
|
} |
| 179 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 180 |
0 |
@Override... |
| 181 |
|
public void menuCanceled(MenuEvent arg0) |
| 182 |
|
{ |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
} |
| 186 |
|
}); |
| 187 |
|
|
| 188 |
|
} |
| 189 |
964 |
return true; |
| 190 |
|
} |
| 191 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 192 |
0 |
private static void showAAConAnnotationSettingsFor(... |
| 193 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame) |
| 194 |
|
{ |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
0 |
AutoCalcSetting fave = alignFrame.getViewport() |
| 201 |
|
.getCalcIdSettingsFor(aaui.getCalcId()); |
| 202 |
0 |
if (fave == null) |
| 203 |
|
{ |
| 204 |
0 |
fave = createDefaultAAConSettings(aaui); |
| 205 |
|
} |
| 206 |
0 |
new SequenceAnnotationWSClient(fave, alignFrame, true); |
| 207 |
|
|
| 208 |
|
} |
| 209 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 210 |
0 |
private static void buildCurrentAAConWorkerFor(... |
| 211 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame) |
| 212 |
|
{ |
| 213 |
0 |
buildCurrentAAConWorkerFor(aaui, alignFrame, null); |
| 214 |
|
} |
| 215 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 216 |
0 |
private static void buildCurrentAAConWorkerFor(... |
| 217 |
|
final AlignAnalysisUIText aaui, AlignFrame alignFrame, |
| 218 |
|
ServiceWithParameters service) |
| 219 |
|
{ |
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
0 |
AutoCalcSetting fave = alignFrame.getViewport() |
| 225 |
|
.getCalcIdSettingsFor(aaui.getCalcId()); |
| 226 |
0 |
if (fave == null) |
| 227 |
|
{ |
| 228 |
0 |
fave = createDefaultAAConSettings(aaui, service); |
| 229 |
|
} |
| 230 |
|
else |
| 231 |
|
{ |
| 232 |
0 |
if (service != null && !fave.getService().getHostURL() |
| 233 |
|
.equals(service.getHostURL())) |
| 234 |
|
{ |
| 235 |
0 |
Console.debug("Changing AACon service to " + service.getHostURL() |
| 236 |
|
+ " from " + fave.getService().getHostURL()); |
| 237 |
0 |
fave.setService(service); |
| 238 |
|
} |
| 239 |
|
} |
| 240 |
0 |
new SequenceAnnotationWSClient(fave, alignFrame, false); |
| 241 |
|
} |
| 242 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 243 |
0 |
private static AutoCalcSetting createDefaultAAConSettings(... |
| 244 |
|
AlignAnalysisUIText aaui) |
| 245 |
|
{ |
| 246 |
0 |
return createDefaultAAConSettings(aaui, null); |
| 247 |
|
} |
| 248 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 249 |
0 |
private static AutoCalcSetting createDefaultAAConSettings(... |
| 250 |
|
AlignAnalysisUIText aaui, ServiceWithParameters service) |
| 251 |
|
{ |
| 252 |
0 |
if (service != null) |
| 253 |
|
{ |
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
|
| 264 |
|
{ |
| 265 |
|
|
| 266 |
|
|
| 267 |
0 |
if (!PreferredServiceRegistry.getRegistry().contains(service)) |
| 268 |
|
{ |
| 269 |
|
|
| 270 |
0 |
service = null; |
| 271 |
|
} |
| 272 |
|
} |
| 273 |
|
} |
| 274 |
0 |
if (service == null) |
| 275 |
|
{ |
| 276 |
|
|
| 277 |
0 |
service = PreferredServiceRegistry.getRegistry().getPreferredServiceFor(null, |
| 278 |
|
aaui.getServiceType()); |
| 279 |
|
} |
| 280 |
0 |
if (service == null) |
| 281 |
|
{ |
| 282 |
|
|
| 283 |
|
|
| 284 |
0 |
throw new Error( |
| 285 |
|
MessageManager.getString("error.no_aacon_service_found")); |
| 286 |
|
} |
| 287 |
0 |
return service instanceof Jws2Instance |
| 288 |
|
? new AAConSettings(true, service, null, null) |
| 289 |
|
: new AutoCalcSetting(service, null, null, true); |
| 290 |
|
} |
| 291 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 292 |
0 |
private static void removeCurrentAAConWorkerFor(AlignAnalysisUIText aaui,... |
| 293 |
|
AlignFrame alignFrame) |
| 294 |
|
{ |
| 295 |
0 |
alignFrame.getViewport().getCalcManager() |
| 296 |
|
.removeWorkersOfClass(aaui.getClient()); |
| 297 |
|
} |
| 298 |
|
} |