From c543db8bc1a31098d2c3ce464d21401fb7ff390f Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 17 Dec 2018 16:23:13 +0000 Subject: [PATCH] JAL-3068 tidy status bar messaging --- src/jalview/gui/ImageExporter.java | 12 +++++++---- src/jalview/io/BioJsHTMLOutput.java | 8 +------ src/jalview/io/HTMLOutput.java | 31 ++++++++++++++++------------ src/jalview/io/HtmlSvgOutput.java | 39 +---------------------------------- 4 files changed, 28 insertions(+), 62 deletions(-) diff --git a/src/jalview/gui/ImageExporter.java b/src/jalview/gui/ImageExporter.java index 4c2c8ba..51d7d82 100644 --- a/src/jalview/gui/ImageExporter.java +++ b/src/jalview/gui/ImageExporter.java @@ -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()); diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 11436d3..9db3df2 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -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"; - } - } diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index f7179cf..54e7e4b 100644 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -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 diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index a943a81..d653e4b 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -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"; - } } -- 1.7.10.2