X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FWebserviceInfo.java;h=a26007262dbdf4ff745be8dfcb2c4024ed9ff53f;hb=73e6ed31b0328def2a94c643fc71380acf16d17c;hp=7ce77a30598cc03a404745f5c4e481233e70f7fe;hpb=aeb0422c06425ac0c76375106ffc635d03e88b88;p=jalview.git diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 7ce77a3..a260072 100755 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -1,157 +1,313 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.gui; +import jalview.jbgui.*; + import java.awt.*; import java.awt.event.*; + import javax.swing.*; -import jalview.jbgui.GWebserviceInfo; + +/** + * Base class for web service client thread and gui + * + * @author $author$ + * @version $Revision$ + */ public class WebserviceInfo extends GWebserviceInfo { + /** Job is Queued */ + public static final int STATE_QUEUING = 0; + + /** Job is Running */ + public static final int STATE_RUNNING = 1; + + /** Job has finished with no errors */ + public static final int STATE_STOPPED_OK = 2; + + /** Job has been cancelled with no errors */ + public static final int STATE_CANCELLED_OK = 3; + + /** job has stopped because of some error */ + public static final int STATE_STOPPED_ERROR = 4; - public static final int STATE_QUEUING = 0; - public static final int STATE_RUNNING = 1; - public static final int STATE_STOPPED_OK = 2; - public static final int STATE_STOPPED_ERROR = 3; - int currentStatus = STATE_QUEUING; - Image image; - int angle = 0; - - String title=""; - jalview.ws.WSClientI thisService; - boolean serviceIsCancellable; - public jalview.ws.WSClientI getthisService() { - return thisService; - } - public void setthisService(jalview.ws.WSClientI newservice) { - thisService = newservice; - serviceIsCancellable = newservice.isCancellable(); - } - - public WebserviceInfo(String title, String info) - { - init(title, info, 520, 500); - } - - public WebserviceInfo(String title, String info, int width, int height) - { - init(title, info, width, height); - } - - void init(String title, String info, int width, int height) - { - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, title, width, height); - - this.title = title; - setInfoText(info); - java.net.URL url = getClass().getResource("/images/logo.gif"); - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - MediaTracker mt = new MediaTracker(this); - mt.addImage(image, 0); - try + /** job has failed because of some unavoidable service interruption */ + public static final int STATE_STOPPED_SERVERERROR = 5; + int currentStatus = STATE_QUEUING; + Image image; + int angle = 0; + String title = ""; + jalview.ws.WSClientI thisService; + boolean serviceIsCancellable; + + /** + * Creates a new WebserviceInfo object. + * + * @param title short name and job type + * @param info reference or other human readable description + */ + public WebserviceInfo(String title, String info) { - mt.waitForID(0); + init(title, info, 520, 500); } - catch (Exception ex) - {} + /** + * Creates a new WebserviceInfo object. + * + * @param title DOCUMENT ME! + * @param info DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public WebserviceInfo(String title, String info, int width, int height) + { + init(title, info, width, height); + } - AnimatedPanel ap = new AnimatedPanel(); - titlePanel.add(ap, BorderLayout.CENTER); - Thread thread = new Thread(ap); - thread.start(); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public jalview.ws.WSClientI getthisService() + { + return thisService; + } - public void setStatus(int status) - { - currentStatus = status; - } + /** + * DOCUMENT ME! + * + * @param newservice DOCUMENT ME! + */ + public void setthisService(jalview.ws.WSClientI newservice) + { + thisService = newservice; + serviceIsCancellable = newservice.isCancellable(); + } - public String getInfoText() - { return infoText.getText(); } + /** + * DOCUMENT ME! + * + * @param title DOCUMENT ME! + * @param info DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + void init(String title, String info, int width, int height) + { + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, title, width, height); - public void setInfoText(String text) - { infoText.setText(text); } + this.title = title; + setInfoText(info); - public void appendInfoText(String text) - { infoText.append(text); } + java.net.URL url = getClass().getResource("/images/logo.gif"); + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - public String getProgressText() - { return progressText.getText(); } + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); - public void setProgressText(String text) - { progressText.setText(text); } + try + { + mt.waitForID(0); + } + catch (Exception ex) + { + } - public void appendProgressText(String text) - { progressText.append(text); } + AnimatedPanel ap = new AnimatedPanel(); + titlePanel.add(ap, BorderLayout.CENTER); - protected void cancel_actionPerformed(ActionEvent e) - { - if (!serviceIsCancellable) - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Cancel not implemented yet!!" , - "Cancel job" - ,JOptionPane.WARNING_MESSAGE); - else - thisService.cancelJob(); - } + Thread thread = new Thread(ap); + thread.start(); + } + /** + * DOCUMENT ME! + * + * @param status integer status from state constants + */ + public void setStatus(int status) + { + currentStatus = status; + } - class AnimatedPanel extends JPanel implements Runnable - { - long startTime=0; - public void run() + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getInfoText() { - startTime = System.currentTimeMillis(); - while(currentStatus