summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'trunk')
-rw-r--r--trunk/pdf-over-gui/PDFOver.config2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java44
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java111
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java4
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java138
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java7
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java25
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ErrorState.java122
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java81
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java11
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java12
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java13
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java13
-rw-r--r--trunk/pdf-over-gui/tmp_signed.pdfbin80034 -> 152201 bytes
17 files changed, 344 insertions, 245 deletions
diff --git a/trunk/pdf-over-gui/PDFOver.config b/trunk/pdf-over-gui/PDFOver.config
index e77193d5..aa7a6cb7 100644
--- a/trunk/pdf-over-gui/PDFOver.config
+++ b/trunk/pdf-over-gui/PDFOver.config
@@ -1,5 +1,5 @@
#Configuration file was generated!
-#Wed Sep 05 13:37:44 CEST 2012
+#Mon Sep 10 10:09:04 CEST 2012
OUTPUT_FOLDER=/home/andy/PDF
PROXY_PORT=-1
EMBLEM=/home/andy/fitzek_andreas_l.jpg
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index e3869105..11f0914d 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -273,7 +273,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.performBKUSelectionChanged(bkuvalue);
} catch (Exception ex) {
log.error("Failed to parse BKU value: " + selected, ex); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Invalid BKU selection. Please check.", ex);
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Invalid BKU selection. Please check.", ex, false);
dialog.open();
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index d95bb466..bb6d47a5 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -54,9 +54,9 @@ public class ConfigurationComposite extends StateComposite {
*/
private final class ConfigurationModeSelectionListener implements
SelectionListener {
-
+
/**
- * Constructor
+ * Constructor
*/
public ConfigurationModeSelectionListener() {
// Nothing to do
@@ -117,13 +117,12 @@ public class ConfigurationComposite extends StateComposite {
BaseConfigurationComposite configComposite;
/**
- * configuration container
- * Keeps state for current configuration changes
+ * configuration container Keeps state for current configuration changes
*/
ConfigurationContainer configurationContainer = new ConfigurationContainerImpl();
/**
- * The stack layout
+ * The stack layout
*/
StackLayout compositeStack = new StackLayout();
@@ -290,8 +289,7 @@ public class ConfigurationComposite extends StateComposite {
this.configManipulator
.setDefaultSignaturePosition(new SignaturePosition());
} else {
- this.configManipulator
- .setDefaultSignaturePosition(null);
+ this.configManipulator.setDefaultSignaturePosition(null);
}
this.configManipulator
@@ -311,21 +309,29 @@ public class ConfigurationComposite extends StateComposite {
getShell(),
SWT.NONE,
"Invalid settings are still present. Please check your input.",
- e);
+ e, false);
dialog.open();
return false;
}
- // Save current config to file
- try {
- this.configManipulator.saveCurrentConfiguration();
- } catch (IOException e) {
- log.error("Failed to save configuration to file!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE,
- "Failed to save configuration file!", e);
- dialog.open();
- return false;
- }
- return true;
+
+ boolean status = false;
+ boolean redo = false;
+ do {
+ // Save current config to file
+ try {
+ this.configManipulator.saveCurrentConfiguration();
+ redo = false;
+ status = true;
+ } catch (IOException e) {
+ log.error("Failed to save configuration to file!", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE,
+ "Failed to save configuration file!", e, true);
+ redo = dialog.open();
+
+ //return false;
+ }
+ } while (redo);
+ return status;
}
/**
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java
index c85d046e..798ad7fb 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java
@@ -45,12 +45,71 @@ public class ErrorComposite extends StateComposite {
@Override
public void widgetSelected(SelectionEvent e) {
ErrorComposite.this.userOk = true;
+ ErrorComposite.this.shouldTryToRecover = false;
+ ErrorComposite.this.state.updateStateMachine();
+ }
+ }
+
+ /**
+ *
+ */
+ private final class RetrySelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public RetrySelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ErrorComposite.this.userOk = true;
+ ErrorComposite.this.shouldTryToRecover = true;
ErrorComposite.this.state.updateStateMachine();
}
}
boolean userOk = false;
+ boolean canTryToRecover = false;
+
+ boolean shouldTryToRecover = false;
+
+ /**
+ * Checks if we should try to recover form the error
+ * @return the shouldTryToRecover
+ */
+ public boolean getShouldTryToRecover() {
+ return this.shouldTryToRecover;
+ }
+
+ /**
+ * Gets try to recover
+ * @return can try to recover
+ */
+ public boolean getCanTryToRecover() {
+ return this.canTryToRecover;
+ }
+
+ /**
+ * Sets try to recover
+ * @param value
+ */
+ public void setCanTryToRecover(boolean value) {
+ this.canTryToRecover = value;
+
+ if(this.canTryToRecover) {
+ this.btn_ok.setVisible(false);
+ this.btn_retry.setVisible(true);
+ this.btn_cancel.setVisible(true);
+ this.lbl_title.setText("Recoverable error ocurred");
+ } else {
+ this.btn_ok.setVisible(true);
+ this.btn_retry.setVisible(false);
+ this.btn_cancel.setVisible(false);
+ this.lbl_title.setText("Fatal error ocurred");
+ }
+ }
+
/**
* Checks if the user has clicked OK
* @return whether the user has clicked OK
@@ -61,6 +120,14 @@ public class ErrorComposite extends StateComposite {
private Exception exception;
private Label lbl_message;
+
+ private Button btn_ok;
+
+ private Button btn_retry;
+
+ private Button btn_cancel;
+
+ private Label lbl_title;
/**
@@ -87,21 +154,54 @@ public class ErrorComposite extends StateComposite {
FormData fd_lbl_message = new FormData();
fd_lbl_message.left = new FormAttachment(10, 0);
fd_lbl_message.right = new FormAttachment(90, 0);
- fd_lbl_message.top = new FormAttachment(10, 0);
+ fd_lbl_message.top = new FormAttachment(15, 5);
fd_lbl_message.bottom = new FormAttachment(80, 0);
this.lbl_message.setLayoutData(fd_lbl_message);
//lbl_message.setText(this.exception.getMessage());
- Button btn_ok = new Button(this, SWT.NATIVE | SWT.RESIZE);
- btn_ok.setText("OK");
+ this.btn_ok = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ this.btn_ok.setText("OK");
// Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT);
FormData fd_btn_ok = new FormData();
fd_btn_ok.left = new FormAttachment(45, 0);
fd_btn_ok.right = new FormAttachment(55, 0);
fd_btn_ok.top = new FormAttachment(85, 0);
fd_btn_ok.bottom = new FormAttachment(95, 0);
- btn_ok.setLayoutData(fd_btn_ok);
- btn_ok.addSelectionListener(new OkSelectionListener());
+ this.btn_ok.setLayoutData(fd_btn_ok);
+ this.btn_ok.addSelectionListener(new OkSelectionListener());
+
+ this.btn_retry = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ this.btn_retry.setText("OK");
+ // Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ FormData fd_btn_retry = new FormData();
+ fd_btn_retry.left = new FormAttachment(30, 0);
+ fd_btn_retry.right = new FormAttachment(50, -5);
+ fd_btn_retry.top = new FormAttachment(85, 0);
+ fd_btn_retry.bottom = new FormAttachment(95, 0);
+ this.btn_retry.setLayoutData(fd_btn_retry);
+ this.btn_retry.addSelectionListener(new RetrySelectionListener());
+ this.btn_retry.setVisible(false);
+
+ this.btn_cancel = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ this.btn_cancel.setText("Cancel");
+ // Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ FormData fd_btn_cancel = new FormData();
+ fd_btn_cancel.left = new FormAttachment(50, 5);
+ fd_btn_cancel.right = new FormAttachment(80, 0);
+ fd_btn_cancel.top = new FormAttachment(85, 0);
+ fd_btn_cancel.bottom = new FormAttachment(95, 0);
+ this.btn_cancel.setLayoutData(fd_btn_cancel);
+ this.btn_cancel.addSelectionListener(new OkSelectionListener());
+ this.btn_cancel.setVisible(false);
+
+ this.lbl_title = new Label(this, SWT.NONE);
+ FormData fd_lbl_title = new FormData();
+ fd_lbl_title.left = new FormAttachment(10, 0);
+ fd_lbl_title.right = new FormAttachment(90, 0);
+ fd_lbl_title.top = new FormAttachment(0, 5);
+ fd_lbl_title.bottom = new FormAttachment(15, -5);
+ this.lbl_title.setLayoutData(fd_lbl_title);
+ this.lbl_title.setText(""); //$NON-NLS-1$
}
@Override
@@ -116,5 +216,4 @@ public class ErrorComposite extends StateComposite {
public void doLayout() {
// Nothing to do
}
-
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
index afa2a2e7..9cdabe23 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
@@ -118,7 +118,7 @@ public class OutputComposite extends StateComposite {
}
} else {
log.error("OutputComposite:OpenSelectionListener:widgetSelected -> source is null!!"); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to get signed document.", "");
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to get signed document.", "", false);
dialog.open();
}
} catch (Exception ex) {
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
index a0977b9e..6bac14ec 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
@@ -226,7 +226,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
plainEmblemSetter(filename);
} catch (Exception ex) {
log.error("processEmblemChanged: ", ex); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to load the emblem", ex);
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to load the emblem", ex, false);
dialog.open();
}
}
@@ -728,7 +728,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.btnUseImage.setSelection(true);
} catch (Exception e1) {
log.error("Failed to load emblem: ", e1); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to load emblem.", e1);
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, "Failed to load emblem.", e1, false);
dialog.open();
}
}
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 1025c1fe..c6f7c19a 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
@@ -45,12 +45,14 @@ public class ErrorDialog extends Dialog {
* @param style
* @param message
* @param exception
+ * @param canRetry
*/
public ErrorDialog(Shell parent, int style, String message,
- Throwable exception) {
+ Throwable exception,
+ boolean canRetry) {
super(parent, style);
this.message = message;
-
+ this.canRetry = canRetry;
final StringBuilder result = new StringBuilder();
result.append(exception.getLocalizedMessage());
final String NEW_LINE = System.getProperty("line.separator"); //$NON-NLS-1$
@@ -71,15 +73,22 @@ public class ErrorDialog extends Dialog {
* @param style
* @param message
* @param details
+ * @param canRetry
*/
- public ErrorDialog(Shell parent, int style, String message, String details) {
+ public ErrorDialog(Shell parent, int style, String message, String details,
+ boolean canRetry) {
super(parent, style);
this.message = message;
this.details = details;
+ this.canRetry = canRetry;
}
private String message = null;
+ private boolean canRetry = false;
+
+ private boolean doRetry = false;
+
private String details = null;
/**
@@ -91,8 +100,9 @@ public class ErrorDialog extends Dialog {
/**
* Open error dialog
+ * @return if the user wants to retry the action which caused the error
*/
- public void open() {
+ public boolean open() {
Shell parent = getParent();
final Shell shell = new Shell(parent, SWT.DIALOG_TRIM
| SWT.APPLICATION_MODAL);
@@ -131,39 +141,91 @@ public class ErrorDialog extends Dialog {
fd_group.left = new FormAttachment(lblErrorImage, 5);
group.setLayoutData(fd_group);
group.setText("Details");
- 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("Ok");
-
+
+ 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("Ok");
+ } 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("Cancel");
+
+ 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("Retry");
+ }
shell.pack();
shell.open();
shell.pack();
@@ -172,5 +234,7 @@ public class ErrorDialog extends Dialog {
if (!display.readAndDispatch())
display.sleep();
}
+
+ return this.doRetry;
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
index 26bd3e1f..39aab13d 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
@@ -16,6 +16,7 @@
package at.asit.pdfover.gui.workflow;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
import at.asit.pdfover.gui.workflow.states.State;
@@ -38,4 +39,10 @@ public interface GUIProvider {
* @param composite the composite
*/
public void display(final Composite composite);
+
+ /**
+ * Gets the main window shell
+ * @return the main window shell
+ */
+ public Shell getMainShell();
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
index ece1cf7f..44ffd7f4 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
@@ -18,7 +18,7 @@ package at.asit.pdfover.gui.workflow;
//Imports
import java.lang.reflect.Constructor;
-import org.eclipse.swt.SWTException;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -26,7 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindow;
-import at.asit.pdfover.gui.workflow.states.ErrorState;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState;
import at.asit.pdfover.gui.workflow.states.State;
@@ -86,9 +86,12 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
current.run();
} catch (Exception e) {
log.error("StateMachine update: ", e); //$NON-NLS-1$
- ErrorState errorState = new ErrorState(this);
- errorState.setException(e);
- jumpToState(errorState);
+ ErrorDialog errorState = new ErrorDialog(this.getMainShell(),
+ SWT.NONE, "Unexpected Error", e, false);
+ //errorState.setException(e);
+ //jumpToState(errorState);
+ errorState.open();
+ this.exit();
}
if (this.exit) {
@@ -355,4 +358,16 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
public ConfigManipulator getConfigManipulator() {
return this.configProvider;
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.GUIProvider#getMainShell()
+ */
+ @Override
+ public Shell getMainShell() {
+ if(this.shell == null) {
+ this.createMainWindow();
+ }
+
+ return this.shell;
+ }
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ErrorState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ErrorState.java
deleted file mode 100644
index dd240616..00000000
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ErrorState.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.workflow.states;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.composites.ErrorComposite;
-import at.asit.pdfover.gui.workflow.StateMachine;
-
-/**
- *
- */
-public class ErrorState extends State {
- /**
- * @param stateMachine
- */
- public ErrorState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- private Exception exception;
-
- private State recoverState = null;
-
- /**
- * @param recoverState the recoverState to set
- */
- public void setRecoverState(State recoverState) {
- this.recoverState = recoverState;
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(ErrorState.class);
-
- private ErrorComposite errorComposite = null;
-
- private ErrorComposite getComposite() {
- if (this.errorComposite == null) {
- this.errorComposite =
- this.stateMachine.getGUIProvider().createComposite(ErrorComposite.class, SWT.RESIZE, this);
- }
-
- return this.errorComposite;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#run()
- */
- @Override
- public void run() {
- ErrorComposite errorComposite = this.getComposite();
-
- if(this.exception != null && !errorComposite.isUserOk()) {
- // Display Exception ....
- this.errorComposite.setException(this.exception);
-
- this.stateMachine.getGUIProvider().display(errorComposite);
- return;
- }
-
- // User was informed!
- if(this.recoverState != null) {
- // see if we can recover!
- this.setNextState(this.recoverState);
- } else {
- // we cannot recover exit!
- this.stateMachine.exit();
- }
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.errorComposite != null)
- this.errorComposite.dispose();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#updateMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- // Stay in previous state behavior
- }
-
- /**
- * Gets the Exception
- * @return the exception
- */
- public Exception getException() {
- return this.exception;
- }
-
- /**
- * Sets the Exception
- * @param exception the exception to set
- */
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
-}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index 9962d968..58e957b9 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -37,32 +37,32 @@ import at.asit.pdfover.signator.SLResponse;
* Logical state for performing the BKU Request to a local BKU
*/
public class LocalBKUState extends State {
-
+
/**
* HTTP Response server HEADER
*/
public final static String BKU_REPSONE_HEADER_SERVER = "server"; //$NON-NLS-1$
-
+
/**
* HTTP Response user-agent HEADER
*/
public final static String BKU_REPSONE_HEADER_USERAGENT = "user-agent"; //$NON-NLS-1$
-
+
/**
* HTTP Response SignatureLayout HEADER
*/
public final static String BKU_REPSONE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; //$NON-NLS-1$
-
+
/**
* TODO: move to a better location ...
*/
public static final String PDF_OVER_USER_AGENT_STRING = "PDF-Over 4.0"; //$NON-NLS-1$
-
+
/**
*
*/
private final class SignLocalBKUThread implements Runnable {
-
+
private LocalBKUState state;
/**
@@ -81,44 +81,45 @@ public class LocalBKUState extends State {
String sl_request = request.getBase64Request();
HttpClient client = new HttpClient();
-
PostMethod method = new PostMethod(
"http://127.0.0.1:3495/http-security-layer-request"); //$NON-NLS-1$
-
+
log.debug("SL REQUEST: " + sl_request); //$NON-NLS-1$
-
+
method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
-
+
int returnCode = client.executeMethod(method);
-
- if(returnCode == HttpStatus.SC_OK)
- {
+
+ if (returnCode == HttpStatus.SC_OK) {
String server = ""; //$NON-NLS-1$
String userAgent = ""; //$NON-NLS-1$
String signatureLayout = ""; //$NON-NLS-1$
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_SERVER) != null)
- {
- server = method.getResponseHeader(BKU_REPSONE_HEADER_SERVER).getValue();
+
+ if (method.getResponseHeader(BKU_REPSONE_HEADER_SERVER) != null) {
+ server = method.getResponseHeader(
+ BKU_REPSONE_HEADER_SERVER).getValue();
}
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT) != null)
- {
- userAgent = method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT).getValue();
+
+ if (method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT) != null) {
+ userAgent = method.getResponseHeader(
+ BKU_REPSONE_HEADER_USERAGENT).getValue();
}
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT) != null)
- {
- signatureLayout = method.getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT).getValue();
+
+ if (method
+ .getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT) != null) {
+ signatureLayout = method.getResponseHeader(
+ BKU_REPSONE_HEADER_SIGNATURE_LAYOUT).getValue();
}
-
+
String response = method.getResponseBodyAsString();
log.debug("SL Response: " + response); //$NON-NLS-1$
- SLResponse slResponse = new SLResponse(response, server, userAgent, signatureLayout);
+ SLResponse slResponse = new SLResponse(response, server,
+ userAgent, signatureLayout);
this.state.signingState.setSignatureResponse(slResponse);
} else {
- this.state.threadException = new HttpException(method.getResponseBodyAsString());
+ this.state.threadException = new HttpException(
+ method.getResponseBodyAsString());
}
} catch (Exception e) {
@@ -141,13 +142,12 @@ public class LocalBKUState extends State {
/**
* SLF4J Logger instance
**/
- static final Logger log = LoggerFactory
- .getLogger(LocalBKUState.class);
+ static final Logger log = LoggerFactory.getLogger(LocalBKUState.class);
at.asit.pdfover.signator.SigningState signingState;
Exception threadException = null;
-
+
/*
* (non-Javadoc)
*
@@ -161,22 +161,27 @@ public class LocalBKUState extends State {
this.signingState = status.getSigningState();
- if (!this.signingState.hasSignatureResponse() &&
- this.threadException == null
- ) {
+ if (!this.signingState.hasSignatureResponse()
+ && this.threadException == null) {
Thread t = new Thread(new SignLocalBKUThread(this));
t.start();
return;
}
- if(this.threadException != null) {
- ErrorDialog dialog = new ErrorDialog(Display.getCurrent().getActiveShell(), SWT.NONE, "Please check if a local BKU is running", this.threadException);
- dialog.open();
+ if (this.threadException != null) {
+ ErrorDialog dialog = new ErrorDialog(
+ this.stateMachine.getGUIProvider().getMainShell(), SWT.NONE,
+ "Please check if a local BKU is running",
+ this.threadException, true);
+ if (!dialog.open()) {
+ this.stateMachine.exit();
+ return;
+ }
this.threadException = null;
this.run();
return;
}
-
+
// OK
this.setNextState(new SigningState(this.stateMachine));
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index f39deada..ed6d675f 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -25,6 +25,7 @@ import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.composites.MobileBKUEnterNumberComposite;
import at.asit.pdfover.gui.composites.MobileBKUEnterTANComposite;
import at.asit.pdfover.gui.composites.WaitingComposite;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUCommunicationState;
import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUStatus;
@@ -148,9 +149,13 @@ public class MobileBKUState extends State {
MobileBKUStatus mobileStatus = this.getStatus();
if (this.threadException != null) {
- ErrorState error = new ErrorState(this.stateMachine);
- error.setException(this.threadException);
- this.setNextState(error);
+ ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
+ SWT.NONE,
+ "Unexpected Error", this.threadException, false);
+ //error.setException(this.threadException);
+ //this.setNextState(error);
+ error.open();
+ this.stateMachine.exit();
return;
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
index a1748287..5a42d3cc 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
@@ -89,7 +89,7 @@ public class OutputState extends State {
output.close();
} catch (IOException e) {
log.error("Failed to save signed document to configured output folder.", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(outputComposite.getShell(), SWT.NONE, "Failed to save signed document to configured output folder.", e);
+ ErrorDialog dialog = new ErrorDialog(outputComposite.getShell(), SWT.NONE, "Failed to save signed document to configured output folder.", e, false);
dialog.open();
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index a1de09d0..3cf0861f 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,6 +30,7 @@ import at.asit.pdfover.gui.cliarguments.BKUArgument;
import at.asit.pdfover.gui.cliarguments.ConfigFileArgument;
import at.asit.pdfover.gui.cliarguments.HelpArgument;
import at.asit.pdfover.gui.cliarguments.PhoneNumberArgument;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.exceptions.InitializationException;
import at.asit.pdfover.gui.workflow.ConfigManipulator;
import at.asit.pdfover.gui.workflow.StateMachine;
@@ -143,9 +145,13 @@ public class PrepareConfigurationState extends State {
} catch (InitializationException e) {
log.error("Failed to initialize: ", e); //$NON-NLS-1$
- ErrorState error = new ErrorState(this.stateMachine);
- error.setException(e);
- this.setNextState(error);
+ ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
+ SWT.NONE, "Initialization failed. Please check your configuration.",
+ e, false);
+ //error.setException(e);
+ //this.setNextState(error);
+ error.open();
+ this.stateMachine.exit();
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
index af6cc3bd..4ed59e5a 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.composites.WaitingComposite;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.workflow.ConfigProvider;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
@@ -137,9 +138,15 @@ public class PrepareSigningState extends State {
}
if(this.threadException != null) {
- ErrorState error = new ErrorState(this.stateMachine);
- error.setException(this.threadException);
- this.setNextState(error);
+ ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
+ SWT.NONE, "Failed to prepare document for signature.", this.threadException,
+ true);
+ this.threadException = null;
+ if(error.open()) {
+ this.stateMachine.update();
+ } else {
+ this.stateMachine.exit();
+ }
return;
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
index 413f125c..37877f12 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
@@ -16,9 +16,11 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.signator.Signer;
@@ -84,9 +86,14 @@ public class SigningState extends State {
}
if(this.threadException != null) {
- ErrorState error = new ErrorState(this.stateMachine);
- error.setException(this.threadException);
- this.setNextState(error);
+ ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
+ SWT.NONE, "Signature error", this.threadException, true);
+ this.threadException = null;
+ if(error.open()) {
+ this.stateMachine.update();
+ } else {
+ this.stateMachine.exit();
+ }
return;
}
diff --git a/trunk/pdf-over-gui/tmp_signed.pdf b/trunk/pdf-over-gui/tmp_signed.pdf
index 6e7d781a..92391de4 100644
--- a/trunk/pdf-over-gui/tmp_signed.pdf
+++ b/trunk/pdf-over-gui/tmp_signed.pdf
Binary files differ