summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java83
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java5
7 files changed, 22 insertions, 87 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
index b2a54ee5..e013b7f8 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
@@ -41,7 +41,7 @@ public class AutomaticPositioningArgument extends Argument {
public int handleArgument(String[] args, int argOffset,
ArgumentHandler handler)
throws InitializationException {
- getConfiguration().setDefaultSignaturePositionOverlay(new SignaturePosition());
+ getConfiguration().setAutoPositionSignatureOverlay();
return argOffset;
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
index be872c1e..b2db3875 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
@@ -57,7 +57,6 @@ 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.BKUs;
-import at.asit.pdfover.signator.SignaturePosition;
/**
* Composite for advanced configuration
@@ -532,8 +531,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
void performPositionSelection(boolean automatic) {
log.debug("Selected Position: {}", automatic);
- SignaturePosition pos = automatic ? new SignaturePosition() : null;
- this.configurationContainer.defaultSignaturePosition = pos;
+ this.configurationContainer.autoPositionSignature = automatic;
this.btnAutomatischePositionierung.setSelection(automatic);
}
@@ -648,7 +646,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
@Override
public void initConfiguration(ConfigurationManager provider) {
- this.configurationContainer.defaultSignaturePosition = provider.getDefaultSignaturePositionPersistent();
+ this.configurationContainer.autoPositionSignature = provider.getAutoPositionSignaturePersistent();
this.configurationContainer.setUseMarker(provider.getUseMarker());
this.configurationContainer.setUseSignatureFields(provider.getUseSignatureFields());
this.configurationContainer.enabledPlaceholderUsage = provider.getEnablePlaceholderUsage();
@@ -696,8 +694,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
} else {
performPostFixChanged(Constants.DEFAULT_POSTFIX);
}
- SignaturePosition pos = this.configurationContainer.defaultSignaturePosition;
- performPositionSelection(pos != null && pos.useAutoPositioning());
+ performPositionSelection(this.configurationContainer.autoPositionSignature);
performUseMarkerSelection(this.configurationContainer.getUseMarker());
performUseSignatureFieldsSelection(this.configurationContainer.getUseSignatureFields());
performEnableUsePlaceholder(this.configurationContainer.enabledPlaceholderUsage);
@@ -740,7 +737,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
@Override
public void storeConfiguration(ConfigurationManager store) {
- store.setDefaultSignaturePosition(this.configurationContainer.defaultSignaturePosition);
+ store.setAutoPositionSignature(this.configurationContainer.autoPositionSignature);
store.setUseMarker(this.configurationContainer.getUseMarker());
store.setUseSignatureFields(this.configurationContainer.getUseSignatureFields());
store.setEnablePlaceholderUsage(this.configurationContainer.enabledPlaceholderUsage);
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 c8d9c208..887ea91a 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
@@ -68,7 +68,6 @@ 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.SignatureParameter;
-import at.asit.pdfover.signator.SignaturePosition;
/**
*
@@ -539,7 +538,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
this.cmbSignatureProfiles.select(newProfile.ordinal());
if (newProfile.equals(Profile.AMTSSIGNATURBLOCK) || newProfile.equals(Profile.INVISIBLE)){
- this.configurationContainer.defaultSignaturePosition = new SignaturePosition();
+ this.configurationContainer.autoPositionSignature = true;
}
setSignatureProfileSetting();
if (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(oldProfile, null)))
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 382cc744..f536ebb4 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
@@ -34,7 +34,6 @@ import at.asit.pdfover.gui.bku.mobile.MobileBKUs;
import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.signator.BKUs;
-import at.asit.pdfover.signator.SignaturePosition;
/**
* Implementation of the configuration container
@@ -141,7 +140,7 @@ public class ConfigurationDataInMemory {
protected boolean mobileBKUBase64 = false;
/** Holds the default signature position */
- public SignaturePosition defaultSignaturePosition = null;
+ public boolean autoPositionSignature = false;
/** Keystore signing options */
public Boolean keystoreEnabled = null;
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 414f89de..44e328bb 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
@@ -22,8 +22,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;
import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import at.asit.pdfover.commons.Profile;
import org.eclipse.swt.graphics.Point;
@@ -37,9 +35,6 @@ import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.utils.LocaleSerializer;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.signator.BKUs;
-import at.asit.pdfover.signator.SignaturePosition;
-
-// TODO: review which properties use the overlay in this file (also: remove unneeded setters/getters, maybe template impl for overlays?)
/**
* Implementation of the configuration provider and manipulator
@@ -224,53 +219,8 @@ public class ConfigurationManager {
this.configuration.mainWindowSize = new Point(width, height);
// Set Signature Position
- String signaturePosition = diskConfig.getProperty(Constants.CFG_SIGNATURE_POSITION);
- SignaturePosition position = null;
- if (signaturePosition != null && !signaturePosition.trim().isEmpty()) {
- signaturePosition = signaturePosition.trim().toLowerCase();
-
- Pattern pattern = Pattern.compile("(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?);p=(\\d))|(auto)|(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?))");
- Matcher matcher = pattern.matcher(signaturePosition);
- if (matcher.matches()) {
- if (matcher.groupCount() == 8) {
- if (matcher.group(1) != null) {
- // we have format: x=..;y=..;p=...
- try {
- // group 2 = x value
- float x = Float.parseFloat(matcher.group(2));
-
- // group 3 = y value
- float y = Float.parseFloat(matcher.group(3));
-
- // group 4 = p value
- int p = Integer.parseInt(matcher.group(3));
-
- position = new SignaturePosition(x, y, p);
- } catch (NumberFormatException ex) {
- log.error(
- "Signature Position read from config failed: Not a valid number", ex);
- }
- } else if (matcher.group(5) != null) {
- // we have format auto
- position = new SignaturePosition();
- } else if (matcher.group(6) != null) {
- // we have format x=...;y=...;
- // group 7 = x value
- float x = Float.parseFloat(matcher.group(7));
-
- // group 8 = y value
- float y = Float.parseFloat(matcher.group(8));
-
- position = new SignaturePosition(x, y);
- }
- } else {
- log.error("Signature Position read from config failed: wrong group Count!");
- }
- } else {
- log.error("Signature Position read from config failed: not matching string");
- }
- }
- setDefaultSignaturePosition(position);
+ String signaturePositionStr = diskConfig.getProperty(Constants.CFG_SIGNATURE_POSITION);
+ setAutoPositionSignature(signaturePositionStr != null && signaturePositionStr.trim().equals("auto"));
//Set keystore stuff
String keystoreEnabled = diskConfig.getProperty(Constants.CFG_KEYSTORE_ENABLED);
@@ -350,16 +300,10 @@ public class ConfigurationManager {
if (getSignaturePdfACompat())
props.setProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT, Constants.TRUE);
- SignaturePosition pos = getDefaultSignaturePositionPersistent();
- if (pos == null) {
+ if (!getAutoPositionSignaturePersistent())
props.setProperty(Constants.CFG_SIGNATURE_POSITION, "");
- } else if (pos.useAutoPositioning()) {
+ else
props.setProperty(Constants.CFG_SIGNATURE_POSITION, "auto");
- } else {
- props.setProperty(Constants.CFG_SIGNATURE_POSITION,
- String.format((Locale) null, "x=%f;y=%f;p=%d",
- pos.getX(), pos.getY(), pos.getPage()));
- }
String mobileBKUURL = getMobileBKUURL();
if (!mobileBKUURL.equals(Constants.DEFAULT_MOBILE_BKU_URL))
@@ -435,23 +379,20 @@ public class ConfigurationManager {
return this.configuration.defaultBKU;
}
- public void setDefaultSignaturePosition(SignaturePosition signaturePosition) {
- this.configuration.defaultSignaturePosition = signaturePosition;
+ public void setAutoPositionSignature(boolean state) {
+ this.configuration.autoPositionSignature = state;
}
- public void setDefaultSignaturePositionOverlay(SignaturePosition signaturePosition) {
- this.configurationOverlay.defaultSignaturePosition = signaturePosition;
+ public void setAutoPositionSignatureOverlay() {
+ this.configurationOverlay.autoPositionSignature = true;
}
- public SignaturePosition getDefaultSignaturePosition() {
- SignaturePosition position = this.configurationOverlay.defaultSignaturePosition;
- if (position == null)
- position = getDefaultSignaturePositionPersistent();
- return position;
+ public boolean getAutoPositionSignature() {
+ return this.configurationOverlay.autoPositionSignature || getAutoPositionSignaturePersistent();
}
- public SignaturePosition getDefaultSignaturePositionPersistent() {
- return this.configuration.defaultSignaturePosition;
+ public boolean getAutoPositionSignaturePersistent() {
+ return this.configuration.autoPositionSignature;
}
public void setPlaceholderTransparency(int transparency) {
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 e7fcb98d..9946f847 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
@@ -87,7 +87,7 @@ public class OpenState extends State {
&& !(status.getPreviousState() instanceof OpenState)) {
status.bku = config.getDefaultBKU();
status.document = null;
- status.signaturePosition = config.getDefaultSignaturePosition();
+ status.signaturePosition = config.getAutoPositionSignature() ? (new SignaturePosition()) : null;
/* ensure that files get closed */
status.getPreviousState().cleanUp();
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 01f7a19c..f50f171d 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
@@ -28,9 +28,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
-import java.util.Locale;
-import at.asit.pdfover.commons.Profile;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.eclipse.swt.SWT;
@@ -54,6 +52,7 @@ 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.Signator;
+import at.asit.pdfover.signator.SignaturePosition;
/**
* Starting state of workflow proccess
@@ -350,7 +349,7 @@ public class PrepareConfigurationState extends State {
// Create PDF Signer
Status status = stateMachine.status;
status.bku = getStateMachine().configProvider.getDefaultBKU();
- status.signaturePosition = getStateMachine().configProvider.getDefaultSignaturePosition();
+ status.signaturePosition = getStateMachine().configProvider.getAutoPositionSignature() ? (new SignaturePosition()) : null;
setNextState(new OpenState(stateMachine));