" - + JvSwingUtils.wrapTooltip(AAconsToggleTooltip + "
") + aaConEnabled.setToolTipText("" + + JvSwingUtils.wrapTooltip(AAconToggleTooltip + "
") + ""); - aaConsEnabled.addActionListener(new ActionListener() + aaConEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - // aaConsEnabled.setSelected(!aaConsEnabled.isSelected()); - List" + JvSwingUtils.wrapTooltip(AAeditSettingsTooltip + "
") @@ -306,72 +358,109 @@ public class SequenceAnnotationWSClient extends Jws2Client @Override public void actionPerformed(ActionEvent arg0) { - showAAConsAnnotationSettingsFor(alignFrame); + showAAConAnnotationSettingsFor(alignFrame); } }); wsmenu.add(modifyParams); } - } - private static void showAAConsAnnotationSettingsFor(AlignFrame alignFrame) + private static void showAAConAnnotationSettingsFor(AlignFrame alignFrame) { /* - * preferred settings - * Whether AACons is automatically recalculated - * Which AACons server to use - * What parameters to use + * preferred settings Whether AACon is automatically recalculated Which + * AACon server to use What parameters to use */ // could actually do a class search for this too - AAConsSettings fave= (AAConsSettings) alignFrame.getViewport().getCalcIdSettingsFor(AAConsCalcId); - if (fave==null) + AAConSettings fave = (AAConSettings) alignFrame.getViewport() + .getCalcIdSettingsFor(AAConCalcId); + if (fave == null) { - fave = createDefaultAAConsSettings(); + fave = createDefaultAAConSettings(); } new SequenceAnnotationWSClient(fave, alignFrame, true); } - private static void buildCurrentAAConsWorkerFor(AlignFrame alignFrame) + + private static void buildCurrentAAConWorkerFor(AlignFrame alignFrame) + { + buildCurrentAAConWorkerFor(alignFrame, null); + } + + private static void buildCurrentAAConWorkerFor(AlignFrame alignFrame, + Jws2Instance service) { /* - * preferred settings - * Whether AACons is automatically recalculated - * Which AACons server to use - * What parameters to use + * preferred settings Whether AACon is automatically recalculated Which + * AACon server to use What parameters to use */ - AAConsSettings fave= (AAConsSettings) alignFrame.getViewport().getCalcIdSettingsFor(AAConsCalcId); - if (fave==null) + AAConSettings fave = (AAConSettings) alignFrame.getViewport() + .getCalcIdSettingsFor(AAConCalcId); + if (fave == null) { - fave = createDefaultAAConsSettings(); + fave = createDefaultAAConSettings(service); + } + else + { + if (service != null + && !fave.getService().hosturl.equals(service.hosturl)) + { + Cache.log.debug("Changing AACon service to " + service.hosturl + + " from " + fave.getService().hosturl); + fave.setService(service); + } } new SequenceAnnotationWSClient(fave, alignFrame, false); } - private static AAConsSettings createDefaultAAConsSettings() + private static AAConSettings createDefaultAAConSettings() { - Jws2Instance service=null; - // set sensible defaults - for (Jws2Instance sv: Jws2Discoverer.getDiscoverer().getServices()) { - if (sv.serviceType.toString().equals(compbio.ws.client.Services.AAConWS.toString())) + return createDefaultAAConSettings(null); + } + + private static AAConSettings createDefaultAAConSettings( + Jws2Instance service) + { + if (service != null) + { + if (!service.serviceType.toString().equals( + compbio.ws.client.Services.AAConWS.toString())) + { + Cache.log + .warn("Ignoring invalid preferred service for AACon calculations (service type was " + + service.serviceType + ")"); + service = null; + } + else { - service = sv; - break; + // check service is actually in the list of currently avaialable + // services + if (!Jws2Discoverer.getDiscoverer().getServices().contains(service)) + { + // it isn't .. + service = null; + } } } - if (service==null) + if (service == null) { - // TODO raise dialog box explaining error, and/or open the JABA preferences menu. - throw new Error("No AACons service found."); + // get the default service for AACon + service = Jws2Discoverer.getDiscoverer().getPreferredServiceFor(null, + compbio.ws.client.Services.AAConWS.toString()); } - return new AAConsSettings(true, service, null, null); + if (service == null) + { + // TODO raise dialog box explaining error, and/or open the JABA + // preferences menu. + throw new Error("No AACon service found."); + } + return new AAConSettings(true, service, null, null); } - private static void removeCurrentAAConsWorkerFor(AlignFrame alignFrame) + private static void removeCurrentAAConWorkerFor(AlignFrame alignFrame) { alignFrame.getViewport().getCalcManager() - .removeRegisteredWorkersOfClass(AAConsClient.class); - // AAConsClient.removeAAConsAnnotation(alignFrame.alignPanel); - + .removeRegisteredWorkersOfClass(AAConClient.class); } }