diff options
Diffstat (limited to 'pdf-over-gui')
11 files changed, 143 insertions, 134 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java index 14d06d47..da928c15 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -51,7 +51,7 @@ public class BKUSelectionState extends State { private BKUSelectionComposite getSelectionComposite() { if (this.selectionComposite == null) { this.selectionComposite = - this.stateMachine.getGUIProvider().createComposite(BKUSelectionComposite.class, SWT.RESIZE, this); + getStateMachine().getGUIProvider().createComposite(BKUSelectionComposite.class, SWT.RESIZE, this); } return this.selectionComposite; @@ -59,12 +59,12 @@ public class BKUSelectionState extends State { @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if (!(status.getPreviousState() instanceof BKUSelectionState) && !(status.getPreviousState() instanceof PositioningState)) { status.setBKU(BKUs.NONE); } else if((status.getPreviousState() instanceof PositioningState)) { - ConfigProvider config = this.stateMachine.getConfigProvider(); + ConfigProvider config = getStateMachine().getConfigProvider(); status.setBKU(config.getDefaultBKU()); } @@ -72,7 +72,7 @@ public class BKUSelectionState extends State { BKUSelectionComposite selection = this .getSelectionComposite(); - this.stateMachine.getGUIProvider().display(selection); + getStateMachine().getGUIProvider().display(selection); selection.layout(); status.setBKU(selection.getSelected()); @@ -81,7 +81,7 @@ public class BKUSelectionState extends State { return; } } - this.setNextState(new PrepareSigningState(this.stateMachine)); + this.setNextState(new PrepareSigningState(getStateMachine())); } /* (non-Javadoc) @@ -98,7 +98,7 @@ public class BKUSelectionState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java index 47c21063..4651ddf5 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java @@ -43,10 +43,10 @@ public class ConfigurationUIState extends State { private ConfigurationComposite getConfigurationComposite() { if (this.configurationComposite == null) { this.configurationComposite = - this.stateMachine.getGUIProvider().createComposite(ConfigurationComposite.class, SWT.RESIZE, this); - this.configurationComposite.setConfigManipulator(this.stateMachine.getConfigManipulator()); - this.configurationComposite.setConfigProvider(this.stateMachine.getPersistentConfigProvider()); - this.configurationComposite.setSigner(this.stateMachine.getPDFSigner()); + getStateMachine().getGUIProvider().createComposite(ConfigurationComposite.class, SWT.RESIZE, this); + this.configurationComposite.setConfigManipulator(getStateMachine().getConfigManipulator()); + this.configurationComposite.setConfigProvider(getStateMachine().getPersistentConfigProvider()); + this.configurationComposite.setSigner(getStateMachine().getPDFSigner()); } return this.configurationComposite; @@ -65,11 +65,11 @@ public class ConfigurationUIState extends State { */ @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); ConfigurationComposite config = this.getConfigurationComposite(); - this.stateMachine.getGUIProvider().display(config); + getStateMachine().getGUIProvider().display(config); if(config.isUserDone()) { @@ -95,7 +95,7 @@ public class ConfigurationUIState extends State { @Override public void updateMainWindowBehavior() { // Leave the state as it is - MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); behavior.setMainBarVisible(false); } @@ -103,6 +103,6 @@ public class ConfigurationUIState extends State { * Triggers to reload the resources */ public void reloadResources() { - this.stateMachine.getGUIProvider().reloadResources(); + getStateMachine().getGUIProvider().reloadResources(); } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java index 697821ad..c9833c87 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java @@ -169,7 +169,7 @@ public class LocalBKUState extends State { // this.state.threadException = e; } finally { - this.state.stateMachine.invokeUpdate(); + this.state.getStateMachine().invokeUpdate(); } } @@ -195,7 +195,7 @@ public class LocalBKUState extends State { */ @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); this.signingState = status.getSigningState(); @@ -208,12 +208,12 @@ public class LocalBKUState extends State { if (this.threadException != null) { ErrorDialog dialog = new ErrorDialog( - this.stateMachine.getGUIProvider().getMainShell(), + getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.LocalBKU"), //$NON-NLS-1$ BUTTONS.RETRY_CANCEL); if (dialog.open() != SWT.RETRY) { - //this.stateMachine.exit(); - this.setNextState(new BKUSelectionState(this.stateMachine)); + //getStateMachine().exit(); + this.setNextState(new BKUSelectionState(getStateMachine())); return; } this.threadException = null; @@ -222,7 +222,7 @@ public class LocalBKUState extends State { } // OK - this.setNextState(new SigningState(this.stateMachine)); + this.setNextState(new SigningState(getStateMachine())); } /* @@ -242,7 +242,7 @@ public class LocalBKUState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus() + MainWindowBehavior behavior = getStateMachine().getStatus() .getBehavior(); behavior.reset(); behavior.setActive(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 23463e6f..7df640de 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -49,15 +49,15 @@ public class MobileBKUState extends State { */ public MobileBKUState(StateMachine stateMachine) { super(stateMachine); - switch(this.stateMachine.getConfigProvider().getMobileBKUType()) { + switch(getStateMachine().getConfigProvider().getMobileBKUType()) { case A_TRUST: - this.status = new ATrustStatus(this.stateMachine.getConfigProvider()); - this.handler = new ATrustHandler(this, this.stateMachine.getGUIProvider().getMainShell()); + this.status = new ATrustStatus(getStateMachine().getConfigProvider()); + this.handler = new ATrustHandler(this, getStateMachine().getGUIProvider().getMainShell()); break; case IAIK: - this.status = new IAIKStatus(this.stateMachine.getConfigProvider()); - this.handler = new IAIKHandler(this, this.stateMachine.getGUIProvider().getMainShell()); + this.status = new IAIKStatus(getStateMachine().getConfigProvider()); + this.handler = new IAIKHandler(this, getStateMachine().getGUIProvider().getMainShell()); break; } @@ -88,7 +88,7 @@ public class MobileBKUState extends State { private WaitingComposite getWaitingComposite() { if (this.waitingComposite == null) { - this.waitingComposite = this.stateMachine.getGUIProvider() + this.waitingComposite = getStateMachine().getGUIProvider() .createComposite(WaitingComposite.class, SWT.RESIZE, this); } @@ -97,7 +97,7 @@ public class MobileBKUState extends State { private MobileBKUEnterTANComposite getMobileBKUEnterTANComposite() { if (this.mobileBKUEnterTANComposite == null) { - this.mobileBKUEnterTANComposite = this.stateMachine + this.mobileBKUEnterTANComposite = getStateMachine() .getGUIProvider().createComposite( MobileBKUEnterTANComposite.class, SWT.RESIZE, this); } @@ -107,7 +107,7 @@ public class MobileBKUState extends State { private MobileBKUEnterNumberComposite getMobileBKUEnterNumberComposite() { if (this.mobileBKUEnterNumberComposite == null) { - this.mobileBKUEnterNumberComposite = this.stateMachine + this.mobileBKUEnterNumberComposite = getStateMachine() .getGUIProvider().createComposite( MobileBKUEnterNumberComposite.class, SWT.RESIZE, this); @@ -137,7 +137,7 @@ public class MobileBKUState extends State { * @return the mobile BKU URL */ public String getURL() { - return this.stateMachine.getConfigProvider().getMobileBKUURL(); + return getStateMachine().getConfigProvider().getMobileBKUURL(); } /** @@ -181,24 +181,24 @@ public class MobileBKUState extends State { @Override public void run() { - this.signingState = this.stateMachine.getStatus().getSigningState(); + this.signingState = getStateMachine().getStatus().getSigningState(); MobileBKUStatus mobileStatus = this.getStatus(); if (this.threadException != null) { ErrorDialog error = new ErrorDialog( - this.stateMachine.getGUIProvider().getMainShell(), + getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.Unexpected"), BUTTONS.OK); //$NON-NLS-1$ // error.setException(this.threadException); // this.setNextState(error); error.open(); - this.stateMachine.exit(); + getStateMachine().exit(); return; } switch (this.communicationState) { case POST_REQUEST: - this.stateMachine.getGUIProvider().display( + getStateMachine().getGUIProvider().display( this.getWaitingComposite()); Thread postSLRequestThread = new Thread( new PostSLRequestThread(this)); @@ -235,7 +235,7 @@ public class MobileBKUState extends State { mobileStatus.setMobilePassword(ui.getMobilePassword()); // show waiting composite - this.stateMachine.getGUIProvider().display( + getStateMachine().getGUIProvider().display( this.getWaitingComposite()); // post to BKU @@ -266,7 +266,7 @@ public class MobileBKUState extends State { ui.setMobilePassword(mobileStatus.getMobilePassword()); } ui.enableButton(); - this.stateMachine.getGUIProvider().display(ui); + getStateMachine().getGUIProvider().display(ui); } } break; @@ -284,7 +284,7 @@ public class MobileBKUState extends State { mobileStatus.setTan(tan.getTan()); // show waiting composite - this.stateMachine.getGUIProvider().display( + getStateMachine().getGUIProvider().display( this.getWaitingComposite()); // post to BKU! @@ -303,16 +303,16 @@ public class MobileBKUState extends State { tan.setTries(mobileStatus.getTanTries()); } tan.enableButton(); - this.stateMachine.getGUIProvider().display(tan); + getStateMachine().getGUIProvider().display(tan); } break; case FINAL: - this.setNextState(new SigningState(this.stateMachine)); + this.setNextState(new SigningState(getStateMachine())); break; case CANCEL: - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); break; } } @@ -339,7 +339,7 @@ public class MobileBKUState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus() + MainWindowBehavior behavior = getStateMachine().getStatus() .getBehavior(); behavior.reset(); behavior.setActive(Buttons.OPEN, true); @@ -359,6 +359,6 @@ public class MobileBKUState extends State { * invoke state machine update in main thread */ public void invokeUpdate() { - this.stateMachine.invokeUpdate(); + getStateMachine().invokeUpdate(); } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java index aad6e005..400a516f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java @@ -50,7 +50,7 @@ public class OpenState extends State { private DataSourceSelectComposite getSelectionComposite() { if (this.selectionComposite == null) { this.selectionComposite = - this.stateMachine.getGUIProvider().createComposite(DataSourceSelectComposite.class, SWT.RESIZE, this); + getStateMachine().getGUIProvider().createComposite(DataSourceSelectComposite.class, SWT.RESIZE, this); } return this.selectionComposite; } @@ -60,11 +60,11 @@ public class OpenState extends State { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if (!(status.getPreviousState() instanceof PrepareConfigurationState) && !(status.getPreviousState() instanceof OpenState)) { - ConfigProvider config = this.stateMachine.getConfigProvider(); + ConfigProvider config = getStateMachine().getConfigProvider(); status.setBKU(config.getDefaultBKU()); status.setDocument(null); status.setSignaturePosition(config.getDefaultSignaturePosition()); @@ -74,7 +74,7 @@ public class OpenState extends State { DataSourceSelectComposite selection = this .getSelectionComposite(); - this.stateMachine.getGUIProvider().display(selection); + getStateMachine().getGUIProvider().display(selection); selection.layout(); status.setDocument(selection.getSelected()); @@ -84,8 +84,8 @@ public class OpenState extends State { return; } } - log.debug("Got Datasource: " + this.stateMachine.getStatus().getDocument().getAbsolutePath()); //$NON-NLS-1$ - this.setNextState(new PositioningState(this.stateMachine)); + log.debug("Got Datasource: " + getStateMachine().getStatus().getDocument().getAbsolutePath()); //$NON-NLS-1$ + this.setNextState(new PositioningState(getStateMachine())); } /* (non-Javadoc) @@ -102,7 +102,7 @@ public class OpenState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setActive(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java index df9d1a39..7b88f887 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -46,11 +46,11 @@ public class OutputState extends State { private OutputComposite getOutputComposite() { if (this.outputComposite == null) { - this.outputComposite = this.stateMachine.getGUIProvider() + this.outputComposite = getStateMachine().getGUIProvider() .createComposite(OutputComposite.class, SWT.RESIZE, this); - ConfigProvider config = this.stateMachine.getConfigProvider(); - Status status = this.stateMachine.getStatus(); + ConfigProvider config = getStateMachine().getConfigProvider(); + Status status = getStateMachine().getStatus(); File tmpDir = new File(config.getConfigurationDirectory() + File.separator + "tmp"); //$NON-NLS-1$ @@ -69,7 +69,7 @@ public class OutputState extends State { this.outputComposite.saveDocument(); if (config.getSkipFinish() && this.outputComposite.getSaveSuccessful()) { - this.stateMachine.exit(); + getStateMachine().exit(); } } @@ -78,15 +78,15 @@ public class OutputState extends State { @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if (status.getSignResult() == null) { - ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(), + ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.Signatur"), BUTTONS.RETRY_CANCEL); //$NON-NLS-1$ if(error.open() == SWT.RETRY) { - this.setNextState(new PrepareSigningState(this.stateMachine)); + this.setNextState(new PrepareSigningState(getStateMachine())); } else { - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } return; } @@ -94,7 +94,7 @@ public class OutputState extends State { OutputComposite outputComposite = this.getOutputComposite(); // Display dialog - this.stateMachine.getGUIProvider().display(outputComposite); + getStateMachine().getGUIProvider().display(outputComposite); } /* @@ -105,7 +105,7 @@ public class OutputState extends State { @Override public void cleanUp() { - this.stateMachine.getStatus().setSignResult(null); + getStateMachine().getStatus().setSignResult(null); if (this.outputComposite != null) this.outputComposite.dispose(); @@ -118,7 +118,7 @@ public class OutputState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus() + MainWindowBehavior behavior = getStateMachine().getStatus() .getBehavior(); behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 1d8f2aa7..38de3e22 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -70,7 +70,7 @@ public class PositioningState extends State { private PDFFile getPDFDocument() throws IOException { PDFFile pdf = null; - RandomAccessFile rafile = new RandomAccessFile(this.stateMachine.getStatus().getDocument(), "r"); //$NON-NLS-1$ + RandomAccessFile rafile = new RandomAccessFile(getStateMachine().getStatus().getDocument(), "r"); //$NON-NLS-1$ FileChannel chan = rafile.getChannel(); ByteBuffer buf = chan .map(FileChannel.MapMode.READ_ONLY, 0, chan.size()); @@ -94,25 +94,25 @@ public class PositioningState extends State { private PositioningComposite getPositioningComposite(PDFFile document) { if (this.positionComposite == null) { this.positionComposite = - this.stateMachine.getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); - log.debug("Displaying " + this.stateMachine.getStatus().getDocument()); //$NON-NLS-1$ + getStateMachine().getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); + log.debug("Displaying " + getStateMachine().getStatus().getDocument()); //$NON-NLS-1$ this.positionComposite.displayDocument(document); } // Update possibly changed values - SignatureParameter param = this.stateMachine.getPDFSigner().getPDFSigner().newParameter(); - Emblem emblem = new FileNameEmblem(this.stateMachine.getConfigProvider().getDefaultEmblem()); + SignatureParameter param = getStateMachine().getPDFSigner().getPDFSigner().newParameter(); + Emblem emblem = new FileNameEmblem(getStateMachine().getConfigProvider().getDefaultEmblem()); param.setEmblem(emblem); - if(this.stateMachine.getConfigProvider().getSignatureNote() != null && !this.stateMachine.getConfigProvider().getSignatureNote().isEmpty()) { - param.setProperty("SIG_NOTE", this.stateMachine.getConfigProvider().getSignatureNote()); //$NON-NLS-1$ + if(getStateMachine().getConfigProvider().getSignatureNote() != null && !getStateMachine().getConfigProvider().getSignatureNote().isEmpty()) { + param.setProperty("SIG_NOTE", getStateMachine().getConfigProvider().getSignatureNote()); //$NON-NLS-1$ } - param.setSignatureLanguage(this.stateMachine.getConfigProvider().getSignLocale().getLanguage()); + param.setSignatureLanguage(getStateMachine().getConfigProvider().getSignLocale().getLanguage()); this.positionComposite.setPlaceholder( param.getPlaceholder(), param.getPlaceholderDimension().getWidth(), param.getPlaceholderDimension().getHeight(), - this.stateMachine.getConfigProvider().getPlaceholderTransparency()); + getStateMachine().getConfigProvider().getPlaceholderTransparency()); if (this.previousPosition != null && !this.previousPosition.useAutoPositioning()) this.positionComposite.setPosition( this.previousPosition.getX(), @@ -124,7 +124,7 @@ public class PositioningState extends State { @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if (!(status.getPreviousState() instanceof PositioningState) && !(status.getPreviousState() instanceof OpenState)) { @@ -133,12 +133,12 @@ public class PositioningState extends State { } if ((this.document == null) || - (this.previousDocument != this.stateMachine.getStatus().getDocument())) { + (this.previousDocument != getStateMachine().getStatus().getDocument())) { this.document = null; log.debug("Checking PDF document for encryption"); //$NON-NLS-1$ try { this.document = getPDFDocument(); - this.previousDocument = this.stateMachine.getStatus().getDocument(); + this.previousDocument = getStateMachine().getStatus().getDocument(); } catch (IOException e) { this.positionComposite = null; log.error("Failed to display PDF document", e); //$NON-NLS-1$ @@ -146,12 +146,12 @@ public class PositioningState extends State { if (message == null) message = Messages.getString("error.IOError"); //$NON-NLS-1$ ErrorDialog dialog = new ErrorDialog( - this.stateMachine.getGUIProvider().getMainShell(), + getStateMachine().getGUIProvider().getMainShell(), message, BUTTONS.RETRY_CANCEL); if(dialog.open() == SWT.RETRY) { run(); } else { - setNextState(new OpenState(this.stateMachine)); + setNextState(new OpenState(getStateMachine())); } return; } @@ -164,25 +164,25 @@ public class PositioningState extends State { } catch(Exception ex) { log.error("Failed to create composite (probably a mac...)", ex); //$NON-NLS-1$ ErrorDialog dialog = new ErrorDialog( - this.stateMachine.getGUIProvider().getMainShell(), + getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.PositioningNotPossible"), BUTTONS.OK); //$NON-NLS-1$ dialog.open(); status.setSignaturePosition(new SignaturePosition()); - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); return; } - this.stateMachine.getGUIProvider().display(position); + getStateMachine().getGUIProvider().display(position); status.setSignaturePosition(position.getPosition()); if(status.getSignaturePosition() != null) { - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } this.positionComposite.requestFocus(); } else { - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } } @@ -200,7 +200,7 @@ public class PositioningState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index 5ba24378..c2e3d9c0 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -73,7 +73,7 @@ public class PrepareConfigurationState extends State { */ public PrepareConfigurationState(StateMachine stateMachine) { super(stateMachine); - this.handler = new ArgumentHandler(this.stateMachine); + this.handler = new ArgumentHandler(getStateMachine()); this.handler.addCLIArgument(HelpArgument.class); this.handler.addCLIArgument(InputDocumentArgument.class); this.handler.addCLIArgument(OutputFolderArgument.class); @@ -90,7 +90,7 @@ public class PrepareConfigurationState extends State { // adding config file argument to this handler so it appears in help this.handler.addCLIArgument(ConfigFileArgument.class); - this.configFileHandler = new ArgumentHandler(this.stateMachine); + this.configFileHandler = new ArgumentHandler(getStateMachine()); this.configFileHandler.addCLIArgument(ConfigFileArgument.class); } @@ -99,9 +99,9 @@ public class PrepareConfigurationState extends State { try { try { - this.stateMachine.getConfigProvider().loadConfiguration( + getStateMachine().getConfigProvider().loadConfiguration( new FileInputStream( - this.stateMachine.getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + filename)); + getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + filename)); log.info("Loaded config from file : " + filename); //$NON-NLS-1$ @@ -112,7 +112,7 @@ public class PrepareConfigurationState extends State { try { InputStream is = this.getClass().getResourceAsStream( Constants.RES_PKG_PATH + filename); - this.stateMachine.getConfigProvider() + getStateMachine().getConfigProvider() .loadConfiguration(is); log.info("Loaded config from resource : " + filename); //$NON-NLS-1$ @@ -135,7 +135,7 @@ public class PrepareConfigurationState extends State { handler.handleArguments(args); if (handler.doesRequireExit()) { - this.stateMachine.exit(); + getStateMachine().exit(); } } @@ -160,7 +160,7 @@ public class PrepareConfigurationState extends State { inputStream = this.getClass().getResourceAsStream( Constants.RES_PKG_PATH + Constants.DEFAULT_CONFIG_FILENAME); pdfOverConfig = new FileOutputStream( - this.stateMachine.getConfigProvider().getConfigurationDirectory() + + getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + Constants.DEFAULT_CONFIG_FILENAME); while ((byteCount = inputStream.read(buffer)) >= 0) { @@ -197,7 +197,7 @@ public class PrepareConfigurationState extends State { try { inputStream = this.getClass().getResourceAsStream( Constants.RES_PKG_PATH + Constants.DEFAULT_LOG4J_FILENAME); - String filename = this.stateMachine.getConfigProvider().getConfigurationDirectory() + String filename = getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + Constants.DEFAULT_LOG4J_FILENAME; pdfOverConfig = new FileOutputStream(filename); @@ -246,13 +246,13 @@ public class PrepareConfigurationState extends State { } // initialize from config file - this.initializeFromConfigurationFile(this.stateMachine + this.initializeFromConfigurationFile(getStateMachine() .getConfigProvider().getConfigurationFile()); - this.stateMachine.getConfigManipulator().setSignatureNote(Messages.getString("simple_config.Note_Default")); //$NON-NLS-1$ + getStateMachine().getConfigManipulator().setSignatureNote(Messages.getString("simple_config.Note_Default")); //$NON-NLS-1$ try { - this.stateMachine.getConfigManipulator().saveCurrentConfiguration(); + getStateMachine().getConfigManipulator().saveCurrentConfiguration(); } catch (IOException e) { log.error( "Failed to set local configuration signature note!", e); //$NON-NLS-1$ @@ -274,8 +274,8 @@ public class PrepareConfigurationState extends State { // Read config file try { - File configDir = new File(this.stateMachine.getConfigProvider().getConfigurationDirectory()); - File configFile = new File(this.stateMachine.getConfigProvider().getConfigurationDirectory() + File configDir = new File(getStateMachine().getConfigProvider().getConfigurationDirectory()); + File configFile = new File(getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + Constants.DEFAULT_CONFIG_FILENAME); if (!configDir.exists() || !configFile.exists()) { log.debug("Creating configuration file"); //$NON-NLS-1$ @@ -286,73 +286,73 @@ public class PrepareConfigurationState extends State { // Read cli arguments for config file first try { - this.initializeFromArguments(this.stateMachine.getCmdArgs(), + this.initializeFromArguments(getStateMachine().getCmdArgs(), this.configFileHandler); } catch (InitializationException e) { log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ - ErrorDialog error = new ErrorDialog(this.stateMachine + ErrorDialog error = new ErrorDialog(getStateMachine() .getGUIProvider().getMainShell(), Messages.getString("error.CmdLineArgs") + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ e.getMessage(), BUTTONS.OK); error.open(); - this.stateMachine.exit(); + getStateMachine().exit(); } // initialize from config file - this.initializeFromConfigurationFile(this.stateMachine + this.initializeFromConfigurationFile(getStateMachine() .getConfigProvider().getConfigurationFile()); // Read cli arguments try { - this.initializeFromArguments(this.stateMachine.getCmdArgs(), + this.initializeFromArguments(getStateMachine().getCmdArgs(), this.handler); } catch (InitializationException e) { log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ ErrorDialog error; if (e.getCause() instanceof FileNotFoundException) { - error = new ErrorDialog(this.stateMachine + error = new ErrorDialog(getStateMachine() .getGUIProvider().getMainShell(), String.format( Messages.getString("error.FileNotExist"), //$NON-NLS-1$ e.getCause().getMessage()), BUTTONS.OK); } else { - error = new ErrorDialog(this.stateMachine + error = new ErrorDialog(getStateMachine() .getGUIProvider().getMainShell(), Messages.getString("error.CmdLineArgs") + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ e.getMessage(), BUTTONS.OK); } error.open(); - this.stateMachine.exit(); + getStateMachine().exit(); } // Set usedSignerLib ... - this.stateMachine.getPDFSigner().setUsedPDFSignerLibrary( + getStateMachine().getPDFSigner().setUsedPDFSignerLibrary( Signator.Signers.PDFAS); // Create PDF Signer - this.stateMachine.getStatus().setBKU( - this.stateMachine.getConfigProvider().getDefaultBKU()); + getStateMachine().getStatus().setBKU( + getStateMachine().getConfigProvider().getDefaultBKU()); - this.stateMachine.getStatus().setSignaturePosition( - this.stateMachine.getConfigProvider() + getStateMachine().getStatus().setSignaturePosition( + getStateMachine().getConfigProvider() .getDefaultSignaturePosition()); - this.setNextState(new OpenState(this.stateMachine)); + this.setNextState(new OpenState(getStateMachine())); } catch (InitializationException e) { log.error("Failed to initialize: ", e); //$NON-NLS-1$ - ErrorDialog error = new ErrorDialog(this.stateMachine + ErrorDialog error = new ErrorDialog(getStateMachine() .getGUIProvider().getMainShell(), Messages.getString("error.Initialization"), //$NON-NLS-1$ BUTTONS.OK); // error.setException(e); // this.setNextState(error); error.open(); - this.stateMachine.exit(); + getStateMachine().exit(); } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index ad0658c5..b66f9d3c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -68,9 +68,9 @@ public class PrepareSigningState extends State { public void run() { try { - Status status = this.state.stateMachine.getStatus(); + Status status = this.state.getStateMachine().getStatus(); - ConfigProvider configuration = this.state.stateMachine + ConfigProvider configuration = this.state.getStateMachine() .getConfigProvider(); // SET PROXY HOST and PORT settings @@ -121,7 +121,7 @@ public class PrepareSigningState extends State { }); } if (this.state.signer == null) { - this.state.signer = this.state.stateMachine.getPDFSigner() + this.state.signer = this.state.getStateMachine().getPDFSigner() .getPDFSigner(); } @@ -161,7 +161,7 @@ public class PrepareSigningState extends State { log.error("PrepareDocumentThread: ", e); //$NON-NLS-1$ this.state.threadException = e; } finally { - this.state.stateMachine.invokeUpdate(); + this.state.getStateMachine().invokeUpdate(); } } } @@ -178,7 +178,7 @@ public class PrepareSigningState extends State { private WaitingComposite getSelectionComposite() { if (this.waitingComposite == null) { - this.waitingComposite = this.stateMachine.getGUIProvider() + this.waitingComposite = getStateMachine().getGUIProvider() .createComposite(WaitingComposite.class, SWT.RESIZE, this); } @@ -195,11 +195,11 @@ public class PrepareSigningState extends State { public void run() { WaitingComposite waiting = this.getSelectionComposite(); - this.stateMachine.getGUIProvider().display(waiting); + getStateMachine().getGUIProvider().display(waiting); - this.signer = this.stateMachine.getPDFSigner().getPDFSigner(); + this.signer = getStateMachine().getPDFSigner().getPDFSigner(); - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if (this.signatureParameter == null) { this.signatureParameter = this.signer.newParameter(); @@ -212,7 +212,7 @@ public class PrepareSigningState extends State { } if (this.threadException != null) { - ErrorDialog error = new ErrorDialog(this.stateMachine + ErrorDialog error = new ErrorDialog(getStateMachine() .getGUIProvider().getMainShell(), Messages.getString("error.PrepareDocument"), //$NON-NLS-1$ BUTTONS.RETRY_CANCEL); @@ -220,7 +220,7 @@ public class PrepareSigningState extends State { if (error.open() == SWT.RETRY) { run(); } else { - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } return; } @@ -228,13 +228,13 @@ public class PrepareSigningState extends State { // We got the Request set it into status and move on to next state ... status.setSigningState(this.signingState); - if (this.stateMachine.getStatus().getBKU() == BKUs.LOCAL) { - this.setNextState(new LocalBKUState(this.stateMachine)); - } else if (this.stateMachine.getStatus().getBKU() == BKUs.MOBILE) { - this.setNextState(new MobileBKUState(this.stateMachine)); + if (getStateMachine().getStatus().getBKU() == BKUs.LOCAL) { + this.setNextState(new LocalBKUState(getStateMachine())); + } else if (getStateMachine().getStatus().getBKU() == BKUs.MOBILE) { + this.setNextState(new MobileBKUState(getStateMachine())); } else { log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); //$NON-NLS-1$ - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } } @@ -254,7 +254,7 @@ public class PrepareSigningState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus() + MainWindowBehavior behavior = getStateMachine().getStatus() .getBehavior(); behavior.reset(); behavior.setActive(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java index 87201e2f..75efbd0c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -51,15 +51,15 @@ public class SigningState extends State { @Override public void run() { try { - Signer signer = this.state.stateMachine.getPDFSigner().getPDFSigner(); - Status status = this.state.stateMachine.getStatus(); + Signer signer = this.state.getStateMachine().getPDFSigner().getPDFSigner(); + Status status = this.state.getStateMachine().getStatus(); status.setSignResult(signer.sign(status.getSigningState())); } catch(Exception e) { log.error("FinishSignThread: ", e); //$NON-NLS-1$ this.state.threadException = e; } finally { - this.state.stateMachine.invokeUpdate(); + this.state.getStateMachine().invokeUpdate(); } } } @@ -80,7 +80,7 @@ public class SigningState extends State { @Override public void run() { - Status status = this.stateMachine.getStatus(); + Status status = getStateMachine().getStatus(); if(status.getSignResult() == null && this.threadException == null) { @@ -96,18 +96,18 @@ public class SigningState extends State { if (cause instanceof ConnectorException) message += ": " + cause.getMessage(); //$NON-NLS-1$ } - ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(), + ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider().getMainShell(), message, BUTTONS.RETRY_CANCEL); this.threadException = null; if(error.open() == SWT.RETRY) { - this.setNextState(new PrepareSigningState(this.stateMachine)); + this.setNextState(new PrepareSigningState(getStateMachine())); } else { - this.setNextState(new BKUSelectionState(this.stateMachine)); + this.setNextState(new BKUSelectionState(getStateMachine())); } return; } - this.setNextState(new OutputState(this.stateMachine)); + this.setNextState(new OutputState(getStateMachine())); } /* (non-Javadoc) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java index 8fcf9367..975e612f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java @@ -26,7 +26,7 @@ public abstract class State { /** * The StateMachine */ - protected StateMachine stateMachine; + private StateMachine stateMachine; private State nextState = null; @@ -74,6 +74,15 @@ public abstract class State { } /** + * Get the state machine + * @return the StateMachine + */ + protected StateMachine getStateMachine() + { + return this.stateMachine; + } + + /** * Update the main window behavior of this state if necessary * Should update this.stateMachine.getStatus().getBehavior() */ |