From 9b5b3fbdd89938d7b79305dd6f3793dba2919992 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 17 Jun 2016 15:29:54 +0100 Subject: [PATCH] JAL-1976 clear message if export is cancelled at 'Rendering options' stage. --- src/jalview/io/HtmlSvgOutput.java | 2 ++ src/jalview/util/ImageMaker.java | 64 +++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 058384a..4e1b261 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -137,6 +137,8 @@ public class HtmlSvgOutput if (renderStyle == null || svgOption.cancelled) { + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", "HTML")); return; } } diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java index 10ea153..fcea21d 100755 --- a/src/jalview/util/ImageMaker.java +++ b/src/jalview/util/ImageMaker.java @@ -54,6 +54,12 @@ public class ImageMaker TYPE type; + private IProgressIndicator pIndicator; + + private long pSessionId; + + private boolean headless; + public enum TYPE { EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()), PNG( @@ -94,17 +100,14 @@ public class ImageMaker int height, File file, String fileTitle, IProgressIndicator pIndicator, long pSessionId, boolean headless) { + this.pIndicator = pIndicator; this.type = type; - + this.pSessionId = pSessionId; + this.headless = headless; if (file == null) { - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar( - MessageManager.formatMessage( - "status.waiting_for_user_to_select_output_file", - type.name), pSessionId); - } + setProgressMessage(MessageManager.formatMessage( + "status.waiting_for_user_to_select_output_file", type.name)); JalviewFileChooser chooser; chooser = type.getChooser(); chooser.setFileView(new jalview.io.JalviewFileView()); @@ -120,12 +123,8 @@ public class ImageMaker } else { - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar(MessageManager.formatMessage( - "status.cancelled_image_export_operation", type.name), - pSessionId); - } + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", type.name)); } } @@ -134,10 +133,9 @@ public class ImageMaker try { out = new FileOutputStream(file); - pIndicator.setProgressBar(null, pSessionId); - pIndicator.setProgressBar(MessageManager.formatMessage( - "status.exporting_alignment_as_x_file", type.getName()), - pSessionId); + setProgressMessage(null); + setProgressMessage(MessageManager.formatMessage( + "status.exporting_alignment_as_x_file", type.getName())); if (type == TYPE.SVG) { setupSVG(width, height, fileTitle); @@ -150,19 +148,13 @@ public class ImageMaker { setupPNG(width, height); } - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar( -MessageManager.formatMessage( - "status.export_complete", type.getName()), - pSessionId); - } + } catch (Exception ex) { System.out.println("Error creating " + type.getName() + " file."); - pIndicator.setProgressBar(MessageManager.formatMessage( - "info.error_creating_file", type.getName()), pSessionId); + setProgressMessage(MessageManager.formatMessage( + "info.error_creating_file", type.getName())); } } } @@ -218,6 +210,8 @@ MessageManager.formatMessage( if (renderStyle == null || eps.cancelled) { + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", "EPS")); return; } } @@ -237,6 +231,8 @@ MessageManager.formatMessage( pg.setAccurateTextMode(accurateText); graphics = pg; + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); } catch (Exception ex) { } @@ -249,6 +245,8 @@ MessageManager.formatMessage( Graphics2D ig2 = (Graphics2D) graphics; ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); } @@ -272,6 +270,8 @@ MessageManager.formatMessage( if (renderStyle == null || svgOption.cancelled) { + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", "SVG")); return; } } @@ -282,6 +282,8 @@ MessageManager.formatMessage( SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR); } + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); graphics = g2; } @@ -311,6 +313,14 @@ MessageManager.formatMessage( "Encapsulated Postscript"); } + private void setProgressMessage(String message) + { + if (pIndicator != null && !headless) + { + pIndicator.setProgressBar(message, pSessionId); + } + } + static JalviewFileChooser getSVGChooser() { if (Jalview.isHeadlessMode()) -- 1.7.10.2