2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.jbgui.*;
\r
24 import java.awt.event.*;
\r
26 import javax.swing.*;
\r
33 * @version $Revision$
\r
35 public class WebserviceInfo extends GWebserviceInfo
\r
37 /** DOCUMENT ME!! */
\r
38 public static final int STATE_QUEUING = 0;
\r
40 /** DOCUMENT ME!! */
\r
41 public static final int STATE_RUNNING = 1;
\r
43 /** DOCUMENT ME!! */
\r
44 public static final int STATE_STOPPED_OK = 2;
\r
46 /** DOCUMENT ME!! */
\r
47 public static final int STATE_CANCELLED_OK = 3;
\r
49 /** DOCUMENT ME!! */
\r
50 public static final int STATE_STOPPED_ERROR = 4;
\r
52 /** DOCUMENT ME!! */
\r
53 public static final int STATE_STOPPED_SERVERERROR = 5;
\r
54 int currentStatus = STATE_QUEUING;
\r
58 jalview.ws.WSClientI thisService;
\r
59 boolean serviceIsCancellable;
\r
62 * Creates a new WebserviceInfo object.
\r
64 * @param title DOCUMENT ME!
\r
65 * @param info DOCUMENT ME!
\r
67 public WebserviceInfo(String title, String info)
\r
69 init(title, info, 520, 500);
\r
73 * Creates a new WebserviceInfo object.
\r
75 * @param title DOCUMENT ME!
\r
76 * @param info DOCUMENT ME!
\r
77 * @param width DOCUMENT ME!
\r
78 * @param height DOCUMENT ME!
\r
80 public WebserviceInfo(String title, String info, int width, int height)
\r
82 init(title, info, width, height);
\r
88 * @return DOCUMENT ME!
\r
90 public jalview.ws.WSClientI getthisService()
\r
98 * @param newservice DOCUMENT ME!
\r
100 public void setthisService(jalview.ws.WSClientI newservice)
\r
102 thisService = newservice;
\r
103 serviceIsCancellable = newservice.isCancellable();
\r
109 * @param title DOCUMENT ME!
\r
110 * @param info DOCUMENT ME!
\r
111 * @param width DOCUMENT ME!
\r
112 * @param height DOCUMENT ME!
\r
114 void init(String title, String info, int width, int height)
\r
116 JInternalFrame frame = new JInternalFrame();
\r
117 frame.setContentPane(this);
\r
118 Desktop.addInternalFrame(frame, title, width, height);
\r
120 this.title = title;
\r
123 java.net.URL url = getClass().getResource("/images/logo.gif");
\r
124 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
\r
126 MediaTracker mt = new MediaTracker(this);
\r
127 mt.addImage(image, 0);
\r
133 catch (Exception ex)
\r
137 AnimatedPanel ap = new AnimatedPanel();
\r
138 titlePanel.add(ap, BorderLayout.CENTER);
\r
140 Thread thread = new Thread(ap);
\r
147 * @param status DOCUMENT ME!
\r
149 public void setStatus(int status)
\r
151 currentStatus = status;
\r
157 * @return DOCUMENT ME!
\r
159 public String getInfoText()
\r
161 return infoText.getText();
\r
167 * @param text DOCUMENT ME!
\r
169 public void setInfoText(String text)
\r
171 infoText.setText(text);
\r
177 * @param text DOCUMENT ME!
\r
179 public void appendInfoText(String text)
\r
181 infoText.append(text);
\r
187 * @return DOCUMENT ME!
\r
189 public String getProgressText()
\r
191 return progressText.getText();
\r
197 * @param text DOCUMENT ME!
\r
199 public void setProgressText(String text)
\r
201 progressText.setText(text);
\r
207 * @param text DOCUMENT ME!
\r
209 public void appendProgressText(String text)
\r
211 progressText.append(text);
\r
217 * @param e DOCUMENT ME!
\r
219 protected void cancel_actionPerformed(ActionEvent e)
\r
221 if (!serviceIsCancellable)
\r
223 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
224 "This job cannot be cancelled.", "Cancel job",
\r
225 JOptionPane.WARNING_MESSAGE);
\r
229 thisService.cancelJob();
\r
233 class AnimatedPanel extends JPanel implements Runnable
\r
235 long startTime = 0;
\r
239 startTime = System.currentTimeMillis();
\r
241 while (currentStatus < STATE_STOPPED_OK)
\r
247 int units = (int) ((System.currentTimeMillis() - startTime) / 10f);
\r
250 startTime = System.currentTimeMillis();
\r
253 catch (Exception ex)
\r
259 cancel.setEnabled(false);
\r
262 synchronized public void paintComponent(Graphics g1)
\r
264 Graphics2D g = (Graphics2D) g1;
\r
265 g.setColor(Color.white);
\r
266 g.fillRect(0, 0, getWidth(), getHeight());
\r
270 g.rotate(Math.toRadians(angle), 28, 28);
\r
271 g.drawImage(image, 10, 10, this);
\r
272 g.rotate(-Math.toRadians(angle), 28, 28);
\r
275 g.setFont(new Font("Arial", Font.BOLD, 12));
\r
276 g.setColor(Color.black);
\r
278 switch (currentStatus)
\r
280 case STATE_QUEUING:
\r
281 g.drawString(title.concat(" - queuing"), 60, 30);
\r
285 case STATE_RUNNING:
\r
286 g.drawString(title.concat(" - running"), 60, 30);
\r
290 case STATE_STOPPED_OK:
\r
291 g.drawString(title.concat(" - complete"), 60, 30);
\r
295 case STATE_CANCELLED_OK:
\r
296 g.drawString(title.concat(" - job cancelled!"), 60, 30);
\r
300 case STATE_STOPPED_ERROR:
\r
301 g.drawString(title.concat(" - job error!"), 60, 30);
\r
305 case STATE_STOPPED_SERVERERROR:
\r
306 g.drawString(title.concat(" - Server Error! (try later)"), 60,
\r