801e3da936a7aae8767fedc6730aa8a1d272978b
[jalview.git] / src / jalview / gui / WebserviceInfo.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.jbgui.GWebserviceInfo;
24 import jalview.util.MessageManager;
25 import jalview.ws.WSClientI;
26
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Dimension;
30 import java.awt.Graphics;
31 import java.awt.Graphics2D;
32 import java.awt.GridLayout;
33 import java.awt.Image;
34 import java.awt.MediaTracker;
35 import java.awt.RenderingHints;
36 import java.awt.event.ActionEvent;
37 import java.awt.image.BufferedImage;
38 import java.util.Vector;
39
40 import javax.swing.JComponent;
41 import javax.swing.JEditorPane;
42 import javax.swing.JInternalFrame;
43 import javax.swing.JPanel;
44 import javax.swing.JScrollPane;
45 import javax.swing.JTabbedPane;
46 import javax.swing.JTextArea;
47 import javax.swing.event.HyperlinkEvent;
48 import javax.swing.event.HyperlinkListener;
49 import javax.swing.text.html.HTMLEditorKit;
50 import javax.swing.text.html.StyleSheet;
51
52 /**
53  * Base class for web service client thread and gui TODO: create StAX parser to
54  * extract html body content reliably when preparing html formatted job statuses
55  * 
56  * @author $author$
57  * @version $Revision$
58  */
59 public class WebserviceInfo extends GWebserviceInfo
60         implements HyperlinkListener, IProgressIndicator
61 {
62
63   /** Job is Queued */
64   public static final int STATE_QUEUING = 0;
65
66   /** Job is Running */
67   public static final int STATE_RUNNING = 1;
68
69   /** Job has finished with no errors */
70   public static final int STATE_STOPPED_OK = 2;
71
72   /** Job has been cancelled with no errors */
73   public static final int STATE_CANCELLED_OK = 3;
74
75   /** job has stopped because of some error */
76   public static final int STATE_STOPPED_ERROR = 4;
77
78   /** job has failed because of some unavoidable service interruption */
79   public static final int STATE_STOPPED_SERVERERROR = 5;
80
81   int currentStatus = STATE_QUEUING;
82
83   Image image;
84
85   int angle = 0;
86
87   String title = "";
88
89   jalview.ws.WSClientI thisService;
90
91   boolean serviceIsCancellable;
92
93   JInternalFrame frame;
94
95   private IProgressIndicator progressBar;
96
97   @Override
98   public void setVisible(boolean aFlag)
99   {
100     super.setVisible(aFlag);
101     frame.setVisible(aFlag);
102   };
103
104   JTabbedPane subjobs = null;
105
106   java.util.Vector jobPanes = null;
107
108   private boolean serviceCanMergeResults = false;
109
110   private boolean viewResultsImmediatly = true;
111
112   /**
113    * Get
114    * 
115    * @param flag
116    *          to indicate if results will be shown in a new window as soon as
117    *          they are available.
118    */
119   public boolean isViewResultsImmediatly()
120   {
121     return viewResultsImmediatly;
122   }
123
124   /**
125    * Set
126    * 
127    * @param flag
128    *          to indicate if results will be shown in a new window as soon as
129    *          they are available.
130    */
131   public void setViewResultsImmediatly(boolean viewResultsImmediatly)
132   {
133     this.viewResultsImmediatly = viewResultsImmediatly;
134   }
135
136   private StyleSheet getStyleSheet(HTMLEditorKit editorKit)
137   {
138
139     // Copied blatantly from
140     // http://www.velocityreviews.com/forums/t132265-string-into-htmldocument.html
141     StyleSheet myStyleSheet = new StyleSheet();
142
143     myStyleSheet.addStyleSheet(editorKit.getStyleSheet());
144
145     editorKit.setStyleSheet(myStyleSheet);
146
147     /*
148      * Set the style sheet rules here by reading them from the constants
149      * interface.
150      */
151     /*
152      * for (int ix=0; ix<CSS_RULES.length; ix++) {
153      * 
154      * myStyleSheet.addRule(CSS_RULES[ix]);
155      * 
156      * }
157      */
158     return myStyleSheet;
159
160   }
161
162   // tabbed or not
163   public synchronized int addJobPane()
164   {
165     JScrollPane jobpane = new JScrollPane();
166     JComponent _progressText;
167     if (renderAsHtml)
168     {
169       JEditorPane progressText = new JEditorPane("text/html", "");
170       progressText.addHyperlinkListener(this);
171       _progressText = progressText;
172       // progressText.setFont(new java.awt.Font("Verdana", 0, 10));
173       // progressText.setBorder(null);
174       progressText.setEditable(false);
175       /*
176        * HTMLEditorKit myEditorKit = new HTMLEditorKit();
177        * 
178        * StyleSheet myStyleSheet = getStyleSheet(myEditorKit);
179        * 
180        * HTMLDocument tipDocument = (HTMLDocument)
181        * (myEditorKit.createDefaultDocument());
182        * 
183        * progressText.setDocument(tipDocument);
184        */progressText.setText("<html><h1>WS Job</h1></html>");
185     }
186     else
187     {
188       JTextArea progressText = new JTextArea();
189       _progressText = progressText;
190
191       progressText.setFont(new java.awt.Font("Verdana", 0, 10));
192       progressText.setBorder(null);
193       progressText.setEditable(false);
194       progressText.setText("WS Job");
195       progressText.setLineWrap(true);
196       progressText.setWrapStyleWord(true);
197     }
198     jobpane.setName("JobPane");
199     jobpane.getViewport().add(_progressText, null);
200     jobpane.setBorder(null);
201     if (jobPanes == null)
202     {
203       jobPanes = new Vector();
204     }
205     int newpane = jobPanes.size();
206     jobPanes.add(jobpane);
207
208     if (newpane == 0)
209     {
210       this.add(jobpane, BorderLayout.CENTER);
211     }
212     else
213     {
214       if (newpane == 1)
215       {
216         // revert to a tabbed pane.
217         JScrollPane firstpane;
218         this.remove(firstpane = (JScrollPane) jobPanes.get(0));
219         subjobs = new JTabbedPane();
220         this.add(subjobs, BorderLayout.CENTER);
221         subjobs.add(firstpane);
222         subjobs.setTitleAt(0, firstpane.getName());
223       }
224       subjobs.add(jobpane);
225     }
226     return newpane; // index for accessor methods below
227   }
228
229   /**
230    * Creates a new WebserviceInfo object.
231    * 
232    * @param title
233    *          short name and job type
234    * @param info
235    *          reference or other human readable description
236    * @param makeVisible
237    *          true to display the webservices window immediatly (otherwise need
238    *          to call setVisible(true))
239    */
240   public WebserviceInfo(String title, String info, boolean makeVisible)
241   {
242     init(title, info, 520, 500, makeVisible);
243   }
244
245   /**
246    * Creates a new WebserviceInfo object.
247    * 
248    * @param title
249    *          DOCUMENT ME!
250    * @param info
251    *          DOCUMENT ME!
252    * @param width
253    *          DOCUMENT ME!
254    * @param height
255    *          DOCUMENT ME!
256    */
257   public WebserviceInfo(String title, String info, int width, int height,
258           boolean makeVisible)
259   {
260     init(title, info, width, height, makeVisible);
261   }
262
263   /**
264    * DOCUMENT ME!
265    * 
266    * @return DOCUMENT ME!
267    */
268   public jalview.ws.WSClientI getthisService()
269   {
270     return thisService;
271   }
272
273   /**
274    * Update state of GUI based on client capabilities (like whether the job is
275    * cancellable, whether the 'merge results' button is shown.
276    * 
277    * @param newservice
278    *          service client to query for capabilities
279    */
280   public void setthisService(jalview.ws.WSClientI newservice)
281   {
282     thisService = newservice;
283     serviceIsCancellable = newservice.isCancellable();
284     frame.setClosable(!serviceIsCancellable);
285     serviceCanMergeResults = newservice.canMergeResults();
286     rebuildButtonPanel();
287   }
288
289   private void rebuildButtonPanel()
290   {
291     if (buttonPanel != null)
292     {
293       buttonPanel.removeAll();
294       if (serviceIsCancellable)
295       {
296         buttonPanel.add(cancel);
297         frame.setClosable(false);
298       }
299       else
300       {
301         frame.setClosable(true);
302       }
303     }
304   }
305
306   /**
307    * DOCUMENT ME!
308    * 
309    * @param title
310    *          DOCUMENT ME!
311    * @param info
312    *          DOCUMENT ME!
313    * @param width
314    *          DOCUMENT ME!
315    * @param height
316    *          DOCUMENT ME!
317    */
318   void init(String title, String info, int width, int height,
319           boolean makeVisible)
320   {
321     frame = new JInternalFrame();
322     frame.setContentPane(this);
323     Desktop.addInternalFrame(frame, title, makeVisible, width, height);
324     frame.setClosable(false);
325
326     progressBar = new ProgressBar(statusPanel, statusBar);
327
328     this.title = title;
329     setInfoText(info);
330
331     java.net.URL url = getClass()
332             .getResource("/images/Jalview_Logo_small_with_border.png");
333     image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
334
335     MediaTracker mt = new MediaTracker(this);
336     mt.addImage(image, 0);
337
338     try
339     {
340       mt.waitForID(0);
341     } catch (Exception ex)
342     {
343     }
344
345     AnimatedPanel ap = new AnimatedPanel();
346     ap.setPreferredSize(new Dimension(60, 60));
347     titlePanel.add(ap, BorderLayout.WEST);
348     titlePanel.add(titleText, BorderLayout.CENTER);
349
350     Thread thread = new Thread(ap);
351     thread.start();
352     final WebserviceInfo thisinfo = this;
353     frame.addInternalFrameListener(
354             new javax.swing.event.InternalFrameAdapter()
355             {
356               @Override
357                         public void internalFrameClosed(
358                       javax.swing.event.InternalFrameEvent evt)
359               {
360                 // System.out.println("Shutting down webservice client");
361                 WSClientI service = thisinfo.getthisService();
362                 if (service != null && service.isCancellable())
363                 {
364                   service.cancelJob();
365                 }
366               };
367             });
368     frame.validate();
369
370   }
371
372   /**
373    * DOCUMENT ME!
374    * 
375    * @param status
376    *          integer status from state constants
377    */
378   public void setStatus(int status)
379   {
380     currentStatus = status;
381
382     String message = null;
383     switch (currentStatus)
384     {
385     case STATE_QUEUING:
386       message = MessageManager.getString("label.state_queueing");
387       break;
388
389     case STATE_RUNNING:
390       message = MessageManager.getString("label.state_running");
391       break;
392
393     case STATE_STOPPED_OK:
394       message = MessageManager.getString("label.state_completed");
395       break;
396
397     case STATE_CANCELLED_OK:
398       message = MessageManager.getString("label.state_job_cancelled");
399       break;
400
401     case STATE_STOPPED_ERROR:
402       message = MessageManager.getString("label.state_job_error");
403       break;
404
405     case STATE_STOPPED_SERVERERROR:
406       message = MessageManager.getString("label.server_error_try_later");
407       break;
408     }
409     titleText.setText(title + (message == null ? "" : " - " + message));
410     titleText.repaint();
411   }
412
413   /**
414    * subjob status indicator
415    * 
416    * @param jobpane
417    * @param status
418    */
419   public void setStatus(int jobpane, int status)
420   {
421     if (jobpane < 0 || jobpane >= jobPanes.size())
422     {
423       throw new Error(MessageManager.formatMessage(
424               "error.setstatus_called_non_existent_job_pane", new String[]
425               { Integer.valueOf(jobpane).toString() }));
426     }
427     switch (status)
428     {
429     case STATE_QUEUING:
430       setProgressName(jobpane + " - QUEUED", jobpane);
431       break;
432     case STATE_RUNNING:
433       setProgressName(jobpane + " - RUNNING", jobpane);
434       break;
435     case STATE_STOPPED_OK:
436       setProgressName(jobpane + " - FINISHED", jobpane);
437       break;
438     case STATE_CANCELLED_OK:
439       setProgressName(jobpane + " - CANCELLED", jobpane);
440       break;
441     case STATE_STOPPED_ERROR:
442       setProgressName(jobpane + " - BROKEN", jobpane);
443       break;
444     case STATE_STOPPED_SERVERERROR:
445       setProgressName(jobpane + " - ALERT", jobpane);
446       break;
447     default:
448       setProgressName(jobpane + " - UNKNOWN STATE", jobpane);
449     }
450   }
451
452   /**
453    * DOCUMENT ME!
454    * 
455    * @return DOCUMENT ME!
456    */
457   public String getInfoText()
458   {
459     return infoText.getText();
460   }
461
462   /**
463    * DOCUMENT ME!
464    * 
465    * @param text
466    *          DOCUMENT ME!
467    */
468   public void setInfoText(String text)
469   {
470     infoText.setText(text);
471   }
472
473   /**
474    * DOCUMENT ME!
475    * 
476    * @param text
477    *          DOCUMENT ME!
478    */
479   public void appendInfoText(String text)
480   {
481     infoText.append(text);
482   }
483
484   /**
485    * DOCUMENT ME!
486    * 
487    * @return DOCUMENT ME!
488    */
489   public String getProgressText(int which)
490   {
491     if (jobPanes == null)
492     {
493       addJobPane();
494     }
495     if (renderAsHtml)
496     {
497       return ((JEditorPane) ((JScrollPane) jobPanes.get(which))
498               .getViewport().getComponent(0)).getText();
499     }
500     else
501     {
502       return ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
503               .getComponent(0)).getText();
504     }
505   }
506
507   /**
508    * DOCUMENT ME!
509    * 
510    * @param text
511    *          DOCUMENT ME!
512    */
513   public void setProgressText(int which, String text)
514   {
515     if (jobPanes == null)
516     {
517       addJobPane();
518     }
519     if (renderAsHtml)
520     {
521       ((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport()
522               .getComponent(0)).setText(ensureHtmlTagged(text));
523     }
524     else
525     {
526       ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
527               .getComponent(0)).setText(text);
528     }
529   }
530
531   /**
532    * extract content from &lt;body&gt; content &lt;/body&gt;
533    * 
534    * @param text
535    * @param leaveFirst
536    *          - set to leave the initial html tag intact
537    * @param leaveLast
538    *          - set to leave the final html tag intact
539    * @return
540    */
541   private String getHtmlFragment(String text, boolean leaveFirst,
542           boolean leaveLast)
543   {
544     if (text == null)
545     {
546       return null;
547     }
548     String lowertxt = text.toLowerCase();
549     int htmlpos = leaveFirst ? -1 : lowertxt.indexOf("<body");
550
551     int htmlend = leaveLast ? -1 : lowertxt.indexOf("</body");
552     int htmlpose = lowertxt.indexOf(">", htmlpos),
553             htmlende = lowertxt.indexOf(">", htmlend);
554     if (htmlend == -1 && htmlpos == -1)
555     {
556       return text;
557     }
558     if (htmlend > -1)
559     {
560       return text.substring((htmlpos == -1 ? 0 : htmlpose + 1), htmlend);
561     }
562     return text.substring(htmlpos == -1 ? 0 : htmlpose + 1);
563   }
564
565   /**
566    * very simple routine for adding/ensuring html tags are present in text.
567    * 
568    * @param text
569    * @return properly html tag enclosed text
570    */
571   private String ensureHtmlTagged(String text)
572   {
573     if (text == null)
574     {
575       return "";
576     }
577     String lowertxt = text.toLowerCase();
578     int htmlpos = lowertxt.indexOf("<body");
579     int htmlend = lowertxt.indexOf("</body");
580     int doctype = lowertxt.indexOf("<!doctype");
581     int xmltype = lowertxt.indexOf("<?xml");
582     if (htmlend == -1)
583     {
584       text = text + "</body></html>";
585     }
586     if (htmlpos > -1)
587     {
588       if ((doctype > -1 && htmlpos > doctype)
589               || (xmltype > -1 && htmlpos > xmltype))
590       {
591         text = "<html><head></head><body>\n" + text.substring(htmlpos - 1);
592       }
593     }
594     else
595     {
596       text = "<html><head></head><body>\n" + text;
597     }
598     if (text.indexOf("<meta") > -1)
599     {
600       System.err
601               .println("HTML COntent: \n" + text + "<< END HTML CONTENT\n");
602
603     }
604     return text;
605   }
606
607   /**
608    * DOCUMENT ME!
609    * 
610    * @param text
611    *          DOCUMENT ME!
612    */
613   public void appendProgressText(int which, String text)
614   {
615     if (jobPanes == null)
616     {
617       addJobPane();
618     }
619     if (renderAsHtml)
620     {
621       String txt = getHtmlFragment(
622               ((JEditorPane) ((JScrollPane) jobPanes.get(which))
623                       .getViewport().getComponent(0)).getText(),
624               true, false);
625       ((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport()
626               .getComponent(0))
627                       .setText(ensureHtmlTagged(
628                               txt + getHtmlFragment(text, false, true)));
629     }
630     else
631     {
632       ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
633               .getComponent(0)).append(text);
634     }
635   }
636
637   /**
638    * setProgressText(0, text)
639    */
640   public void setProgressText(String text)
641   {
642     setProgressText(0, text);
643   }
644
645   /**
646    * appendProgressText(0, text)
647    */
648   public void appendProgressText(String text)
649   {
650     appendProgressText(0, text);
651   }
652
653   /**
654    * getProgressText(0)
655    */
656   public String getProgressText()
657   {
658     return getProgressText(0);
659   }
660
661   /**
662    * get the tab title for a subjob
663    * 
664    * @param which
665    *          int
666    * @return String
667    */
668   public String getProgressName(int which)
669   {
670     if (jobPanes == null)
671     {
672       addJobPane();
673     }
674     if (subjobs != null)
675     {
676       return subjobs.getTitleAt(which);
677     }
678     else
679     {
680       return ((JScrollPane) jobPanes.get(which)).getViewport()
681               .getComponent(0).getName();
682     }
683   }
684
685   /**
686    * set the tab title for a subjob
687    * 
688    * @param name
689    *          String
690    * @param which
691    *          int
692    */
693   public void setProgressName(String name, int which)
694   {
695     if (subjobs != null)
696     {
697       subjobs.setTitleAt(which, name);
698       subjobs.revalidate();
699       subjobs.repaint();
700     }
701     JScrollPane c = (JScrollPane) jobPanes.get(which);
702     c.getViewport().getComponent(0).setName(name);
703     c.repaint();
704   }
705
706   /**
707    * Gui action for cancelling the current job, if possible.
708    * 
709    * @param e
710    *          DOCUMENT ME!
711    */
712   @Override
713 protected void cancel_actionPerformed(ActionEvent e)
714   {
715     if (!serviceIsCancellable)
716     {
717       // JBPNote : TODO: We should REALLY just tell the WSClientI to cancel
718       // anyhow - it has to stop threads and clean up
719       // JBPNote : TODO: Instead of a warning, we should have an optional 'Are
720       // you sure?' prompt
721       warnUser(
722               MessageManager.getString(
723                       "warn.job_cannot_be_cancelled_close_window"),
724               MessageManager.getString("action.cancel_job"));
725     }
726     else
727     {
728       thisService.cancelJob();
729     }
730     frame.setClosable(true);
731   }
732
733   /**
734    * Spawns a thread that pops up a warning dialog box with the given message
735    * and title.
736    * 
737    * @param message
738    * @param title
739    */
740   public void warnUser(final String message, final String title)
741   {
742     javax.swing.SwingUtilities.invokeLater(new Runnable()
743     {
744       @Override
745         public void run()
746       {
747         JvOptionPane.showInternalMessageDialog(Desktop.desktop, message,
748                 title, JvOptionPane.WARNING_MESSAGE);
749
750       }
751     });
752   }
753
754   /**
755    * Set up GUI for user to get at results - and possibly automatically display
756    * them if viewResultsImmediatly is set.
757    */
758   public void setResultsReady()
759   {
760     frame.setClosable(true);
761     buttonPanel.remove(cancel);
762     buttonPanel.add(showResultsNewFrame);
763     if (serviceCanMergeResults)
764     {
765       buttonPanel.add(mergeResults);
766       buttonPanel.setLayout(new GridLayout(2, 1, 5, 5));
767     }
768     buttonPanel.validate();
769     validate();
770     if (viewResultsImmediatly)
771     {
772       showResultsNewFrame.doClick();
773     }
774   }
775
776   /**
777    * called when job has finished but no result objects can be passed back to
778    * user
779    */
780   public void setFinishedNoResults()
781   {
782     frame.setClosable(true);
783     buttonPanel.remove(cancel);
784     buttonPanel.validate();
785     validate();
786   }
787
788   class AnimatedPanel extends JPanel implements Runnable
789   {
790     long startTime = 0;
791
792     BufferedImage offscreen;
793
794     @Override
795         public void run()
796     {
797       startTime = System.currentTimeMillis();
798
799       while (currentStatus < STATE_STOPPED_OK)
800       {
801         try
802         {
803           Thread.sleep(50);
804
805           int units = (int) ((System.currentTimeMillis() - startTime)
806                   / 10f);
807           angle += units;
808           angle %= 360;
809           startTime = System.currentTimeMillis();
810
811           if (currentStatus >= STATE_STOPPED_OK)
812           {
813             angle = 0;
814           }
815
816           repaint();
817         } catch (Exception ex)
818         {
819         }
820       }
821
822       cancel.setEnabled(false);
823     }
824
825     void drawPanel()
826     {
827       if (offscreen == null || offscreen.getWidth(this) != getWidth()
828               || offscreen.getHeight(this) != getHeight())
829       {
830         offscreen = new BufferedImage(getWidth(), getHeight(),
831                 BufferedImage.TYPE_INT_RGB);
832       }
833
834       Graphics2D g = (Graphics2D) offscreen.getGraphics();
835
836       g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
837               RenderingHints.VALUE_ANTIALIAS_ON);
838       g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
839               RenderingHints.VALUE_INTERPOLATION_BICUBIC);
840       g.setRenderingHint(RenderingHints.KEY_RENDERING,
841               RenderingHints.VALUE_RENDER_QUALITY);
842
843       g.setColor(Color.white);
844       g.fillRect(0, 0, getWidth(), getHeight());
845
846       if (image != null)
847       {
848         int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2;
849         g.rotate(Math.toRadians(angle), x, y);
850         g.drawImage(image, 0, 0, this);
851         g.rotate(-Math.toRadians(angle), x, y);
852       }
853     }
854
855     @Override
856         public void paintComponent(Graphics g1)
857     {
858       drawPanel();
859
860       g1.drawImage(offscreen, 0, 0, this);
861     }
862   }
863
864   boolean renderAsHtml = false;
865
866   public void setRenderAsHtml(boolean b)
867   {
868     renderAsHtml = b;
869   }
870
871   @Override
872 public void hyperlinkUpdate(HyperlinkEvent e)
873   {
874     Desktop.hyperlinkUpdate(e);
875   }
876
877   /*
878    * (non-Javadoc)
879    * 
880    * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
881    */
882   @Override
883   public void setProgressBar(String message, long id)
884   {
885     progressBar.setProgressBar(message, id);
886   }
887
888   @Override
889   public void registerHandler(final long id,
890           final IProgressIndicatorHandler handler)
891   {
892     progressBar.registerHandler(id, handler);
893   }
894
895   /**
896    * 
897    * @return true if any progress bars are still active
898    */
899   @Override
900   public boolean operationInProgress()
901   {
902     return progressBar.operationInProgress();
903   }
904 }