From 42fde29384da03043bcf7710b4983fa4f5836ae8 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Mon, 23 Nov 2020 16:02:25 +0100 Subject: change in profile setting --- .../main/java/at/asit/pdfover/commons/Profile.java | 45 +++++----------------- .../composites/AdvancedConfigurationComposite.java | 2 +- .../composites/SimpleConfigurationComposite.java | 13 ++++--- .../gui/workflow/config/ConfigProviderImpl.java | 2 +- .../signer/pdfas/PdfAs4SignatureParameter.java | 7 +++- .../at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 2 +- publish.sh | 2 +- 7 files changed, 26 insertions(+), 47 deletions(-) diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java index ef2eccd8..c15fc225 100644 --- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java +++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java @@ -2,48 +2,21 @@ package at.asit.pdfover.commons; public enum Profile { - SIGNATURBLOCK_SMALL("Signaturblock Normal"), //$NON-NLS-1$ - AMTSSIGNATURBLOCK("Amtssignatur"), //$NON-NLS-1$ - BASE_LOGO("Nur Bildmarke"), //$NON-NLS-1$ - INVISIBLE("Unsichtbar"); + SIGNATURBLOCK_SMALL, //$NON-NLS-1$ + AMTSSIGNATURBLOCK, //$NON-NLS-1$ + BASE_LOGO, //$NON-NLS-1$ + INVISIBLE; public static int length = 4; - private String name; - Profile(String profile){ - this.name = profile; - } - - public static String[] getProfileStrings() { - String[] profiles = new String[Profile.length]; - int i = 0; - for (Profile profile : Profile.values()) { - profiles[i] = profile.getName(); - i++; - } - return profiles; - } - - public static Profile getProfileByIndex(int index) { - String[] profiles = getProfileStrings(); - if (profiles.length < index) { - return null; - } - return getProfile(profiles[index]); - } - - public String getName() { - return this.name; - } - - public static Profile getProfile(String profile) { - if (SIGNATURBLOCK_SMALL.getName().equals(profile)) { + public static Profile getProfile(String name) { + if (SIGNATURBLOCK_SMALL.name().equals(name)) { return SIGNATURBLOCK_SMALL; - } else if (AMTSSIGNATURBLOCK.getName().equals(profile)) { + } else if (AMTSSIGNATURBLOCK.name().equals(name)) { return AMTSSIGNATURBLOCK; - } else if (BASE_LOGO.getName().equals(profile)) { + } else if (BASE_LOGO.name().equals(name)) { return BASE_LOGO; - } else if (INVISIBLE.getName().equals(profile)){ + } else if (INVISIBLE.name().equals(name)){ return INVISIBLE; } return null; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java index d2dabc5f..79523afe 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java @@ -975,7 +975,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { store.setUpdateCheck(this.configurationContainer.getUpdateCheck()); - store.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName()); + store.setSignatureProfile(this.configurationContainer.getSignatureProfile().name()); String hostOld = provider.getProxyHostPersistent(); String hostNew = this.configurationContainer.getProxyHost(); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java index 75482b60..10be1500 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java @@ -243,8 +243,11 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { @Override public void widgetSelected(SelectionEvent e) { Profile current = SimpleConfigurationComposite.this.configurationContainer.getSignatureProfile(); - Profile selected = Profile.getProfileByIndex(SimpleConfigurationComposite.this.cmbSignatureProfiles - .getSelectionIndex()); + //Profile selected = Profile.getProfileByIndex(SimpleConfigurationComposite.this.cmbSignatureProfiles + // .getSelectionIndex()); + //TODO to test + int index = SimpleConfigurationComposite.this.cmbSignatureProfiles.getSelectionIndex(); + Profile selected = Profile.values()[index]; if (!current.equals(selected)) { preformProfileSelectionChanged(selected); } @@ -735,7 +738,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { } void preformProfileSelectionChanged(Profile selected) { - log.debug("Signature Profile {} was selected", selected.getName()); //$NON-NLS-1$ + log.debug("Signature Profile {} was selected", selected.name()); //$NON-NLS-1$ this.configurationContainer.setSignatureProfile(selected); this.cmbSignatureProfiles.select(selected.ordinal()); @@ -748,7 +751,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { void setSignatureProfileSetting(){ try { SignatureParameter param = this.signer.getPDFSigner().newParameter(); - param.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName()); + param.setSignatureProfile(this.configurationContainer.getSignatureProfile().name()); } catch (Exception e){ log.debug("Cannot save signature profile {}", e.getMessage()); @@ -879,7 +882,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { store.setSignatureNote(this.configurationContainer.getSignatureNote()); - store.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName()); + store.setSignatureProfile(this.configurationContainer.getSignatureProfile().name()); } /* diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java index c3a15cb3..a7e6592c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java @@ -1521,7 +1521,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public String getSignatureProfile() { - return this.configurationOverlay.getSignatureProfile().getName(); + return this.configurationOverlay.getSignatureProfile().name(); } diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 08722617..0117b8d3 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -69,7 +69,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { **/ static final Logger log = LoggerFactory .getLogger(PdfAs4SignatureParameter.class); - private String profile; + private String profile = null; /* (non-Javadoc) * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension() @@ -175,7 +175,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { return Profile.INVISIBLE.name(); } - switch (Profile.getProfile(this.profile)){ + switch (Profile.getProfile(getProfileName())){ case BASE_LOGO: case INVISIBLE: return getProfileName(); @@ -202,6 +202,9 @@ public class PdfAs4SignatureParameter extends SignatureParameter { } private String getProfileName(){ + if (this.profile == null){ + this.profile = Profile.SIGNATURBLOCK_SMALL.name(); + } return Profile.getProfile(this.profile).name(); } diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index a1934cb2..1b045c64 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -147,7 +147,7 @@ public class PdfAs4Signer implements Signer { sp = new SignaturePosition(); else if (tp.isPauto()) sp = new SignaturePosition(tp.getPosX(), tp.getPosY()); - else if (param.getSignatureProfileId().contains(Profile.AMTSSIGNATURBLOCK.getName())) + else if (param.getSignatureProfileId().contains(Profile.AMTSSIGNATURBLOCK.name())) sp = new SignaturePosition(); else sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage()); diff --git a/publish.sh b/publish.sh index c365b868..df8f3184 100755 --- a/publish.sh +++ b/publish.sh @@ -1,7 +1,7 @@ #!/bin/bash #### CONFIGURE: ###### -PUBLISH_DIR="C:\Users\aabraham\eclipse-workspace-pdf-over\pdf-over\pdf-over-build" +PUBLISH_DIR="pdf-over-build" LOG_DIR="log" CODEBASE_URL="http:\/\/abyss.iaik.tugraz.at\/pdf-over\/" CONTEXT_URL="http:\/\/abyss.iaik.tugraz.at\/pdf-over\/" -- cgit v1.2.3