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
22 import java.awt.event.*;
\r
23 import javax.swing.*;
\r
25 import jalview.jbgui.*;
\r
27 public class WebserviceInfo
\r
28 extends GWebserviceInfo
\r
30 public static final int STATE_QUEUING = 0;
\r
31 public static final int STATE_RUNNING = 1;
\r
32 public static final int STATE_STOPPED_OK = 2;
\r
33 public static final int STATE_CANCELLED_OK = 3;
\r
34 public static final int STATE_STOPPED_ERROR = 4;
\r
35 public static final int STATE_STOPPED_SERVERERROR = 5;
\r
36 int currentStatus = STATE_QUEUING;
\r
40 jalview.ws.WSClientI thisService;
\r
41 boolean serviceIsCancellable;
\r
43 public WebserviceInfo(String title, String info)
\r
45 init(title, info, 520, 500);
\r
48 public WebserviceInfo(String title, String info, int width, int height)
\r
50 init(title, info, width, height);
\r
53 public jalview.ws.WSClientI getthisService()
\r
58 public void setthisService(jalview.ws.WSClientI newservice)
\r
60 thisService = newservice;
\r
61 serviceIsCancellable = newservice.isCancellable();
\r
64 void init(String title, String info, int width, int height)
\r
66 JInternalFrame frame = new JInternalFrame();
\r
67 frame.setContentPane(this);
\r
68 Desktop.addInternalFrame(frame, title, width, height);
\r
73 java.net.URL url = getClass().getResource("/images/logo.gif");
\r
74 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
\r
76 MediaTracker mt = new MediaTracker(this);
\r
77 mt.addImage(image, 0);
\r
83 catch (Exception ex)
\r
87 AnimatedPanel ap = new AnimatedPanel();
\r
88 titlePanel.add(ap, BorderLayout.CENTER);
\r
90 Thread thread = new Thread(ap);
\r
94 public void setStatus(int status)
\r
96 currentStatus = status;
\r
99 public String getInfoText()
\r
101 return infoText.getText();
\r
104 public void setInfoText(String text)
\r
106 infoText.setText(text);
\r
109 public void appendInfoText(String text)
\r
111 infoText.append(text);
\r
114 public String getProgressText()
\r
116 return progressText.getText();
\r
119 public void setProgressText(String text)
\r
121 progressText.setText(text);
\r
124 public void appendProgressText(String text)
\r
126 progressText.append(text);
\r
129 protected void cancel_actionPerformed(ActionEvent e)
\r
131 if (!serviceIsCancellable)
\r
133 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
134 "This job cannot be cancelled.",
\r
136 JOptionPane.WARNING_MESSAGE);
\r
140 thisService.cancelJob();
\r
144 class AnimatedPanel
\r
145 extends JPanel implements Runnable
\r
147 long startTime = 0;
\r
151 startTime = System.currentTimeMillis();
\r
153 while (currentStatus < STATE_STOPPED_OK)
\r
160 int units = (int) ( (System.currentTimeMillis() - startTime) / 10f);
\r
163 startTime = System.currentTimeMillis();
\r
166 catch (Exception ex)
\r
172 cancel.setEnabled(false);
\r
175 synchronized public void paintComponent(Graphics g1)
\r
177 Graphics2D g = (Graphics2D) g1;
\r
178 g.setColor(Color.white);
\r
179 g.fillRect(0, 0, getWidth(), getHeight());
\r
183 g.rotate(Math.toRadians(angle), 28, 28);
\r
184 g.drawImage(image, 10, 10, this);
\r
185 g.rotate( -Math.toRadians(angle), 28, 28);
\r
188 g.setFont(new Font("Arial", Font.BOLD, 12));
\r
189 g.setColor(Color.black);
\r
191 switch (currentStatus)
\r
193 case STATE_QUEUING:
\r
194 g.drawString(title.concat(" - queuing"), 60, 30);
\r
198 case STATE_RUNNING:
\r
199 g.drawString(title.concat(" - running"), 60, 30);
\r
203 case STATE_STOPPED_OK:
\r
204 g.drawString(title.concat(" - complete"), 60, 30);
\r
208 case STATE_CANCELLED_OK:
\r
209 g.drawString(title.concat(" - job cancelled!"), 60, 30);
\r
213 case STATE_STOPPED_ERROR:
\r
214 g.drawString(title.concat(" - job error!"), 60, 30);
\r
218 case STATE_STOPPED_SERVERERROR:
\r
219 g.drawString(title.concat(" - Server Error! (try later)"), 60,
\r