X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FWSClient.java;h=33aea909e67225d72871fece3875091ba7913984;hb=61632514caf99d7897843f8bb3e4378aa715d040;hp=1490da17544281d605510eb2bc5cc4acc444dcd4;hpb=d423f22792e47dbc800ae220a58677f988971d06;p=jalview.git diff --git a/src/jalview/ws/WSClient.java b/src/jalview/ws/WSClient.java index 1490da1..33aea90 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -1,28 +1,39 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.ws; -import javax.swing.JMenu; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.WebserviceInfo; +import jalview.gui.WsJobParameters; +import jalview.util.MessageManager; +import jalview.ws.api.ServiceWithParameters; +import jalview.ws.api.UIinfo; +import jalview.ws.params.ArgumentI; +import jalview.ws.params.ParamDatastoreI; +import jalview.ws.params.WsParamSetI; -import ext.vamsas.*; -import jalview.gui.*; +import java.util.List; -public abstract class WSClient implements WSMenuEntryProviderI +public abstract class WSClient // implements WSMenuEntryProviderI { /** * WSClient holds the basic attributes that are displayed to the user for all @@ -56,6 +67,11 @@ public abstract class WSClient implements WSMenuEntryProviderI protected WebserviceInfo wsInfo; /** + * the root object for the service client + */ + protected UIinfo serviceHandle; + + /** * total number of jobs managed by this web service client instance. */ int jobsRunning = 0; @@ -65,95 +81,119 @@ public abstract class WSClient implements WSMenuEntryProviderI * mappings between abstract interface names and menu entries */ protected java.util.Hashtable ServiceActions; + + /** + * alignFrame associated with this client + */ + protected AlignFrame alignFrame; { ServiceActions = new java.util.Hashtable(); ServiceActions.put("MsaWS", "Multiple Sequence Alignment"); ServiceActions.put("SecStrPred", "Secondary Structure Prediction"); }; - public WSClient() - { - } - /** - * initialise WSClient service information attributes from the service handle - * - * @param sh - * @return the service instance information GUI for this client and job. + * The preset for the job executed by this client (may be null) */ - protected WebserviceInfo setWebService(ServiceHandle sh) - { - return setWebService(sh, false); - } + protected WsParamSetI preset; /** - * original service handle that this client was derived from + * The parameters for the job executed by this client (may be null) */ - ServiceHandle serviceHandle = null; + protected List paramset; + + public WSClient() + { + } /** - * initialise WSClient service information attributes from the service handle + * base constructor for a web service with parameters. Extending classes + * should implement this constructor with additional logic to verify that + * preset and arguments are compatible with the service being configured. * - * @param sh - * @param headless - * true implies no GUI objects will be created. - * @return the service instance information GUI for this client and job. + * @param _alignFrame + * @param preset + * @param arguments */ - protected WebserviceInfo setWebService(ServiceHandle sh, boolean headless) + public WSClient(AlignFrame _alignFrame, WsParamSetI preset, + List arguments) { - WebServiceName = sh.getName(); - if (ServiceActions.containsKey(sh.getAbstractName())) - { - WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification - // properly - // add this for short names. +(String) - // ServiceActions.get(sh.getAbstractName()); - } - else - { - WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName(); + alignFrame = _alignFrame; + this.preset = preset; + this.paramset = arguments; + } - } - WebServiceReference = sh.getDescription(); - WsURL = sh.getEndpointURL(); - WebserviceInfo wsInfo = null; - if (!headless) + protected WebserviceInfo setWebService(UIinfo serv, boolean b) + { + WebServiceName = serv.getName(); + WebServiceJobTitle = serv.getActionText(); + WsURL = serv.getHostURL(); + if (!b) { - wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference); + return new WebserviceInfo(WebServiceJobTitle, + WebServiceJobTitle + " using service hosted at " + + WsURL + "\n" + + (serv.getDescription() != null + ? serv.getDescription() + : ""), + false); } - return wsInfo; + return null; } /** - * convenience method to pass the serviceHandle reference that instantiated - * this service on to the menu entry constructor + * called to open a parameter editing dialog for parameterised services * - * @param wsmenu - * the menu to which any menu entries/sub menus are to be attached - * @param alignFrame - * the alignFrame instance that provides input data for the service + * @param sh + * @param editParams + * @return */ - public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame) + protected boolean processParams(ServiceWithParameters sh, + boolean editParams) + { + return processParams(sh, editParams, false); + } + + protected boolean processParams(ServiceWithParameters sh, + boolean editParams, + boolean adjustingExisting) { - if (serviceHandle == null) + + if (editParams) { - throw new Error( - "IMPLEMENTATION ERROR: cannot attach WS Menu Entry without service handle reference!"); + // always do this + sh.initParamStore(Desktop.getUserParameterStore()); + + WsJobParameters jobParams = (preset == null && paramset != null + && paramset.size() > 0) + ? new WsJobParameters((ParamDatastoreI) null, sh, + (WsParamSetI) null, paramset) + : new WsJobParameters((ParamDatastoreI) null, sh, + preset, (List) null); + if (adjustingExisting) + { + jobParams.setName(MessageManager + .getString("label.adjusting_parameters_for_calculation")); + } + if (!jobParams.showRunDialog()) + { + return false; // dialog cancelled + } + + WsParamSetI prset = jobParams.getPreset(); + if (prset == null) + { + paramset = jobParams.isServiceDefaults() ? null + : jobParams.getJobParams(); + this.preset = null; + } + else + { + this.preset = prset; // ((JabaPreset) prset).p; + paramset = null; // no user supplied parameters. + } } - attachWSMenuEntry(wsmenu, serviceHandle, alignFrame); + return true; } - /** - * method implemented by each WSClient implementation that creates menu - * entries that enact their service using data from alignFrame. - * - * @param wsmenu - * where new menu entries (and submenus) are to be attached - * @param serviceHandle - * the serviceHandle document for the service that entries are - * created for - * @param alignFrame - */ - public abstract void attachWSMenuEntry(JMenu wsmenu, - final ServiceHandle serviceHandle, final AlignFrame alignFrame); }