From 89ac04963c6781065a5342e219396bbd73bdf6e9 Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 1 Oct 2012 08:30:45 +0000 Subject: Moved Mobile BKU URL to configuration file Extracted localizable Strings git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12542 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../java/at/asit/pdfover/gui/DeveloperMain.java | 9 ++ .../src/main/java/at/asit/pdfover/gui/Main.java | 9 +- .../main/java/at/asit/pdfover/gui/MainWindow.java | 29 +----- .../pdfover/gui/cliarguments/ArgumentHandler.java | 50 ++++++---- .../asit/pdfover/gui/cliarguments/BKUArgument.java | 7 +- .../gui/cliarguments/ConfigFileArgument.java | 8 +- .../pdfover/gui/cliarguments/EmblemArgument.java | 7 +- .../pdfover/gui/cliarguments/HelpArgument.java | 5 +- .../gui/cliarguments/InputDocumentArgument.java | 80 +++++++++++++++ .../gui/cliarguments/OutputFolderArgument.java | 10 +- .../pdfover/gui/cliarguments/PasswordArgument.java | 7 +- .../gui/cliarguments/PhoneNumberArgument.java | 7 +- .../gui/cliarguments/ProxyHostArgument.java | 10 +- .../gui/cliarguments/ProxyPortArgument.java | 7 +- .../composites/AdvancedConfigurationComposite.java | 47 ++++++--- .../gui/composites/BKUSelectionComposite.java | 9 +- .../gui/composites/ConfigurationComposite.java | 15 +-- .../gui/composites/DataSourceSelectComposite.java | 15 +-- .../composites/MobileBKUEnterNumberComposite.java | 11 ++- .../gui/composites/MobileBKUEnterTANComposite.java | 28 ++++-- .../pdfover/gui/composites/OutputComposite.java | 15 ++- .../composites/SimpleConfigurationComposite.java | 45 ++++----- .../at/asit/pdfover/gui/controls/ErrorDialog.java | 12 ++- .../pdfover/gui/exceptions/InvalidEmblemFile.java | 13 +-- .../gui/exceptions/InvalidPortException.java | 4 +- .../gui/exceptions/PasswordTooLongException.java | 4 +- .../gui/exceptions/PasswordTooShortException.java | 4 +- .../java/at/asit/pdfover/gui/messages.properties | 109 ++++++++++++++++++++- .../pdfover/gui/workflow/ConfigManipulator.java | 5 + .../asit/pdfover/gui/workflow/ConfigProvider.java | 6 ++ .../pdfover/gui/workflow/ConfigProviderImpl.java | 23 +++++ .../pdfover/gui/workflow/StateMachineImpl.java | 22 +---- .../gui/workflow/states/ConfigurationUIState.java | 1 - .../pdfover/gui/workflow/states/LocalBKUState.java | 6 +- .../gui/workflow/states/MobileBKUState.java | 5 +- .../pdfover/gui/workflow/states/OutputState.java | 5 +- .../workflow/states/PrepareConfigurationState.java | 8 +- .../gui/workflow/states/PrepareSigningState.java | 3 +- .../pdfover/gui/workflow/states/SigningState.java | 3 +- .../states/mobilebku/PostSLRequestThread.java | 15 +-- 40 files changed, 467 insertions(+), 211 deletions(-) create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java index 23b14d4c..82bfd2a0 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java @@ -42,6 +42,15 @@ public class DeveloperMain { // Set PDF-AS log4j configuration: //System.setProperty("log4j.configuration", "log4j.properties"); + StringBuilder sb = new StringBuilder(); + + for(int i = 0; i < args.length; i++) { + sb.append(" "); //$NON-NLS-1$ + sb.append(args[i]); + } + + log.debug("Executing arguments are: " + sb.toString()); //$NON-NLS-1$ + StateMachineImpl stateMachine = new StateMachineImpl(args); log.debug("Starting stateMachine ..."); //$NON-NLS-1$ diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java index 1637da75..43762b13 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java @@ -19,6 +19,8 @@ package at.asit.pdfover.gui; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.workflow.StateMachineImpl; + /** * Main entry point for production */ @@ -27,15 +29,18 @@ public class Main { /** * SFL4J Logger instance **/ - @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(Main.class); /** * @param args */ public static void main(String[] args) { - // TODO Auto-generated method stub + StateMachineImpl stateMachine = new StateMachineImpl(args); + log.debug("Starting stateMachine ..."); //$NON-NLS-1$ + + stateMachine.start(); + log.debug("Ended stateMachine ..."); //$NON-NLS-1$ } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index 8a9c217d..1086992b 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -21,7 +21,6 @@ import java.util.EnumMap; import java.util.Map; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; @@ -59,7 +58,6 @@ public class MainWindow { static final Logger log = LoggerFactory.getLogger(MainWindow.class); private Shell shell; - private CLabel lbl_status; private Composite container; private StackLayout stack; StateMachine stateMachine; @@ -116,18 +114,6 @@ public class MainWindow { this.buttonMap = new EnumMap(Buttons.class); } - /** - * Set current status (may be removed in production release) - * - * @param value - */ - public void setStatus(String value) { - if (this.getShell().isDisposed()) { - return; - } - this.lbl_status.setText("[DEBUG]: Current workflow state: " + value); //$NON-NLS-1$ - } - /** * Sets top level composite for stack layout * @@ -252,8 +238,8 @@ public class MainWindow { fd_btn_open.top = new FormAttachment(0); fd_btn_open.left = new FormAttachment(0, 45); this.btn_open.setLayoutData(fd_btn_open); - this.btn_open.setText(Messages.getString("main.open")); //$NON-NLS-1$ - this.btn_open.setToolTipText(Messages.getString("main.open")); //$NON-NLS-1$ + this.btn_open.setText(Messages.getString("common.open")); //$NON-NLS-1$ + this.btn_open.setToolTipText(Messages.getString("common.open")); //$NON-NLS-1$ this.btn_open.addMouseListener(new MouseListener() { @Override @@ -327,22 +313,13 @@ public class MainWindow { this.container = new Composite(getShell(), SWT.RESIZE); FormData fd_composite_1 = new FormData(); - fd_composite_1.bottom = new FormAttachment(100, -25); + fd_composite_1.bottom = new FormAttachment(100, -5); fd_composite_1.right = new FormAttachment(100, -5); fd_composite_1.top = new FormAttachment(0, 50); fd_composite_1.left = new FormAttachment(0, 5); this.container.setLayoutData(fd_composite_1); this.stack = new StackLayout(); this.container.setLayout(this.stack); - - this.lbl_status = new CLabel(getShell(), SWT.NONE); - FormData fd_lblNewLabel = new FormData(); - fd_lblNewLabel.right = new FormAttachment(100, -5); - fd_lblNewLabel.bottom = new FormAttachment(100, -5); - fd_lblNewLabel.top = new FormAttachment(100, -20); - fd_lblNewLabel.left = new FormAttachment(0, 5); - this.lbl_status.setLayoutData(fd_lblNewLabel); - this.lbl_status.setText("DEBUG LABEL!!"); //$NON-NLS-1$ } /** diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java index f43b636c..badf37da 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java @@ -39,71 +39,81 @@ public class ArgumentHandler { .getLogger(ArgumentHandler.class); private Map cliArguments = new HashMap(); - + private StateMachine stateMachine = null; - + private boolean requiredExit = false; - + /** * Constructor - * @param stateMachine + * + * @param stateMachine */ public ArgumentHandler(StateMachine stateMachine) { this.stateMachine = stateMachine; } - + /** * Gets available Arguments + * * @return the list of available arguments */ public Set getArguments() { return new HashSet(this.cliArguments.values()); } - + /** * Adds a CLIArgument to the handler * * @param arg */ public void addCLIArgument(CLIArgument arg) { - if(arg == null) { + if (arg == null) { return; } - + String[] commandOptions = arg.getCommandOptions(); - - if(commandOptions == null) { + + if (commandOptions == null) { return; } - - for(int i = 0; i < commandOptions.length; i++) - { + + for (int i = 0; i < commandOptions.length; i++) { this.cliArguments.put(commandOptions[i], arg); } } - + /** * Handle CLI Arguments * * @param args - * @throws InitializationException + * @throws InitializationException */ public void handleArguments(String[] args) throws InitializationException { - for(int i = 0; i < args.length; i++) { - if(this.cliArguments.containsKey(args[i])) { - this.cliArguments.get(args[i]).handleArgument(args, i, this.stateMachine, this); + + for (int i = 0; i < args.length; i++) { + if (this.cliArguments.containsKey(args[i])) { + i = this.cliArguments.get(args[i]).handleArgument(args, i, + this.stateMachine, this); + } else { + // Assume we got the document we want to sign + if (this.cliArguments.containsKey("-i")) { //$NON-NLS-1$ + i = this.cliArguments.get("-i").handleArgument(args, i-1, //$NON-NLS-1$ + this.stateMachine, this); + } } } } - + /** * Set by an cli argument if it wants the program to exit + * * @param requireExit */ public void setRequireExit(boolean requireExit) { this.requiredExit = requireExit; } - + /** * Checks if one argument required the program to exit again * diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java index 5c039c83..3117780e 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java @@ -15,6 +15,7 @@ */ package at.asit.pdfover.gui.cliarguments; +import at.asit.pdfover.gui.Messages; import at.asit.pdfover.gui.exceptions.InitializationException; import at.asit.pdfover.gui.workflow.ConfigManipulator; import at.asit.pdfover.gui.workflow.StateMachine; @@ -29,7 +30,7 @@ public class BKUArgument extends CLIArgument { */ public BKUArgument() { super( - new String[] { "-b" }, "Select the BKU to use values are: LOCAL, MOBILE (example: -b