2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 import javax.swing.JMenu;
25 public abstract class WSClient implements WSMenuEntryProviderI
28 * WSClient holds the basic attributes that are displayed to the user for all
29 * jalview web service clients
32 * displayed name for this web service
34 protected String WebServiceName;
37 * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment
38 * from Cut and Paste input')
40 protected String WebServiceJobTitle;
43 * String giving additional information such as method citations for this
46 protected String WebServiceReference;
51 protected String WsURL;
54 * Web service information used to initialise the WSClient attributes
56 protected WebserviceInfo wsInfo;
59 * total number of jobs managed by this web service client instance.
64 * TODO: this is really service metadata, and should be moved elsewhere.
65 * mappings between abstract interface names and menu entries
67 protected java.util.Hashtable ServiceActions;
69 ServiceActions = new java.util.Hashtable();
70 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
71 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
79 * initialise WSClient service information attributes from the service handle
82 * @return the service instance information GUI for this client and job.
84 protected WebserviceInfo setWebService(ServiceHandle sh)
86 return setWebService(sh, false);
90 * original service handle that this client was derived from
92 ServiceHandle serviceHandle = null;
95 * initialise WSClient service information attributes from the service handle
99 * true implies no GUI objects will be created.
100 * @return the service instance information GUI for this client and job.
102 protected WebserviceInfo setWebService(ServiceHandle sh, boolean headless)
104 WebServiceName = sh.getName();
105 if (ServiceActions.containsKey(sh.getAbstractName()))
107 WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification
109 // add this for short names. +(String)
110 // ServiceActions.get(sh.getAbstractName());
114 WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName();
117 WebServiceReference = sh.getDescription();
118 WsURL = sh.getEndpointURL();
119 WebserviceInfo wsInfo = null;
122 wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference);
128 * convenience method to pass the serviceHandle reference that instantiated
129 * this service on to the menu entry constructor
132 * the menu to which any menu entries/sub menus are to be attached
134 * the alignFrame instance that provides input data for the service
136 public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
138 if (serviceHandle == null)
141 "IMPLEMENTATION ERROR: cannot attach WS Menu Entry without service handle reference!");
143 attachWSMenuEntry(wsmenu, serviceHandle, alignFrame);
147 * method implemented by each WSClient implementation that creates menu
148 * entries that enact their service using data from alignFrame.
151 * where new menu entries (and submenus) are to be attached
152 * @param serviceHandle
153 * the serviceHandle document for the service that entries are
157 public abstract void attachWSMenuEntry(JMenu wsmenu,
158 final ServiceHandle serviceHandle, final AlignFrame alignFrame);