Merge branch 'Jalview-BH/JAL-3026-JAL-3063-JAXB' into
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 17 Dec 2018 17:25:49 +0000 (17:25 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 17 Dec 2018 17:25:49 +0000 (17:25 +0000)
JAL-3048dialogRunner2

Conflicts:
src/jalview/io/JalviewFileChooser.java

src/jalview/gui/ImageExporter.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/HTMLOutput.java
src/jalview/io/HtmlSvgOutput.java
src/jalview/io/JalviewFileChooser.java

index 0689220..90b212f 100644 (file)
@@ -88,6 +88,10 @@ public class ImageExporter
           String imageSource)
   {
     final long messageId = System.currentTimeMillis();
+    setStatus(
+            MessageManager.formatMessage(
+                    "status.exporting_alignment_as_x_file", imageType),
+            messageId);
 
     /*
      * prompt user for output file if not provided
@@ -186,10 +190,10 @@ public class ImageExporter
     String type = imageType.getName();
     try
     {
-      setStatus(
-              MessageManager.formatMessage(
-                      "status.exporting_alignment_as_x_file", type),
-              messageId);
+//      setStatus(
+//              MessageManager.formatMessage(
+//                      "status.exporting_alignment_as_x_file", type),
+//              messageId);
       ImageMaker im = new ImageMaker(imageType, width, height, chosenFile,
               title, asLineart);
       imageWriter.exportImage(im.getGraphics());
index 11436d3..9db3df2 100644 (file)
@@ -56,7 +56,7 @@ public class BioJsHTMLOutput extends HTMLOutput
 
   public BioJsHTMLOutput(AlignmentPanel ap)
   {
-    super(ap);
+    super(ap, "BioJS MSA");
   }
 
   public static void refreshVersionInfo(String dirName)
@@ -275,10 +275,4 @@ public class BioJsHTMLOutput extends HTMLOutput
 
   }
 
-  @Override
-  protected String getDescription()
-  {
-    return "BioJS MSA";
-  }
-
 }
index f7179cf..54e7e4b 100644 (file)
@@ -39,23 +39,34 @@ public abstract class HTMLOutput implements Runnable
 {
   protected AlignmentPanel ap;
 
+  /*
+   * key for progress or status messages
+   */
   protected long pSessionId;
 
+  /*
+   * (optional) place to write progress messages to
+   */
   protected IProgressIndicator pIndicator;
 
   protected File generatedFile;
 
   String _bioJson = null;
 
+  private String description;
+
   /**
    * Constructor given an alignment panel (which should not be null)
    * 
    * @param ap
+   * @param desc 
    */
-  public HTMLOutput(AlignmentPanel ap)
+  public HTMLOutput(AlignmentPanel ap, String desc)
   {
     this.ap = ap;
     this.pIndicator = ap.alignFrame;
+    this.description = desc;
+    this.pSessionId = System.currentTimeMillis();
   }
 
   /**
@@ -243,16 +254,6 @@ public abstract class HTMLOutput implements Runnable
 
   /**
    * This method provides implementation of consistent behaviour which should
-   * occur before a HTML file export. It MUST be called at the start of the
-   * exportHTML() method implementation.
-   */
-  protected void exportStarted()
-  {
-    pSessionId = System.currentTimeMillis();
-  }
-
-  /**
-   * This method provides implementation of consistent behaviour which should
    * occur after a HTML file export. It MUST be called at the end of the
    * exportHTML() method implementation.
    */
@@ -299,7 +300,8 @@ public abstract class HTMLOutput implements Runnable
 
   public void exportHTML(String outputFile)
   {
-    exportStarted();
+    setProgressMessage(MessageManager.formatMessage(
+        "status.exporting_alignment_as_x_file", getDescription()));
     try
     {
       if (outputFile == null)
@@ -334,5 +336,8 @@ public abstract class HTMLOutput implements Runnable
    * 
    * @return
    */
-  protected abstract String getDescription();
+  protected final String getDescription()
+  {
+       return description;
+  }
 }
\ No newline at end of file
index 1f82853..c1a9e9f 100644 (file)
@@ -44,34 +44,7 @@ public class HtmlSvgOutput extends HTMLOutput
 {
   public HtmlSvgOutput(AlignmentPanel ap)
   {
-    super(ap);
-  }
-
-  @Override
-  public void exportHTML(String outputFile)
-  {
-    exportStarted();
-    try
-    {
-      if (outputFile == null)
-      {
-        outputFile = getOutputFile();
-        if (outputFile == null)
-        {
-          setProgressMessage(MessageManager.formatMessage(
-                  "status.cancelled_image_export_operation", "HTML"));
-          return;
-        }
-      }
-      generatedFile = new File(outputFile);
-    } catch (Exception e)
-    {
-      setProgressMessage(MessageManager
-              .formatMessage("info.error_creating_file", "HTML"));
-      e.printStackTrace();
-      return;
-    }
-    new Thread(this).start();
+    super(ap, "HTML");
   }
 
   public int printUnwrapped(int pwidth, int pheight, int pi,
@@ -233,10 +206,6 @@ public class HtmlSvgOutput extends HTMLOutput
   {
     try
     {
-      setProgressMessage(null);
-      setProgressMessage(MessageManager.formatMessage(
-              "status.exporting_alignment_as_x_file", getDescription()));
-
       String renderStyle = Cache.getDefault("HTML_RENDERING",
               "Prompt each time");
       AtomicBoolean textOption = new AtomicBoolean(
@@ -349,10 +318,4 @@ public class HtmlSvgOutput extends HTMLOutput
               .formatMessage("info.error_creating_file", getDescription()));
     }
   }
-
-  @Override
-  protected String getDescription()
-  {
-    return "HTML";
-  }
 }
index 9c99603..81cb510 100755 (executable)
@@ -50,8 +50,6 @@ import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.SpringLayout;
-import javax.swing.SwingUtilities;
-import javax.swing.border.TitledBorder;
 import javax.swing.plaf.basic.BasicFileChooserUI;
 
 /**
@@ -317,16 +315,13 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
     return f == null ? selectedFile : f;
   }
 
-  /**
-   * Overridden for JalviewJS compatibility: only one thread in Javascript, 
-   * so we can't wait for user choice in another thread and then perform the 
-   * desired action
-   */
   @Override
   public int showSaveDialog(Component parent) throws HeadlessException
   {
     this.setAccessory(null);
+    // Java 9,10,11 on OSX - clear selected file so name isn't auto populated
     this.setSelectedFile(null);
+
     return super.showSaveDialog(parent);
   }
 
@@ -423,17 +418,9 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
     }
   }
 
-  /**
-   * A panel to set as the 'accessory' component to the file chooser dialog,
-   * holding a list of recently opened files (if any). These are held as a
-   * tab-separated list of file paths under key <code>RECENT_FILE</code> in
-   * <code>.jalview_properties</code>. A click in the list calls a method in
-   * JalviewFileChooser to set the chosen file as the selection.
-   */
   class RecentlyOpened extends JPanel
   {
     private static final long serialVersionUID = 1L;
-
     JList<String> list;
 
     RecentlyOpened()
@@ -446,6 +433,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
       if (historyItems != null)
       {
         st = new StringTokenizer(historyItems, "\t");
+
         while (st.hasMoreTokens())
         {
           recent.addElement(st.nextToken());
@@ -467,7 +455,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
         }
       });
 
-      this.setBorder(new TitledBorder(
+      this.setBorder(new javax.swing.border.TitledBorder(
               MessageManager.getString("label.recently_opened")));
 
       final JScrollPane scroller = new JScrollPane(list);
@@ -489,7 +477,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
 
       this.add(scroller);
 
-      SwingUtilities.invokeLater(new Runnable()
+      javax.swing.SwingUtilities.invokeLater(new Runnable()
       {
         @Override
         public void run()
@@ -498,7 +486,9 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI,
                   .setValue(scroller.getHorizontalScrollBar().getMaximum());
         }
       });
+
     }
+
   }
 
   @Override