summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-02 16:04:49 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-02 16:04:49 +0200
commita3a190f41b5b509f2af1c1565ad9599169cf7f82 (patch)
treef617c0ef11ea37178a29089db41a2c4bcb376c30 /pdf-over-gui/src/main/java
parent84a57e47b435e5b44e827536b3eb29fae7ec3501 (diff)
downloadpdf-over-a3a190f41b5b509f2af1c1565ad9599169cf7f82.tar.gz
pdf-over-a3a190f41b5b509f2af1c1565ad9599169cf7f82.tar.bz2
pdf-over-a3a190f41b5b509f2af1c1565ad9599169cf7f82.zip
YAGNI: Emblem interface
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java16
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java6
6 files changed, 18 insertions, 24 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
index e821d78f..4fb4874e 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
@@ -66,7 +66,7 @@ import at.asit.pdfover.gui.utils.ImageConverter;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signator.CachedFileNameEmblem;
+import at.asit.pdfover.signator.Emblem;
import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
/**
@@ -423,8 +423,8 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
private void setEmblemFileInternal(final String filename, boolean force)
throws Exception {
- if (!force && this.configurationContainer.getEmblem() != null) {
- if (this.configurationContainer.getEmblem().equals(filename)) {
+ if (!force && this.configurationContainer.getEmblemPath() != null) {
+ if (this.configurationContainer.getEmblemPath().equals(filename)) {
return; // Ignore ...
}
}
@@ -435,7 +435,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
}
void updateSignatureBlockPreview() {
- String image = this.configurationContainer.getEmblem();
+ String image = this.configurationContainer.getEmblemPath();
ImageData img = null;
ImageData logo = null;
@@ -449,7 +449,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
param.enablePDFACompat = this.configurationContainer.signaturePDFACompat;
if (image != null && !image.trim().isEmpty()) {
logo = new ImageData(image);
- param.emblem = new CachedFileNameEmblem(image);
+ param.emblem = new Emblem(image);
}
//TODO deactivated the placeholder preview
//TODO display accurate placeholder preview -> now its only standard placeholder shown
@@ -468,7 +468,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
try {
File imgFile = new File(image);
this.logo = new Image(this.getDisplay(),
- ImageConverter.convertToSWT(CachedFileNameEmblem.fixImage(
+ ImageConverter.convertToSWT(Emblem.fixImage(
ImageIO.read(imgFile), imgFile)));
} catch (IOException e) {
log.error("Error reading image", e);
@@ -604,7 +604,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
this.txtMobileNumber.setText(number);
}
- String emblemFile = this.configurationContainer.getEmblem();
+ String emblemFile = this.configurationContainer.getEmblemPath();
if (emblemFile != null && !emblemFile.trim().isEmpty()) {
this.logoFile = emblemFile;
try {
@@ -636,7 +636,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
@Override
public void storeConfiguration(ConfigurationManager store) {
store.setDefaultMobileNumberPersistent(this.configurationContainer.getMobileNumber());
- store.setDefaultEmblemPersistent(this.configurationContainer.getEmblem());
+ store.setDefaultEmblemPersistent(this.configurationContainer.getEmblemPath());
store.setSignatureLocalePersistent(this.configurationContainer.signatureLocale);
store.setSignatureNotePersistent(this.configurationContainer.signatureNote);
store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile().name());
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java
index 80b27183..18009895 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java
@@ -34,7 +34,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.signator.CachedFileNameEmblem;
import at.asit.pdfover.signator.Emblem;
import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
@@ -79,12 +78,8 @@ public class SignaturePlaceholderCache {
String sigEHsh = "";
if (param.emblem != null) {
Emblem embl = param.emblem;
- if (embl instanceof CachedFileNameEmblem) {
- sigEmbl = ((CachedFileNameEmblem) embl).getOriginalFileName();
- sigEHsh = ((CachedFileNameEmblem) embl).getOriginalFileHash();
- } else {
- sigEmbl = embl.getFileName();
- }
+ sigEmbl = embl.getOriginalFileName();
+ sigEHsh = embl.getOriginalFileHash();
}
String sigPdfA = param.enablePDFACompat ? Constants.TRUE : Constants.FALSE;
String sigNote = param.getProperty("SIG_NOTE");
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
index 7fb08602..39d557c5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
@@ -47,7 +47,7 @@ public class ConfigurationDataInMemory {
/** the emblem File */
protected String emblemFile = null;
- public String getEmblem() { return this.emblemFile; }
+ public String getEmblemPath() { return this.emblemFile; }
public void setEmblem(String emblemFile) throws InvalidEmblemFile {
if (emblemFile == null || emblemFile.trim().isEmpty()) {
// Ok to set no file ...
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
index d467178a..df059e68 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
@@ -521,15 +521,15 @@ public class ConfigurationManager {
}
}
- public String getDefaultEmblem() {
- String emblem = this.configurationOverlay.getEmblem();
+ public String getDefaultEmblemPath() {
+ String emblem = this.configurationOverlay.getEmblemPath();
if (emblem == null)
emblem = getDefaultEmblemPersistent();
return emblem;
}
public String getDefaultEmblemPersistent() {
- String emblem = this.configuration.getEmblem();
+ String emblem = this.configuration.getEmblemPath();
if (emblem == null)
emblem = STRING_EMPTY;
return emblem;
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 5ed63e0b..a09a7a6b 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
@@ -35,7 +35,6 @@ import at.asit.pdfover.gui.utils.SignaturePlaceholderCache;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signator.CachedFileNameEmblem;
import at.asit.pdfover.signator.Emblem;
import at.asit.pdfover.signator.SignaturePosition;
import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
@@ -108,7 +107,7 @@ public class PositioningState extends State {
// Update possibly changed values
ConfigurationManager config = stateMachine.configProvider;
PdfAs4SignatureParameter param = new PdfAs4SignatureParameter();
- Emblem emblem = new CachedFileNameEmblem(config.getDefaultEmblem());
+ Emblem emblem = new Emblem(config.getDefaultEmblemPath());
param.emblem = emblem;
if(config.getSignatureNote() != null && !config.getSignatureNote().isEmpty()) {
param.setProperty("SIG_NOTE", config.getSignatureNote());
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 786ed920..bb3190ef 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
@@ -32,7 +32,7 @@ import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signator.CachedFileNameEmblem;
+import at.asit.pdfover.signator.Emblem;
import at.asit.pdfover.signator.PDFFileDocumentSource;
import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
import at.asit.pdfover.signer.pdfas.PdfAs4Signer;
@@ -134,8 +134,8 @@ public class PrepareSigningState extends State {
this.state.signatureParameter.signaturePosition = status.signaturePosition;
}
- if (configuration.getDefaultEmblem() != null && !configuration.getDefaultEmblem().isEmpty()) {
- this.state.signatureParameter.emblem = new CachedFileNameEmblem(configuration.getDefaultEmblem());
+ if (configuration.getDefaultEmblemPath() != null && !configuration.getDefaultEmblemPath().isEmpty()) {
+ this.state.signatureParameter.emblem = new Emblem(configuration.getDefaultEmblemPath());
}
if (configuration.getSignatureNote() != null