From 2adb61249ec1a084c09ec0aa9e8297126aa4871c Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 31 Oct 2012 16:36:31 +0000 Subject: + resolved conflicts + simplified Error Dialog + Change emblem config git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12683 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../at/asit/pdfover/gui/controls/ErrorDialog.java | 206 +++++++++++++-------- 1 file changed, 126 insertions(+), 80 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 017de3ef..6d04b33f 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 @@ -42,16 +42,18 @@ import at.asit.pdfover.gui.Messages; * */ public class ErrorDialog extends Dialog { + + private static final boolean VERBOSE_ERROR = false; + /** * @param parent * @param style * @param message * @param exception - * @param canRetry + * @param canRetry */ public ErrorDialog(Shell parent, int style, String message, - Throwable exception, - boolean canRetry) { + Throwable exception, boolean canRetry) { super(parent, style); this.message = message; this.canRetry = canRetry; @@ -90,7 +92,7 @@ public class ErrorDialog extends Dialog { private boolean canRetry = false; boolean doRetry = false; - + private String details = null; /** @@ -102,6 +104,7 @@ public class ErrorDialog extends Dialog { /** * Open error dialog + * * @return if the user wants to retry the action which caused the error */ public boolean open() { @@ -134,53 +137,106 @@ public class ErrorDialog extends Dialog { lblerrorMessage.setLayoutData(fd_lblerrorMessage); lblerrorMessage.setText(this.message); - Group group = new Group(shell, SWT.NONE); - group.setLayout(new FormLayout()); - FormData fd_group = new FormData(); + if (VERBOSE_ERROR) { - fd_group.right = new FormAttachment(100, -5); - fd_group.top = new FormAttachment(lblerrorMessage, 5); - fd_group.left = new FormAttachment(lblErrorImage, 5); - group.setLayoutData(fd_group); - group.setText(Messages.getString("error.Details")); //$NON-NLS-1$ + Group group = new Group(shell, SWT.NONE); + group.setLayout(new FormLayout()); + FormData fd_group = new FormData(); - if (!this.canRetry) { + fd_group.right = new FormAttachment(100, -5); + fd_group.top = new FormAttachment(lblerrorMessage, 5); + fd_group.left = new FormAttachment(lblErrorImage, 5); + group.setLayoutData(fd_group); + group.setText(Messages.getString("error.Details")); //$NON-NLS-1$ + + if (!this.canRetry) { + + Button btnOk = new Button(shell, SWT.NONE); + btnOk.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + shell.dispose(); + } + }); + fd_group.bottom = new FormAttachment(btnOk, -5); + + ScrolledComposite scrolledComposite = new ScrolledComposite( + group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + FormData fd_scrolledComposite = new FormData(); + fd_scrolledComposite.top = new FormAttachment(0, 5); + fd_scrolledComposite.left = new FormAttachment(0, 5); + fd_scrolledComposite.bottom = new FormAttachment(100, -5); + fd_scrolledComposite.right = new FormAttachment(100, -5); + scrolledComposite.setLayoutData(fd_scrolledComposite); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + + Label lblDetails = new Label(scrolledComposite, SWT.NONE); + + lblDetails.setText(this.details); + + scrolledComposite.setContent(lblDetails); + scrolledComposite.setMinSize(lblDetails.computeSize( + SWT.DEFAULT, SWT.DEFAULT)); + FormData fd_btnOk = new FormData(); + fd_btnOk.bottom = new FormAttachment(100, -5); + fd_btnOk.right = new FormAttachment(100, -5); + btnOk.setLayoutData(fd_btnOk); + btnOk.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ + } else { + Button btnCancel = new Button(shell, SWT.NONE); + Button btnRetry = new Button(shell, SWT.NONE); + + btnCancel.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + shell.dispose(); + } + }); + + btnRetry.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ErrorDialog.this.doRetry = true; + shell.dispose(); + } + }); + fd_group.bottom = new FormAttachment(btnCancel, -5); + + ScrolledComposite scrolledComposite = new ScrolledComposite( + group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + FormData fd_scrolledComposite = new FormData(); + fd_scrolledComposite.top = new FormAttachment(0, 5); + fd_scrolledComposite.left = new FormAttachment(0, 5); + fd_scrolledComposite.bottom = new FormAttachment(100, -5); + fd_scrolledComposite.right = new FormAttachment(100, -5); + scrolledComposite.setLayoutData(fd_scrolledComposite); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + + Label lblDetails = new Label(scrolledComposite, SWT.NONE); + + lblDetails.setText(this.details); + + scrolledComposite.setContent(lblDetails); + scrolledComposite.setMinSize(lblDetails.computeSize( + SWT.DEFAULT, SWT.DEFAULT)); + FormData fd_btnCancel = new FormData(); + fd_btnCancel.bottom = new FormAttachment(100, -5); + fd_btnCancel.right = new FormAttachment(100, -5); + btnCancel.setLayoutData(fd_btnCancel); + btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ + + FormData fd_btnRetry = new FormData(); + fd_btnRetry.bottom = new FormAttachment(100, -5); + fd_btnRetry.right = new FormAttachment(btnCancel, -10); + btnRetry.setLayoutData(fd_btnRetry); + btnRetry.setText(Messages.getString("error.Retry")); //$NON-NLS-1$ + } - Button btnOk = new Button(shell, SWT.NONE); - btnOk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - fd_group.bottom = new FormAttachment(btnOk, -5); - - ScrolledComposite scrolledComposite = new ScrolledComposite(group, - SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - FormData fd_scrolledComposite = new FormData(); - fd_scrolledComposite.top = new FormAttachment(0, 5); - fd_scrolledComposite.left = new FormAttachment(0, 5); - fd_scrolledComposite.bottom = new FormAttachment(100, -5); - fd_scrolledComposite.right = new FormAttachment(100, -5); - scrolledComposite.setLayoutData(fd_scrolledComposite); - scrolledComposite.setExpandHorizontal(true); - scrolledComposite.setExpandVertical(true); - - Label lblDetails = new Label(scrolledComposite, SWT.NONE); - - lblDetails.setText(this.details); - - scrolledComposite.setContent(lblDetails); - scrolledComposite.setMinSize(lblDetails.computeSize(SWT.DEFAULT, - SWT.DEFAULT)); - FormData fd_btnOk = new FormData(); - fd_btnOk.bottom = new FormAttachment(100, -5); - fd_btnOk.right = new FormAttachment(100, -5); - btnOk.setLayoutData(fd_btnOk); - btnOk.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ } else { + Button btnCancel = new Button(shell, SWT.NONE); - Button btnRetry = new Button(shell, SWT.NONE); btnCancel.addSelectionListener(new SelectionAdapter() { @Override @@ -189,44 +245,34 @@ public class ErrorDialog extends Dialog { } }); - btnRetry.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ErrorDialog.this.doRetry = true; - shell.dispose(); - } - }); - fd_group.bottom = new FormAttachment(btnCancel, -5); - - ScrolledComposite scrolledComposite = new ScrolledComposite(group, - SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - FormData fd_scrolledComposite = new FormData(); - fd_scrolledComposite.top = new FormAttachment(0, 5); - fd_scrolledComposite.left = new FormAttachment(0, 5); - fd_scrolledComposite.bottom = new FormAttachment(100, -5); - fd_scrolledComposite.right = new FormAttachment(100, -5); - scrolledComposite.setLayoutData(fd_scrolledComposite); - scrolledComposite.setExpandHorizontal(true); - scrolledComposite.setExpandVertical(true); - - Label lblDetails = new Label(scrolledComposite, SWT.NONE); - - lblDetails.setText(this.details); - - scrolledComposite.setContent(lblDetails); - scrolledComposite.setMinSize(lblDetails.computeSize(SWT.DEFAULT, - SWT.DEFAULT)); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -5); fd_btnCancel.right = new FormAttachment(100, -5); + fd_btnCancel.top = new FormAttachment(lblerrorMessage, 10); btnCancel.setLayoutData(fd_btnCancel); - btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ + btnCancel.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ + - FormData fd_btnRetry = new FormData(); - fd_btnRetry.bottom = new FormAttachment(100, -5); - fd_btnRetry.right = new FormAttachment(btnCancel, -10); - btnRetry.setLayoutData(fd_btnRetry); - btnRetry.setText(Messages.getString("error.Retry")); //$NON-NLS-1$ + if(this.canRetry) { + btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ + + Button btnRetry = new Button(shell, SWT.NONE); + + + btnRetry.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ErrorDialog.this.doRetry = true; + shell.dispose(); + } + }); + FormData fd_btnRetry = new FormData(); + + fd_btnRetry.bottom = new FormAttachment(100, -5); + fd_btnRetry.right = new FormAttachment(btnCancel, -10); + btnRetry.setLayoutData(fd_btnRetry); + btnRetry.setText(Messages.getString("error.Retry")); //$NON-NLS-1$ + } } shell.pack(); shell.open(); @@ -236,7 +282,7 @@ public class ErrorDialog extends Dialog { if (!display.readAndDispatch()) display.sleep(); } - + return this.doRetry; } } -- cgit v1.2.3