summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java112
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java127
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java49
4 files changed, 170 insertions, 133 deletions
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 8ca12de1..0b0f6d1b 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
@@ -53,7 +53,9 @@ import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.exceptions.OutputfolderDoesntExistException;
import at.asit.pdfover.gui.exceptions.OutputfolderNotADirectoryException;
import at.asit.pdfover.gui.utils.Messages;
+import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
+import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.BKUs;
import at.asit.pdfover.signator.SignaturePosition;
@@ -904,7 +906,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
/*
* (non-Javadoc)
- *
* @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
*/
@Override
@@ -912,12 +913,47 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
// Nothing to do here
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#initConfiguration(at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ */
+ @Override
+ public void initConfiguration(PersistentConfigProvider provider) {
+ this.configurationContainer.setDefaultSignaturePosition(
+ provider.getDefaultSignaturePositionPersistent());
+ this.configurationContainer.setSignaturePdfACompat(
+ provider.getSignaturePdfACompat());
+ this.configurationContainer.setPlaceholderTransparency(
+ provider.getPlaceholderTransparency());
+
+ this.configurationContainer.setDefaultBKU(
+ provider.getDefaultBKUPersistent());
+
+ this.configurationContainer.setOutputFolder(
+ provider.getDefaultOutputFolderPersistent());
+
+ this.configurationContainer.setLocale(provider.getLocale());
+
+ this.configurationContainer.setUpdateCheck(
+ provider.getUpdateCheck());
+
+ this.configurationContainer.setProxyHost(
+ provider.getProxyHostPersistent());
+ try {
+ this.configurationContainer.setProxyPort(
+ provider.getProxyPortPersistent());
+ } catch (InvalidPortException e) {
+ log.error("Failed to set proxy port!", e); //$NON-NLS-1$
+ }
+ this.configurationContainer.setProxyUser(
+ provider.getProxyUserPersistent());
+ this.configurationContainer.setProxyPass(
+ provider.getProxyPassPersistent());
+ }
+
/*
* (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration
- * ()
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration()
*/
@Override
public void loadConfiguration() {
@@ -958,12 +994,70 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
// }
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#storeConfiguration(at.asit.pdfover.gui.workflow.config.ConfigManipulator, at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ */
+ @Override
+ public void storeConfiguration(ConfigManipulator store,
+ PersistentConfigProvider provider) {
+ store.setDefaultSignaturePosition(
+ this.configurationContainer.getDefaultSignaturePosition());
+ store.setSignaturePdfACompat(
+ this.configurationContainer.getSignaturePdfACompat());
+ store.setPlaceholderTransparency(
+ this.configurationContainer.getPlaceholderTransparency());
+
+ store.setDefaultBKU(this.configurationContainer.getDefaultBKU());
+
+ store.setDefaultOutputFolder(this.configurationContainer.getOutputFolder());
+
+ store.setLocale(this.configurationContainer.getLocale());
+
+ store.setUpdateCheck(this.configurationContainer.getUpdateCheck());
+
+ String hostOld = provider.getProxyHostPersistent();
+ String hostNew = this.configurationContainer.getProxyHost();
+ if (hostOld != null && !hostOld.isEmpty() &&
+ (hostNew == null || hostNew.isEmpty())) {
+ // Proxy has been removed, let's clear the system properties
+ // Otherwise, the proxy settings wouldn't get removed
+ System.clearProperty("http.proxyHost"); //$NON-NLS-1$
+ System.clearProperty("https.proxyHost"); //$NON-NLS-1$
+ }
+ store.setProxyHost(hostNew);
+
+ int portOld = provider.getProxyPortPersistent();
+ int portNew = this.configurationContainer.getProxyPort();
+ if (portOld != -1 && portNew == -1) {
+ // cf. above
+ System.clearProperty("http.proxyPort"); //$NON-NLS-1$
+ System.clearProperty("https.proxyPort"); //$NON-NLS-1$
+ }
+ store.setProxyPort(portNew);
+
+ String userOld = provider.getProxyUserPersistent();
+ String userNew = this.configurationContainer.getProxyUser();
+ if (userOld != null && !userOld.isEmpty() &&
+ (userNew == null || userNew.isEmpty())) {
+ // cf. above
+ System.clearProperty("http.proxyUser"); //$NON-NLS-1$
+ System.clearProperty("https.proxyUser"); //$NON-NLS-1$
+ }
+ store.setProxyUser(userNew);
+
+ String passOld = provider.getProxyPassPersistent();
+ String passNew = this.configurationContainer.getProxyPass();
+ if (passOld != null && passNew == null) {
+ // cf. above
+ System.clearProperty("http.proxyPassword"); //$NON-NLS-1$
+ System.clearProperty("https.proxyPassword"); //$NON-NLS-1$
+ }
+ store.setProxyPass(passNew);
+ }
/*
* (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings
- * ()
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings()
*/
@Override
public void validateSettings(int resumeIndex) throws Exception {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
index d341a9d3..6a7b1f19 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
@@ -19,7 +19,9 @@ package at.asit.pdfover.gui.composites;
import org.eclipse.swt.widgets.Composite;
import at.asit.pdfover.gui.workflow.PDFSigner;
+import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
+import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
import at.asit.pdfover.gui.workflow.states.State;
/**
@@ -69,11 +71,24 @@ public abstract class BaseConfigurationComposite extends StateComposite {
}
/**
+ * Initialize ConfigurationContainer from PersistentConfigProvider
+ * @param provider the PersistentConfigProvider to load config from
+ */
+ public abstract void initConfiguration(PersistentConfigProvider provider);
+
+ /**
* Load configuration from ConfigurationContainer
*/
public abstract void loadConfiguration();
/**
+ * Store configuration from ConfigurationContainer to ConfigManipulator
+ * @param store the ConfigManipulator to store config to
+ * @param provider the PersistentConfigProvider containing the old config
+ */
+ public abstract void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider);
+
+ /**
* Called before exit.
* The method validates every setting in the configuration before exit
*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index a9572027..9d894526 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -45,9 +45,6 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
-import at.asit.pdfover.gui.exceptions.InvalidNumberException;
-import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.exceptions.ResumableException;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.PDFSigner;
@@ -378,56 +375,8 @@ public class ConfigurationComposite extends StateComposite {
this.configProvider = provider;
if (this.configProvider != null) {
// Initialize Configuration Container
- this.configurationContainer
- .setDefaultSignaturePosition(this.configProvider
- .getDefaultSignaturePositionPersistent());
-
- this.configurationContainer
- .setPlaceholderTransparency(this.configProvider
- .getPlaceholderTransparency());
-
- this.configurationContainer.setSignatureNote(
- this.configProvider.getSignatureNote());
-
- this.configurationContainer.setLocale(this.configProvider.getLocale());
-
- this.configurationContainer.setSignatureLocale(this.configProvider.getSignatureLocale());
-
- this.configurationContainer.setSignaturePdfACompat(this.configProvider.getSignaturePdfACompat());
-
- this.configurationContainer.setDefaultBKU(this.configProvider
- .getDefaultBKUPersistent());
- try {
- this.configurationContainer.setEmblem(this.configProvider
- .getDefaultEmblemPersistent());
- } catch (InvalidEmblemFile e) {
- log.error("Failed to set emblem!", e); //$NON-NLS-1$
- }
- try {
- this.configurationContainer.setMobileNumber(this.configProvider
- .getDefaultMobileNumberPersistent());
- } catch (InvalidNumberException e) {
- log.error("Failed to set mobile phone number!", e); //$NON-NLS-1$
- }
-
- this.configurationContainer.setOutputFolder(this.configProvider
- .getDefaultOutputFolderPersistent());
-
- this.configurationContainer.setUpdateCheck(this.configProvider.
- getUpdateCheck());
-
- this.configurationContainer.setProxyHost(this.configProvider
- .getProxyHostPersistent());
- try {
- this.configurationContainer.setProxyPort(this.configProvider
- .getProxyPortPersistent());
- } catch (InvalidPortException e) {
- log.error("Failed to set proxy port!", e); //$NON-NLS-1$
- }
- this.configurationContainer.setProxyUser(this.configProvider
- .getProxyUserPersistent());
- this.configurationContainer.setProxyPass(this.configProvider
- .getProxyPassPersistent());
+ this.simpleConfigComposite.initConfiguration(this.configProvider);
+ this.advancedConfigComposite.initConfiguration(this.configProvider);
this.simpleConfigComposite.loadConfiguration();
this.advancedConfigComposite.loadConfiguration();
@@ -504,74 +453,10 @@ public class ConfigurationComposite extends StateComposite {
}
// Write current Configuration
- this.configManipulator.setDefaultBKU(this.configurationContainer
- .getDefaultBKU());
- this.configManipulator
- .setDefaultMobileNumber(this.configurationContainer.getMobileNumber());
- this.configManipulator
- .setDefaultSignaturePosition(this.configurationContainer.getDefaultSignaturePosition());
-
- this.configManipulator.setLocale(this.configurationContainer.getLocale());
-
- this.configManipulator.setSignatureLocale(this.configurationContainer.getSignatureLocale());
-
- this.configManipulator.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat());
-
- this.configManipulator
- .setPlaceholderTransparency(this.configurationContainer
- .getPlaceholderTransparency());
-
- this.configManipulator
- .setDefaultOutputFolder(this.configurationContainer
- .getOutputFolder());
-
- this.configManipulator.setSignatureNote(this.configurationContainer
- .getSignatureNote());
-
- this.configManipulator.setUpdateCheck(this.configurationContainer
- .getUpdateCheck());
-
- String hostOld = this.configProvider.getProxyHostPersistent();
- String hostNew = this.configurationContainer.getProxyHost();
- if (hostOld != null && !hostOld.isEmpty() &&
- (hostNew == null || hostNew.isEmpty())) {
- // Proxy has been removed, let's clear the system properties
- // Otherwise, the proxy settings wouldn't get removed
- System.clearProperty("http.proxyHost"); //$NON-NLS-1$
- System.clearProperty("https.proxyHost"); //$NON-NLS-1$
- }
- this.configManipulator.setProxyHost(hostNew);
-
- int portOld = this.configProvider.getProxyPortPersistent();
- int portNew = this.configurationContainer.getProxyPort();
- if (portOld != -1 && portNew == -1) {
- // cf. above
- System.clearProperty("http.proxyPort"); //$NON-NLS-1$
- System.clearProperty("https.proxyPort"); //$NON-NLS-1$
- }
- this.configManipulator.setProxyPort(portNew);
-
- String userOld = this.configProvider.getProxyUserPersistent();
- String userNew = this.configurationContainer.getProxyUser();
- if (userOld != null && !userOld.isEmpty() &&
- (userNew == null || userNew.isEmpty())) {
- // cf. above
- System.clearProperty("http.proxyUser"); //$NON-NLS-1$
- System.clearProperty("https.proxyUser"); //$NON-NLS-1$
- }
- this.configManipulator.setProxyUser(userNew);
-
- String passOld = this.configProvider.getProxyPassPersistent();
- String passNew = this.configurationContainer.getProxyPass();
- if (passOld != null && passNew == null) {
- // cf. above
- System.clearProperty("http.proxyPassword"); //$NON-NLS-1$
- System.clearProperty("https.proxyPassword"); //$NON-NLS-1$
- }
- this.configManipulator.setProxyPass(passNew);
-
- this.configManipulator.setDefaultEmblem(this.configurationContainer
- .getEmblem());
+ this.simpleConfigComposite.storeConfiguration(
+ this.configManipulator, this.configProvider);
+ this.advancedConfigComposite.storeConfiguration(
+ this.configManipulator, this.configProvider);
status = false;
redo = false;
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 093c0a88..37f37739 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
@@ -62,10 +62,13 @@ import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
+import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.exceptions.InvalidNumberException;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.utils.SignaturePlaceholderCache;
+import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
+import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.FileNameEmblem;
import at.asit.pdfover.signator.SignatureParameter;
@@ -743,11 +746,36 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
layout(true, true);
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#initConfiguration(at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ */
+ @Override
+ public void initConfiguration(PersistentConfigProvider provider) {
+ try {
+ this.configurationContainer.setMobileNumber(
+ provider.getDefaultMobileNumberPersistent());
+ } catch (InvalidNumberException e) {
+ log.error("Failed to set mobile phone number!", e); //$NON-NLS-1$
+ }
+
+ try {
+ this.configurationContainer.setEmblem(
+ provider.getDefaultEmblemPersistent());
+ } catch (InvalidEmblemFile e) {
+ log.error("Failed to set emblem!", e); //$NON-NLS-1$
+ }
+
+ this.configurationContainer.setSignatureLocale(
+ provider.getSignatureLocale());
+
+ this.configurationContainer.setSignatureNote(
+ provider.getSignatureNote());
+ }
+
/*
* (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration
* ()
*/
@Override
@@ -785,6 +813,21 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.performSignatureLangSelectionChanged(this.configurationContainer.getSignatureLocale());
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#storeConfiguration(at.asit.pdfover.gui.workflow.config.ConfigManipulator, at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ */
+ @Override
+ public void storeConfiguration(ConfigManipulator store,
+ PersistentConfigProvider provider) {
+ store.setDefaultMobileNumber(this.configurationContainer.getMobileNumber());
+
+ store.setDefaultEmblem(this.configurationContainer.getEmblem());
+
+ store.setSignatureLocale(this.configurationContainer.getSignatureLocale());
+
+ store.setSignatureNote(this.configurationContainer.getSignatureNote());
+ }
+
/*
* (non-Javadoc)
*