2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 import javax.swing.JMenu;
26 public abstract class WSClient
29 * WSClient holds the basic attributes that are displayed to the user for all
30 * jalview web service clients
33 * displayed name for this web service
35 protected String WebServiceName;
38 * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment
39 * from Cut and Paste input')
41 protected String WebServiceJobTitle;
44 * String giving additional information such as method citations for this
47 protected String WebServiceReference;
52 protected String WsURL;
55 * Web service information used to initialise the WSClient attributes
57 protected WebserviceInfo wsInfo;
60 * total number of jobs managed by this web service client instance.
65 * TODO: this is really service metadata, and should be moved elsewhere.
66 * mappings between abstract interface names and menu entries
68 protected java.util.Hashtable ServiceActions;
70 ServiceActions = new java.util.Hashtable();
71 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
72 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
80 * initialise WSClient service information attributes from the service handle
83 * @return the service instance information GUI for this client and job.
85 protected WebserviceInfo setWebService(ServiceHandle sh)
87 return setWebService(sh, false);
91 * original service handle that this client was derived from
93 ServiceHandle serviceHandle = null;
96 * initialise WSClient service information attributes from the service handle
100 * true implies no GUI objects will be created.
101 * @return the service instance information GUI for this client and job.
103 protected WebserviceInfo setWebService(ServiceHandle sh, boolean headless)
105 WebServiceName = sh.getName();
106 if (ServiceActions.containsKey(sh.getAbstractName()))
108 WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification
110 // add this for short names. +(String)
111 // ServiceActions.get(sh.getAbstractName());
115 WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName();
118 WebServiceReference = sh.getDescription();
119 WsURL = sh.getEndpointURL();
120 WebserviceInfo wsInfo = null;
123 wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference);
129 * convenience method to pass the serviceHandle reference that instantiated
130 * this service on to the menu entry constructor
133 * the menu to which any menu entries/sub menus are to be
136 * the alignFrame instance that provides input data for the
139 public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
141 if (serviceHandle == null)
144 "IMPLEMENTATION ERROR: cannot attach WS Menu Entry without service handle reference!");
146 attachWSMenuEntry(wsmenu, serviceHandle, alignFrame);
150 * method implemented by each WSClient implementation that creates menu
151 * entries that enact their service using data from alignFrame.
154 * where new menu entries (and submenus) are to be attached
155 * @param serviceHandle
156 * the serviceHandle document for the service that entries are
160 public abstract void attachWSMenuEntry(JMenu wsmenu,
161 final ServiceHandle serviceHandle, final AlignFrame alignFrame);