JAL-1976 Added progress indicators for HTML_SVG and BioJS export operations
[jalview.git] / src / jalview / io / HtmlSvgOutput.java
index e946367..b53cacd 100644 (file)
@@ -27,6 +27,7 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.AlignViewport;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.HTMLOptions;
+import jalview.gui.IProgressIndicator;
 import jalview.math.AlignmentDimension;
 import jalview.util.MessageManager;
 
@@ -59,11 +60,20 @@ public class HtmlSvgOutput
 
   public void generateHtmlSvgOutput(File file)
   {
+    IProgressIndicator pIndicator = ap.alignFrame;
+    long pSessionId = System.currentTimeMillis();
     try
     {
+      boolean headless = (System.getProperty("java.awt.headless") != null && System
+              .getProperty("java.awt.headless").equals("true"));
       if (file == null)
       {
-
+        if (pIndicator != null && !headless)
+        {
+          pIndicator.setProgressBar(MessageManager.formatMessage(
+                  "status.waiting_for_user_to_select_output_file", "HTML"),
+                  pSessionId);
+        }
         JalviewFileChooser chooser = getHTMLChooser();
         chooser.setFileView(new jalview.io.JalviewFileView());
         chooser.setDialogTitle(ap.alignFrame.getTitle());
@@ -76,6 +86,17 @@ public class HtmlSvgOutput
                   .getSelectedFile().getParent());
           file = chooser.getSelectedFile();
         }
+        else
+        {
+
+          if (pIndicator != null && !headless)
+        {
+            pIndicator.setProgressBar(MessageManager.formatMessage(
+                    "status.cancelled_image_export_operation", "HTML"),
+                    pSessionId);
+          }
+          return;
+        }
       }
 
       AlignmentDimension aDimension = ap.getAlignmentDimension();
@@ -178,9 +199,16 @@ public class HtmlSvgOutput
       {
         jalview.util.BrowserLauncher.openURL("file:///" + file);
       }
+      if (pIndicator != null && !headless)
+      {
+        pIndicator.setProgressBar(MessageManager.formatMessage(
+                "status.export_complete", "HTML"), pSessionId);
+      }
     } catch (Exception e)
     {
       e.printStackTrace();
+      pIndicator.setProgressBar(MessageManager.formatMessage(
+              "info.error_creating_file", "HTML"), pSessionId);
     }
   }