/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
-\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package jalview.gui;\r
\r
import java.awt.*;\r
import java.awt.event.*;\r
import javax.swing.*;\r
-import jalview.jbgui.GWebserviceInfo;\r
\r
-public class WebserviceInfo extends GWebserviceInfo\r
-{\r
+import jalview.jbgui.*;\r
\r
+public class WebserviceInfo\r
+ extends GWebserviceInfo\r
+{\r
public static final int STATE_QUEUING = 0;\r
public static final int STATE_RUNNING = 1;\r
public static final int STATE_STOPPED_OK = 2;\r
int currentStatus = STATE_QUEUING;\r
Image image;\r
int angle = 0;\r
-\r
- String title="";\r
+ String title = "";\r
jalview.ws.WSClientI thisService;\r
boolean serviceIsCancellable;\r
- public jalview.ws.WSClientI getthisService() {\r
- return thisService;\r
- }\r
- public void setthisService(jalview.ws.WSClientI newservice) {\r
- thisService = newservice;\r
- serviceIsCancellable = newservice.isCancellable();\r
- }\r
\r
public WebserviceInfo(String title, String info)\r
{\r
init(title, info, width, height);\r
}\r
\r
+ public jalview.ws.WSClientI getthisService()\r
+ {\r
+ return thisService;\r
+ }\r
+\r
+ public void setthisService(jalview.ws.WSClientI newservice)\r
+ {\r
+ thisService = newservice;\r
+ serviceIsCancellable = newservice.isCancellable();\r
+ }\r
+\r
void init(String title, String info, int width, int height)\r
{\r
JInternalFrame frame = new JInternalFrame();\r
\r
this.title = title;\r
setInfoText(info);\r
+\r
java.net.URL url = getClass().getResource("/images/logo.gif");\r
image = java.awt.Toolkit.getDefaultToolkit().createImage(url);\r
+\r
MediaTracker mt = new MediaTracker(this);\r
mt.addImage(image, 0);\r
+\r
try\r
{\r
mt.waitForID(0);\r
}\r
catch (Exception ex)\r
- {}\r
-\r
+ {\r
+ }\r
\r
AnimatedPanel ap = new AnimatedPanel();\r
titlePanel.add(ap, BorderLayout.CENTER);\r
+\r
Thread thread = new Thread(ap);\r
thread.start();\r
}\r
}\r
\r
public String getInfoText()\r
- { return infoText.getText(); }\r
+ {\r
+ return infoText.getText();\r
+ }\r
\r
public void setInfoText(String text)\r
- { infoText.setText(text); }\r
+ {\r
+ infoText.setText(text);\r
+ }\r
\r
public void appendInfoText(String text)\r
- { infoText.append(text); }\r
+ {\r
+ infoText.append(text);\r
+ }\r
\r
public String getProgressText()\r
- { return progressText.getText(); }\r
+ {\r
+ return progressText.getText();\r
+ }\r
\r
public void setProgressText(String text)\r
- { progressText.setText(text); }\r
+ {\r
+ progressText.setText(text);\r
+ }\r
\r
public void appendProgressText(String text)\r
- { progressText.append(text); }\r
+ {\r
+ progressText.append(text);\r
+ }\r
\r
protected void cancel_actionPerformed(ActionEvent e)\r
{\r
if (!serviceIsCancellable)\r
+ {\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "This job cannot be cancelled." ,\r
- "Cancel job"\r
- ,JOptionPane.WARNING_MESSAGE);\r
+ "This job cannot be cancelled.",\r
+ "Cancel job",\r
+ JOptionPane.WARNING_MESSAGE);\r
+ }\r
else\r
+ {\r
thisService.cancelJob();\r
+ }\r
}\r
\r
-\r
- class AnimatedPanel extends JPanel implements Runnable\r
+ class AnimatedPanel\r
+ extends JPanel implements Runnable\r
{\r
- long startTime=0;\r
+ long startTime = 0;\r
+\r
public void run()\r
{\r
startTime = System.currentTimeMillis();\r
- while(currentStatus<STATE_STOPPED_OK)\r
- try\r
- {\r
- Thread.sleep(50);\r
\r
- int units = (int)((System.currentTimeMillis()-startTime)/10f);\r
- angle += units;\r
- angle %= 360;\r
- startTime = System.currentTimeMillis();\r
- repaint();\r
+ while (currentStatus < STATE_STOPPED_OK)\r
+ {\r
\r
+ try\r
+ {\r
+ Thread.sleep(50);\r
+\r
+ int units = (int) ( (System.currentTimeMillis() - startTime) / 10f);\r
+ angle += units;\r
+ angle %= 360;\r
+ startTime = System.currentTimeMillis();\r
+ repaint();\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ }\r
}\r
- catch (Exception ex)\r
- {}\r
+\r
angle = 0;\r
cancel.setEnabled(false);\r
-\r
}\r
\r
- synchronized public void paintComponent(Graphics g1)\r
+ synchronized public void paintComponent(Graphics g1)\r
{\r
Graphics2D g = (Graphics2D) g1;\r
g.setColor(Color.white);\r
g.fillRect(0, 0, getWidth(), getHeight());\r
+\r
if (image != null)\r
{\r
g.rotate(Math.toRadians(angle), 28, 28);\r
g.drawImage(image, 10, 10, this);\r
g.rotate( -Math.toRadians(angle), 28, 28);\r
}\r
+\r
g.setFont(new Font("Arial", Font.BOLD, 12));\r
g.setColor(Color.black);\r
- switch(currentStatus)\r
+\r
+ switch (currentStatus)\r
{\r
case STATE_QUEUING:\r
g.drawString(title.concat(" - queuing"), 60, 30);\r
+\r
break;\r
+\r
case STATE_RUNNING:\r
g.drawString(title.concat(" - running"), 60, 30);\r
+\r
break;\r
+\r
case STATE_STOPPED_OK:\r
g.drawString(title.concat(" - complete"), 60, 30);\r
+\r
break;\r
\r
case STATE_CANCELLED_OK:\r
g.drawString(title.concat(" - job cancelled!"), 60, 30);\r
+\r
break;\r
\r
case STATE_STOPPED_ERROR:\r
g.drawString(title.concat(" - job error!"), 60, 30);\r
+\r
break;\r
+\r
case STATE_STOPPED_SERVERERROR:\r
- g.drawString(title.concat(" - Server Error! (try later)"), 60, 30);\r
+ g.drawString(title.concat(" - Server Error! (try later)"), 60,\r
+ 30);\r
+\r
break;\r
}\r
-\r
}\r
}\r
}\r