From 11398d864a32451ef76cd03fcbb262273e644041 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 18 Feb 2022 15:37:25 +0100 Subject: properly load configured default BKU when positioning state is skipped (due to a detected signature placeholder), cf. #46 --- .../at/asit/pdfover/gui/workflow/states/BKUSelectionState.java | 8 +++++--- .../main/java/at/asit/pdfover/gui/workflow/states/OpenState.java | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'pdf-over-gui/src') 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 af9e9d15..bed41f4a 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 @@ -68,10 +68,12 @@ public class BKUSelectionState extends State { @Override public void run() { Status status = getStateMachine().getStatus(); - if (!(status.getPreviousState() instanceof BKUSelectionState) && - !(status.getPreviousState() instanceof PositioningState)) { + State previousState = status.getPreviousState(); + if (!(previousState instanceof OpenState) && + !(previousState instanceof PositioningState) && + !(previousState instanceof BKUSelectionState)) { status.setBKU(BKUs.NONE); - } else if((status.getPreviousState() instanceof PositioningState)) { + } else if(!(status.getPreviousState() instanceof BKUSelectionState)) { ConfigProvider config = getStateMachine().getConfigProvider(); status.setBKU(config.getDefaultBKU()); } 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 86d93daa..1b734b32 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 @@ -207,7 +207,6 @@ public class OpenState extends State { * The selected placeholder is added to the configuration file * @param selection */ - @SuppressWarnings("static-method") private void addPlaceholderSelectionToConfig(String selection) { try { PropertiesConfiguration config = new PropertiesConfiguration(); @@ -218,7 +217,7 @@ public class OpenState extends State { layout.save(new FileWriter(advancedConfig, false)); } catch (Exception e) { - log.error(e.getMessage(), e.getStackTrace()); + log.error("Failed to add placeholder selection to config", e); } } -- cgit v1.2.3