From 11b4582b7c2e2d5008931fa5029563efedda37a5 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 31 Oct 2012 16:36:59 +0000 Subject: + ignore option for error dialog + resumeable exception for settings validation git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12754 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../at/asit/pdfover/gui/controls/ErrorDialog.java | 52 ++++++++++++++++------ 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java index 88392d98..7cefb857 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java @@ -30,16 +30,44 @@ public class ErrorDialog { private MessageBox box; /** - * @param parent - * @param message - * @param canRetry + * Message box buttons */ - public ErrorDialog(Shell parent, String message, boolean canRetry) { + public enum ERROR_BUTTONS { + /** + * Display only ok button + */ + OK, + /** + * Display retry and cancel buttons + */ + RETRY_CANCEL, + /** + * Display abort, retry and ignore buttons + */ + ABORT_RETRY_IGNORE + }; + + /** + * @param parent The parent shell + * @param message The error message + * @param button The buttons to be shown + */ + public ErrorDialog(Shell parent, String message, ERROR_BUTTONS button) { + this.initialize(parent, message, button); + } + + private void initialize(Shell parent, String message, ERROR_BUTTONS button) { int boxstyle = SWT.ICON_ERROR ; - if(canRetry) { - boxstyle |= SWT.RETRY| SWT.CANCEL; - } else { + switch(button) { + case OK: boxstyle |= SWT.OK; + break; + case RETRY_CANCEL: + boxstyle |= SWT.RETRY| SWT.CANCEL; + break; + case ABORT_RETRY_IGNORE: + boxstyle |= SWT.RETRY| SWT.ABORT | SWT.IGNORE; + break; } this.box = new MessageBox(parent, boxstyle); @@ -50,13 +78,9 @@ public class ErrorDialog { /** * Open error dialog * - * @return if the user wants to retry the action which caused the error + * @return SWT.OK | SWT.IGNORE | SWT.ABORT | SWT.RETRY | SWT.CANCEL */ - public boolean open() { - int rc = this.box.open(); - if(rc == SWT.RETRY) { - return true; - } - return false; + public int open() { + return this.box.open(); } } -- cgit v1.2.3