JAL-1807 explicit imports (jalview.gui)
[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.Font;
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.event.ActionEvent;
36 import java.awt.image.BufferedImage;
37 import java.util.Vector;
38
39 import javax.swing.JComponent;
40 import javax.swing.JEditorPane;
41 import javax.swing.JInternalFrame;
42 import javax.swing.JOptionPane;
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 implements
60         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   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 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(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().getResource(
332             "/images/Jalview_Logo_small.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     titlePanel.add(ap, BorderLayout.CENTER);
347
348     Thread thread = new Thread(ap);
349     thread.start();
350     final WebserviceInfo thisinfo = this;
351     frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
352     {
353       public void internalFrameClosed(
354               javax.swing.event.InternalFrameEvent evt)
355       {
356         // System.out.println("Shutting down webservice client");
357         WSClientI service = thisinfo.getthisService();
358         if (service != null && service.isCancellable())
359         {
360           service.cancelJob();
361         }
362       };
363     });
364     frame.validate();
365
366   }
367
368   /**
369    * DOCUMENT ME!
370    * 
371    * @param status
372    *          integer status from state constants
373    */
374   public void setStatus(int status)
375   {
376     currentStatus = status;
377   }
378
379   /**
380    * subjob status indicator
381    * 
382    * @param jobpane
383    * @param status
384    */
385   public void setStatus(int jobpane, int status)
386   {
387     if (jobpane < 0 || jobpane >= jobPanes.size())
388     {
389       throw new Error(MessageManager.formatMessage("error.setstatus_called_non_existent_job_pane", new String[]{Integer.valueOf(jobpane).toString()}));
390     }
391     switch (status)
392     {
393     case STATE_QUEUING:
394       setProgressName(jobpane + " - QUEUED", jobpane);
395       break;
396     case STATE_RUNNING:
397       setProgressName(jobpane + " - RUNNING", jobpane);
398       break;
399     case STATE_STOPPED_OK:
400       setProgressName(jobpane + " - FINISHED", jobpane);
401       break;
402     case STATE_CANCELLED_OK:
403       setProgressName(jobpane + " - CANCELLED", jobpane);
404       break;
405     case STATE_STOPPED_ERROR:
406       setProgressName(jobpane + " - BROKEN", jobpane);
407       break;
408     case STATE_STOPPED_SERVERERROR:
409       setProgressName(jobpane + " - ALERT", jobpane);
410       break;
411     default:
412       setProgressName(jobpane + " - UNKNOWN STATE", jobpane);
413     }
414   }
415
416   /**
417    * DOCUMENT ME!
418    * 
419    * @return DOCUMENT ME!
420    */
421   public String getInfoText()
422   {
423     return infoText.getText();
424   }
425
426   /**
427    * DOCUMENT ME!
428    * 
429    * @param text
430    *          DOCUMENT ME!
431    */
432   public void setInfoText(String text)
433   {
434     infoText.setText(text);
435   }
436
437   /**
438    * DOCUMENT ME!
439    * 
440    * @param text
441    *          DOCUMENT ME!
442    */
443   public void appendInfoText(String text)
444   {
445     infoText.append(text);
446   }
447
448   /**
449    * DOCUMENT ME!
450    * 
451    * @return DOCUMENT ME!
452    */
453   public String getProgressText(int which)
454   {
455     if (jobPanes == null)
456     {
457       addJobPane();
458     }
459     if (renderAsHtml)
460     {
461       return ((JEditorPane) ((JScrollPane) jobPanes.get(which))
462               .getViewport().getComponent(0)).getText();
463     }
464     else
465     {
466       return ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
467               .getComponent(0)).getText();
468     }
469   }
470
471   /**
472    * DOCUMENT ME!
473    * 
474    * @param text
475    *          DOCUMENT ME!
476    */
477   public void setProgressText(int which, String text)
478   {
479     if (jobPanes == null)
480     {
481       addJobPane();
482     }
483     if (renderAsHtml)
484     {
485       ((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport()
486               .getComponent(0)).setText(ensureHtmlTagged(text));
487     }
488     else
489     {
490       ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
491               .getComponent(0)).setText(text);
492     }
493   }
494
495   /**
496    * extract content from &lt;body&gt; content &lt;/body&gt;
497    * 
498    * @param text
499    * @param leaveFirst
500    *          - set to leave the initial html tag intact
501    * @param leaveLast
502    *          - set to leave the final html tag intact
503    * @return
504    */
505   private String getHtmlFragment(String text, boolean leaveFirst,
506           boolean leaveLast)
507   {
508     if (text == null)
509     {
510       return null;
511     }
512     String lowertxt = text.toLowerCase();
513     int htmlpos = leaveFirst ? -1 : lowertxt.indexOf("<body");
514
515     int htmlend = leaveLast ? -1 : lowertxt.indexOf("</body");
516     int htmlpose = lowertxt.indexOf(">", htmlpos), htmlende = lowertxt
517             .indexOf(">", htmlend);
518     if (htmlend == -1 && htmlpos == -1)
519     {
520       return text;
521     }
522     if (htmlend > -1)
523     {
524       return text.substring((htmlpos == -1 ? 0 : htmlpose + 1), htmlend);
525     }
526     return text.substring(htmlpos == -1 ? 0 : htmlpose + 1);
527   }
528
529   /**
530    * very simple routine for adding/ensuring html tags are present in text.
531    * 
532    * @param text
533    * @return properly html tag enclosed text
534    */
535   private String ensureHtmlTagged(String text)
536   {
537     if (text == null)
538     {
539       return "";
540     }
541     String lowertxt = text.toLowerCase();
542     int htmlpos = lowertxt.indexOf("<body");
543     int htmlend = lowertxt.indexOf("</body");
544     int doctype = lowertxt.indexOf("<!doctype");
545     int xmltype = lowertxt.indexOf("<?xml");
546     if (htmlend == -1)
547     {
548       text = text + "</body></html>";
549     }
550     if (htmlpos > -1)
551     {
552       if ((doctype > -1 && htmlpos > doctype)
553               || (xmltype > -1 && htmlpos > xmltype))
554       {
555         text = "<html><head></head><body>\n" + text.substring(htmlpos - 1);
556       }
557     }
558     else
559     {
560       text = "<html><head></head><body>\n" + text;
561     }
562     if (text.indexOf("<meta") > -1)
563     {
564       System.err.println("HTML COntent: \n" + text
565               + "<< END HTML CONTENT\n");
566
567     }
568     return text;
569   }
570
571   /**
572    * DOCUMENT ME!
573    * 
574    * @param text
575    *          DOCUMENT ME!
576    */
577   public void appendProgressText(int which, String text)
578   {
579     if (jobPanes == null)
580     {
581       addJobPane();
582     }
583     if (renderAsHtml)
584     {
585       String txt = getHtmlFragment(
586               ((JEditorPane) ((JScrollPane) jobPanes.get(which))
587                       .getViewport().getComponent(0)).getText(), true,
588               false);
589       ((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport()
590               .getComponent(0)).setText(ensureHtmlTagged(txt
591               + getHtmlFragment(text, false, true)));
592     }
593     else
594     {
595       ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport()
596               .getComponent(0)).append(text);
597     }
598   }
599
600   /**
601    * setProgressText(0, text)
602    */
603   public void setProgressText(String text)
604   {
605     setProgressText(0, text);
606   }
607
608   /**
609    * appendProgressText(0, text)
610    */
611   public void appendProgressText(String text)
612   {
613     appendProgressText(0, text);
614   }
615
616   /**
617    * getProgressText(0)
618    */
619   public String getProgressText()
620   {
621     return getProgressText(0);
622   }
623
624   /**
625    * get the tab title for a subjob
626    * 
627    * @param which
628    *          int
629    * @return String
630    */
631   public String getProgressName(int which)
632   {
633     if (jobPanes == null)
634     {
635       addJobPane();
636     }
637     if (subjobs != null)
638     {
639       return subjobs.getTitleAt(which);
640     }
641     else
642     {
643       return ((JScrollPane) jobPanes.get(which)).getViewport()
644               .getComponent(0).getName();
645     }
646   }
647
648   /**
649    * set the tab title for a subjob
650    * 
651    * @param name
652    *          String
653    * @param which
654    *          int
655    */
656   public void setProgressName(String name, int which)
657   {
658     if (subjobs != null)
659     {
660       subjobs.setTitleAt(which, name);
661       subjobs.revalidate();
662       subjobs.repaint();
663     }
664     JScrollPane c = (JScrollPane) jobPanes.get(which);
665     c.getViewport().getComponent(0).setName(name);
666     c.repaint();
667   }
668
669   /**
670    * Gui action for cancelling the current job, if possible.
671    * 
672    * @param e
673    *          DOCUMENT ME!
674    */
675   protected void cancel_actionPerformed(ActionEvent e)
676   {
677     if (!serviceIsCancellable)
678     {
679       // JBPNote : TODO: We should REALLY just tell the WSClientI to cancel
680       // anyhow - it has to stop threads and clean up
681       // JBPNote : TODO: Instead of a warning, we should have an optional 'Are
682       // you sure?' prompt
683       warnUser(MessageManager.getString("warn.job_cannot_be_cancelled_close_window"),
684               MessageManager.getString("action.cancel_job"));
685     }
686     else
687     {
688       thisService.cancelJob();
689     }
690     frame.setClosable(true);
691   }
692
693   /**
694    * Spawns a thread that pops up a warning dialog box with the given message
695    * and title.
696    * 
697    * @param message
698    * @param title
699    */
700   public void warnUser(final String message, final String title)
701   {
702     javax.swing.SwingUtilities.invokeLater(new Runnable()
703     {
704       public void run()
705       {
706         JOptionPane.showInternalMessageDialog(Desktop.desktop, message,
707                 title, JOptionPane.WARNING_MESSAGE);
708
709       }
710     });
711   }
712
713   /**
714    * Set up GUI for user to get at results - and possibly automatically display
715    * them if viewResultsImmediatly is set.
716    */
717   public void setResultsReady()
718   {
719     frame.setClosable(true);
720     buttonPanel.remove(cancel);
721     buttonPanel.add(showResultsNewFrame);
722     if (serviceCanMergeResults)
723     {
724       buttonPanel.add(mergeResults);
725       buttonPanel.setLayout(new GridLayout(2, 1, 5, 5));
726     }
727     buttonPanel.validate();
728     validate();
729     if (viewResultsImmediatly)
730     {
731       showResultsNewFrame.doClick();
732     }
733   }
734
735   /**
736    * called when job has finished but no result objects can be passed back to
737    * user
738    */
739   public void setFinishedNoResults()
740   {
741     frame.setClosable(true);
742     buttonPanel.remove(cancel);
743     buttonPanel.validate();
744     validate();
745   }
746
747   class AnimatedPanel extends JPanel implements Runnable
748   {
749     long startTime = 0;
750
751     BufferedImage offscreen;
752
753     public void run()
754     {
755       startTime = System.currentTimeMillis();
756
757       while (currentStatus < STATE_STOPPED_OK)
758       {
759         try
760         {
761           Thread.sleep(50);
762
763           int units = (int) ((System.currentTimeMillis() - startTime) / 10f);
764           angle += units;
765           angle %= 360;
766           startTime = System.currentTimeMillis();
767
768           if (currentStatus >= STATE_STOPPED_OK)
769           {
770             angle = 0;
771           }
772
773           repaint();
774         } catch (Exception ex)
775         {
776         }
777       }
778
779       cancel.setEnabled(false);
780     }
781
782     void drawPanel()
783     {
784       if (offscreen == null || offscreen.getWidth(this) != getWidth()
785               || offscreen.getHeight(this) != getHeight())
786       {
787         offscreen = new BufferedImage(getWidth(), getHeight(),
788                 BufferedImage.TYPE_INT_ARGB);
789       }
790
791       Graphics2D g = (Graphics2D) offscreen.getGraphics();
792
793       g.setColor(Color.white);
794       g.fillRect(0, 0, getWidth(), getHeight());
795
796       g.setFont(new Font("Arial", Font.BOLD, 12));
797       g.setColor(Color.black);
798
799       switch (currentStatus)
800       {
801       case STATE_QUEUING:
802         g.drawString(
803                 title.concat(" - ").concat(
804                         MessageManager.getString("label.state_queueing")),
805                 60, 30);
806
807         break;
808
809       case STATE_RUNNING:
810         g.drawString(
811                 title.concat(" - ").concat(
812                         MessageManager.getString("label.state_running")),
813                 60, 30);
814
815         break;
816
817       case STATE_STOPPED_OK:
818         g.drawString(
819                 title.concat(" - ").concat(
820                         MessageManager.getString("label.state_completed")),
821                 60, 30);
822
823         break;
824
825       case STATE_CANCELLED_OK:
826         g.drawString(
827                 title.concat(" - ").concat(
828                         MessageManager
829                                 .getString("label.state_job_cancelled")),
830                 60, 30);
831
832         break;
833
834       case STATE_STOPPED_ERROR:
835         g.drawString(
836                 title.concat(" - ").concat(
837                         MessageManager.getString("label.state_job_error")),
838                 60, 30);
839
840         break;
841
842       case STATE_STOPPED_SERVERERROR:
843         g.drawString(
844                 title.concat(" - ").concat(
845                         MessageManager
846                                 .getString("label.server_error_try_later")),
847                 60, 30);
848
849         break;
850       }
851
852       if (image != null)
853       {
854         int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2;
855         g.rotate(Math.toRadians(angle), 10 + x, 10 + y);
856         g.drawImage(image, 10, 10, this);
857         g.rotate(-Math.toRadians(angle), 10 + x, 10 + y);
858       }
859     }
860
861     public void paintComponent(Graphics g1)
862     {
863       drawPanel();
864
865       g1.drawImage(offscreen, 0, 0, this);
866     }
867   }
868
869   boolean renderAsHtml = false;
870
871   public void setRenderAsHtml(boolean b)
872   {
873     renderAsHtml = b;
874   }
875
876   public void hyperlinkUpdate(HyperlinkEvent e)
877   {
878     Desktop.hyperlinkUpdate(e);
879   }
880
881   /*
882    * (non-Javadoc)
883    * 
884    * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
885    */
886   @Override
887   public void setProgressBar(String message, long id)
888   {
889     progressBar.setProgressBar(message, id);
890   }
891
892   @Override
893   public void registerHandler(final long id,
894           final IProgressIndicatorHandler handler)
895   {
896     progressBar.registerHandler(id, handler);
897   }
898
899   /**
900    * 
901    * @return true if any progress bars are still active
902    */
903   @Override
904   public boolean operationInProgress()
905   {
906     return progressBar.operationInProgress();
907   }
908 }