diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-02-18 15:52:44 +0100 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-02-18 15:52:44 +0100 |
commit | 6c8bcdd5de65d3fd7e2611abf70454a21ba53c3c (patch) | |
tree | 9d6f58293458ed561b2270ecf42c5271d33a4a67 /pdf-over-gui/src/main | |
parent | 11398d864a32451ef76cd03fcbb262273e644041 (diff) | |
download | pdf-over-6c8bcdd5de65d3fd7e2611abf70454a21ba53c3c.tar.gz pdf-over-6c8bcdd5de65d3fd7e2611abf70454a21ba53c3c.tar.bz2 pdf-over-6c8bcdd5de65d3fd7e2611abf70454a21ba53c3c.zip |
various refactors to start making signature placeholder code more readable
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java | 11 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java | 15 |
2 files changed, 15 insertions, 11 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 bed41f4a..8cca67a0 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 @@ -69,9 +69,11 @@ public class BKUSelectionState extends State { public void run() { Status status = getStateMachine().getStatus(); State previousState = status.getPreviousState(); - if (!(previousState instanceof OpenState) && - !(previousState instanceof PositioningState) && - !(previousState instanceof BKUSelectionState)) { + if (!( + (previousState instanceof OpenState) || + (previousState instanceof PositioningState) || + (previousState instanceof BKUSelectionState) + )) { status.setBKU(BKUs.NONE); } else if(!(status.getPreviousState() instanceof BKUSelectionState)) { ConfigProvider config = getStateMachine().getConfigProvider(); @@ -79,8 +81,7 @@ public class BKUSelectionState extends State { } if(status.getBKU() == BKUs.NONE) { - BKUSelectionComposite selection = this - .getSelectionComposite(); + BKUSelectionComposite selection = this.getSelectionComposite(); getStateMachine().getGUIProvider().display(selection); selection.layout(); 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 1b734b32..0b0929dd 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 @@ -81,10 +81,10 @@ public class OpenState extends State { @Override public void run() { + ConfigProvider config = getStateMachine().getConfigProvider(); Status status = getStateMachine().getStatus(); if (!(status.getPreviousState() instanceof PrepareConfigurationState) && !(status.getPreviousState() instanceof OpenState)) { - ConfigProvider config = getStateMachine().getConfigProvider(); status.setBKU(config.getDefaultBKU()); status.setDocument(null); status.setSignaturePosition(config.getDefaultSignaturePosition()); @@ -107,13 +107,16 @@ public class OpenState extends State { // scan for signature placeholders // - see if we want to scan for placeholders in the settings - if (getStateMachine().getConfigProvider().getEnablePlaceholderUsage()) { + if (config.getEnablePlaceholderUsage()) { try { // - scan for placeholders PDDocument pddocument = PDDocument.load(getStateMachine().getStatus().getDocument()); + boolean useSignatureFields = config.getUseSignatureFields(); + boolean useMarker = config.getUseMarker(); + log.debug("Placeholder usage enabled. Signature fields: {}, QR Markers: {}", useSignatureFields, useMarker); //first check the signature fields placeholder - if (getStateMachine().getConfigProvider().getUseSignatureFields()) { + if (useSignatureFields) { List<String> fields = SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(pddocument); @@ -156,14 +159,13 @@ public class OpenState extends State { } } // second check if qr code placeholder search is enabled - } else if (getStateMachine().getConfigProvider().getUseMarker()) { + } else if (useMarker) { SignaturePlaceholderData signaturePlaceholderData = SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(pddocument); if (null != signaturePlaceholderData) { - // create a dialog with ok and cancel buttons and a question - // icon + // create a dialog with ok and cancel buttons and a question icon MessageBox dialog = new MessageBox(getStateMachine().getGUIProvider().getMainShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); dialog.setText(Messages.getString("dataSourceSelection.usePlaceholderTitle")); //$NON-NLS-1$ @@ -187,6 +189,7 @@ public class OpenState extends State { } else { getStateMachine().getStatus().setSearchForPlaceholderSignature(false); } + // TODO: why does this use a different logic (via PositioningState) than the signature placeholders? } } else { |