2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 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
30 * for all jalview web service clients
33 * displayed name for this web service
35 protected String WebServiceName;
37 * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment from Cut and Paste input')
39 protected String WebServiceJobTitle;
41 * String giving additional information such as method citations for this service
43 protected String WebServiceReference;
47 protected String WsURL;
49 * Web service information used to initialise the WSClient attributes
51 protected WebserviceInfo wsInfo;
53 * total number of jobs managed by this web service client instance.
57 * TODO: this is really service metadata, and should be moved elsewhere.
58 * mappings between abstract interface names and menu entries
60 protected java.util.Hashtable ServiceActions;
62 ServiceActions = new java.util.Hashtable();
63 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
64 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
70 * initialise WSClient service information attributes from the service handle
72 * @return the service instance information GUI for this client and job.
74 protected WebserviceInfo setWebService(ServiceHandle sh)
76 return setWebService(sh, false);
79 * original service handle that this client was derived from
81 ServiceHandle serviceHandle=null;
83 * initialise WSClient service information attributes from the service handle
85 * @param headless true implies no GUI objects will be created.
86 * @return the service instance information GUI for this client and job.
88 protected WebserviceInfo setWebService(ServiceHandle sh, boolean headless)
90 WebServiceName = sh.getName();
91 if (ServiceActions.containsKey(sh.getAbstractName()))
93 WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification properly
94 // add this for short names. +(String) ServiceActions.get(sh.getAbstractName());
98 WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName();
101 WebServiceReference = sh.getDescription();
102 WsURL = sh.getEndpointURL();
103 WebserviceInfo wsInfo = null;
106 wsInfo = new WebserviceInfo(WebServiceJobTitle,
107 WebServiceReference);
112 * convenience method to pass the serviceHandle reference that instantiated this
113 * service on to the menu entry constructor
114 * @param wsmenu the menu to which any menu entries/sub menus are to be attached
115 * @param alignFrame the alignFrame instance that provides input data for the service
117 public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
119 if (serviceHandle==null)
121 throw new Error("IMPLEMENTATION ERROR: cannot attach WS Menu Entry without service handle reference!");
123 attachWSMenuEntry(wsmenu, serviceHandle, alignFrame);
126 * method implemented by each WSClient implementation that creates menu entries that enact their service
127 * using data from alignFrame.
128 * @param wsmenu where new menu entries (and submenus) are to be attached
129 * @param serviceHandle the serviceHandle document for the service that entries are created for
132 public abstract void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle serviceHandle, final AlignFrame alignFrame);