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
- public static final int STATE_STOPPED_ERROR = 3;\r
+ public static final int STATE_CANCELLED_OK = 3;\r
+ public static final int STATE_STOPPED_ERROR = 4;\r
int currentStatus = STATE_QUEUING;\r
Image image;\r
int angle = 0;\r
\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
JInternalFrame frame = new JInternalFrame();\r
frame.setContentPane(this);\r
Desktop.addInternalFrame(frame, title, width, height);\r
- frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
-\r
\r
this.title = title;\r
setInfoText(info);\r
\r
protected void cancel_actionPerformed(ActionEvent e)\r
{\r
- JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "Cancel not implemented yet!!" ,\r
- "Cancel job"\r
- ,JOptionPane.WARNING_MESSAGE);\r
+ if (!serviceIsCancellable)\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "This job cannot be cancelled." ,\r
+ "Cancel job"\r
+ ,JOptionPane.WARNING_MESSAGE);\r
+ else\r
+ thisService.cancelJob();\r
}\r
\r
\r
class AnimatedPanel extends JPanel implements Runnable\r
{\r
+ long startTime=0;\r
public void run()\r
{\r
+ startTime = System.currentTimeMillis();\r
while(currentStatus<STATE_STOPPED_OK)\r
try\r
{\r
- Thread.sleep(10);\r
- angle += 1;\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
}\r
catch (Exception ex)\r
{}\r
\r
}\r
\r
- public void paintComponent(Graphics g1)\r
+ synchronized public void paintComponent(Graphics g1)\r
{\r
Graphics2D g = (Graphics2D) g1;\r
g.setColor(Color.white);\r
case STATE_STOPPED_OK:\r
g.drawString(title.concat(" - complete"), 60, 30);\r
break;\r
+\r
+ case STATE_CANCELLED_OK:\r
+ g.drawString(title.concat(" - job cancelled!"), 60, 30);\r
+ break;\r
+\r
case STATE_STOPPED_ERROR:\r
g.drawString(title.concat(" - error!"), 60, 30);\r
break;\r