X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FWebserviceInfo.java;h=0a098e5ea650201f3534338f8a3cb985cab2848d;hb=94f96a9c993be278b360ad15965715063db72520;hp=26aa067c1d53d66463e352221a632d4060aaab84;hpb=2d235d86ceb55ebb6b9422b17a4603248e13998d;p=jalview.git diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 26aa067..0a098e5 100755 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -1,22 +1,44 @@ +/* + * 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 java.awt.*; import java.awt.event.*; import javax.swing.*; -import jalview.jbgui.GWebserviceInfo; -public class WebserviceInfo extends GWebserviceInfo -{ +import jalview.jbgui.*; +public class WebserviceInfo + extends GWebserviceInfo +{ 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; + public static final int STATE_CANCELLED_OK = 3; + public static final int STATE_STOPPED_ERROR = 4; + public static final int STATE_STOPPED_SERVERERROR = 5; int currentStatus = STATE_QUEUING; Image image; int angle = 0; - - String title=""; + String title = ""; + jalview.ws.WSClientI thisService; + boolean serviceIsCancellable; public WebserviceInfo(String title, String info) { @@ -28,6 +50,17 @@ public class WebserviceInfo extends GWebserviceInfo init(title, info, width, height); } + public jalview.ws.WSClientI getthisService() + { + return thisService; + } + + public void setthisService(jalview.ws.WSClientI newservice) + { + thisService = newservice; + serviceIsCancellable = newservice.isCancellable(); + } + void init(String title, String info, int width, int height) { JInternalFrame frame = new JInternalFrame(); @@ -36,20 +69,24 @@ public class WebserviceInfo extends GWebserviceInfo 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 { mt.waitForID(0); } catch (Exception ex) - {} - + { + } AnimatedPanel ap = new AnimatedPanel(); titlePanel.add(ap, BorderLayout.CENTER); + Thread thread = new Thread(ap); thread.start(); } @@ -60,86 +97,130 @@ public class WebserviceInfo extends GWebserviceInfo } public String getInfoText() - { return infoText.getText(); } + { + return infoText.getText(); + } public void setInfoText(String text) - { infoText.setText(text); } + { + infoText.setText(text); + } public void appendInfoText(String text) - { infoText.append(text); } + { + infoText.append(text); + } public String getProgressText() - { return progressText.getText(); } + { + return progressText.getText(); + } public void setProgressText(String text) - { progressText.setText(text); } + { + progressText.setText(text); + } public void appendProgressText(String text) - { progressText.append(text); } + { + progressText.append(text); + } protected void cancel_actionPerformed(ActionEvent e) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Cancel not implemented yet!!" , - "Cancel job" - ,JOptionPane.WARNING_MESSAGE); + if (!serviceIsCancellable) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "This job cannot be cancelled.", + "Cancel job", + JOptionPane.WARNING_MESSAGE); + } + else + { + thisService.cancelJob(); + } } - - class AnimatedPanel extends JPanel implements Runnable + class AnimatedPanel + extends JPanel implements Runnable { - long startTime=0; + long startTime = 0; + public void run() { startTime = System.currentTimeMillis(); - while(currentStatus