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
20 package jalview.gui;
\r
23 import java.awt.event.*;
\r
24 import javax.swing.*;
\r
25 import jalview.jbgui.GWebserviceInfo;
\r
27 public class WebserviceInfo 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
41 jalview.ws.WSClientI thisService;
\r
42 boolean serviceIsCancellable;
\r
43 public jalview.ws.WSClientI getthisService() {
\r
46 public void setthisService(jalview.ws.WSClientI newservice) {
\r
47 thisService = newservice;
\r
48 serviceIsCancellable = newservice.isCancellable();
\r
51 public WebserviceInfo(String title, String info)
\r
53 init(title, info, 520, 500);
\r
56 public WebserviceInfo(String title, String info, int width, int height)
\r
58 init(title, info, width, height);
\r
61 void init(String title, String info, int width, int height)
\r
63 JInternalFrame frame = new JInternalFrame();
\r
64 frame.setContentPane(this);
\r
65 Desktop.addInternalFrame(frame, title, width, height);
\r
69 java.net.URL url = getClass().getResource("/images/logo.gif");
\r
70 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
\r
71 MediaTracker mt = new MediaTracker(this);
\r
72 mt.addImage(image, 0);
\r
77 catch (Exception ex)
\r
81 AnimatedPanel ap = new AnimatedPanel();
\r
82 titlePanel.add(ap, BorderLayout.CENTER);
\r
83 Thread thread = new Thread(ap);
\r
87 public void setStatus(int status)
\r
89 currentStatus = status;
\r
92 public String getInfoText()
\r
93 { return infoText.getText(); }
\r
95 public void setInfoText(String text)
\r
96 { infoText.setText(text); }
\r
98 public void appendInfoText(String text)
\r
99 { infoText.append(text); }
\r
101 public String getProgressText()
\r
102 { return progressText.getText(); }
\r
104 public void setProgressText(String text)
\r
105 { progressText.setText(text); }
\r
107 public void appendProgressText(String text)
\r
108 { progressText.append(text); }
\r
110 protected void cancel_actionPerformed(ActionEvent e)
\r
112 if (!serviceIsCancellable)
\r
113 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
114 "This job cannot be cancelled." ,
\r
116 ,JOptionPane.WARNING_MESSAGE);
\r
118 thisService.cancelJob();
\r
122 class AnimatedPanel extends JPanel implements Runnable
\r
127 startTime = System.currentTimeMillis();
\r
128 while(currentStatus<STATE_STOPPED_OK)
\r
133 int units = (int)((System.currentTimeMillis()-startTime)/10f);
\r
136 startTime = System.currentTimeMillis();
\r
140 catch (Exception ex)
\r
143 cancel.setEnabled(false);
\r
147 synchronized public void paintComponent(Graphics g1)
\r
149 Graphics2D g = (Graphics2D) g1;
\r
150 g.setColor(Color.white);
\r
151 g.fillRect(0, 0, getWidth(), getHeight());
\r
154 g.rotate(Math.toRadians(angle), 28, 28);
\r
155 g.drawImage(image, 10, 10, this);
\r
156 g.rotate( -Math.toRadians(angle), 28, 28);
\r
158 g.setFont(new Font("Arial", Font.BOLD, 12));
\r
159 g.setColor(Color.black);
\r
160 switch(currentStatus)
\r
162 case STATE_QUEUING:
\r
163 g.drawString(title.concat(" - queuing"), 60, 30);
\r
165 case STATE_RUNNING:
\r
166 g.drawString(title.concat(" - running"), 60, 30);
\r
168 case STATE_STOPPED_OK:
\r
169 g.drawString(title.concat(" - complete"), 60, 30);
\r
172 case STATE_CANCELLED_OK:
\r
173 g.drawString(title.concat(" - job cancelled!"), 60, 30);
\r
176 case STATE_STOPPED_ERROR:
\r
177 g.drawString(title.concat(" - job error!"), 60, 30);
\r
179 case STATE_STOPPED_SERVERERROR:
\r
180 g.drawString(title.concat(" - Server Error! (try later)"), 60, 30);
\r