summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:17:43 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:17:43 +0000
commit62db75f575d6d808d483bd9e60065c72bf964761 (patch)
tree433ca2c88488b605aa62a7129421cc37eb694cb3 /pdf-over-gui/src/main
parentaba3a45006ddc1603c9827c3ef3c07ea56ec87cf (diff)
downloadmocca-62db75f575d6d808d483bd9e60065c72bf964761.tar.gz
mocca-62db75f575d6d808d483bd9e60065c72bf964761.tar.bz2
mocca-62db75f575d6d808d483bd9e60065c72bf964761.zip
+ Signature block language configuration
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@242 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java31
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java81
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java33
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java23
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java2
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties2
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties2
12 files changed, 200 insertions, 9 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java
index 0c6101b9..77e2f764 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java
@@ -54,23 +54,23 @@ public class Messages {
currentLocale = locale;
}
- private static ResourceBundle getBundle() {
- if(!bundles.containsKey(currentLocale)) {
+ private static ResourceBundle getBundle(Locale locale) {
+ if(!bundles.containsKey(locale)) {
ResourceBundle tmp = null;
try {
- tmp = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+ tmp = ResourceBundle.getBundle(BUNDLE_NAME, locale);
} catch(Exception e) {
- log.error("NO RESOURCE BUNDLE FOR " + currentLocale.toString(), e); //$NON-NLS-1$
+ log.error("NO RESOURCE BUNDLE FOR " + locale.toString(), e); //$NON-NLS-1$
tmp = ResourceBundle.getBundle(BUNDLE_NAME);
}
if(tmp == null) {
- log.error("NO RESOURCE BUNDLE FOR " + currentLocale.toString()); //$NON-NLS-1$
+ log.error("NO RESOURCE BUNDLE FOR " + locale.toString()); //$NON-NLS-1$
tmp = ResourceBundle.getBundle(BUNDLE_NAME);
}
- bundles.put(currentLocale, tmp);
+ bundles.put(locale, tmp);
return tmp;
}
- return bundles.get(currentLocale);
+ return bundles.get(locale);
}
/**
@@ -80,7 +80,22 @@ public class Messages {
*/
public static String getString(String key) {
try {
- return getBundle().getString(key);
+ return getBundle(currentLocale).getString(key);
+ //return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Gets the localized message
+ * @param key the key
+ * @param locale the locale to use
+ * @return the localized message
+ */
+ public static String getString(String key, Locale locale) {
+ try {
+ return getBundle(locale).getString(key);
//return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
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 1c403c59..733e2d97 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
@@ -66,6 +66,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
Text txtOutputFolder;
Combo cmbBKUAuswahl;
Combo cmbLocaleAuswahl;
+ Combo cmbSigningLangAuswahl;
String[] bkuStrings;
Button btnAutomatischePositionierung;
Scale sclTransparenz;
@@ -78,6 +79,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
private Label lblTransparenzRechts;
private Label lblTransparenzLinks;
private Label lblTransparenz;
+ private Label lblSigningLanguage;
/**
* @param parent
@@ -200,6 +202,63 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
});
+ this.lblSigningLanguage = new Label(this.grpSignatur, SWT.READ_ONLY);
+ FormData fd_lblSigningLanguage = new FormData();
+ //fd_lblSigningLanguage.right = new FormAttachment(100, -5);
+ fd_lblSigningLanguage.top = new FormAttachment(this.sclTransparenz, 5);
+ fd_lblSigningLanguage.left = new FormAttachment(0, 5);
+ this.lblSigningLanguage.setLayoutData(fd_lblSigningLanguage);
+
+ FontData[] fD_lblSigningLanguage = this.lblSigningLanguage.getFont()
+ .getFontData();
+ fD_lblSigningLanguage[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblSigningLanguage.setFont(new Font(Display.getCurrent(),
+ fD_lblSigningLanguage[0]));
+
+ this.lblSigningLanguage.setText(Messages.getString("advanced_config.SigBlockLang")); //$NON-NLS-1$
+
+ this.cmbSigningLangAuswahl = new Combo(this.grpSignatur, SWT.READ_ONLY);
+ FormData fd_cmbSigningLangAuswahl = new FormData();
+ fd_cmbSigningLangAuswahl.right = new FormAttachment(100, -5);
+ fd_cmbSigningLangAuswahl.top = new FormAttachment(this.sclTransparenz, 5);
+ fd_cmbSigningLangAuswahl.left = new FormAttachment(this.lblSigningLanguage, 5);
+
+ FontData[] fD_cmbSigningLangAuswahl = this.cmbSigningLangAuswahl.getFont()
+ .getFontData();
+ fD_cmbSigningLangAuswahl[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.cmbSigningLangAuswahl.setFont(new Font(Display.getCurrent(),
+ fD_cmbSigningLangAuswahl[0]));
+
+ String[] localeSignStrings = new String[Constants.SUPPORTED_LOCALES.length];
+
+ for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; ++i) {
+ localeSignStrings[i] = Constants.SUPPORTED_LOCALES[i].getDisplayLanguage(Constants.SUPPORTED_LOCALES[i]);
+ }
+
+ this.cmbSigningLangAuswahl.setToolTipText(Messages.getString("advanced_config.SigBlockLang_ToolTip")); //$NON-NLS-1$
+
+ this.cmbSigningLangAuswahl.setItems(localeSignStrings);
+
+ this.cmbSigningLangAuswahl.setLayoutData(fd_cmbSigningLangAuswahl);
+
+ this.cmbSigningLangAuswahl.setToolTipText(Messages
+ .getString("advanced_config.LocaleSelection_ToolTip")); //$NON-NLS-1$
+
+ this.cmbSigningLangAuswahl.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer
+ .getSignLocale();
+ Locale selectedLocale = Constants.
+ SUPPORTED_LOCALES[AdvancedConfigurationComposite.this.cmbSigningLangAuswahl
+ .getSelectionIndex()];
+ if (!currentLocale.equals(selectedLocale)) {
+ performSignLocaleSelectionChanged(selectedLocale);
+ }
+ }
+ });
+
this.grpBkuAuswahl = new Group(this, SWT.NONE);
this.grpBkuAuswahl.setText(Messages
.getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$
@@ -495,12 +554,30 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
log.warn("NO Locale match for " + locale); //$NON-NLS-1$
return 0;
}
+
+ int getSignLocaleElementIndex(Locale locale) {
+ for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; i++) {
+ if (Constants.SUPPORTED_LOCALES[i].equals(locale)) {
+ log.debug("Locale: " + locale + " IDX: " + i); //$NON-NLS-1$ //$NON-NLS-2$
+ return i;
+ }
+ }
+
+ log.warn("NO Locale match for " + locale); //$NON-NLS-1$
+ return 0;
+ }
void performLocaleSelectionChanged(Locale selected) {
log.debug("Selected Locale: " + selected); //$NON-NLS-1$
this.configurationContainer.setLocale(selected);
this.cmbLocaleAuswahl.select(this.getLocaleElementIndex(selected));
}
+
+ void performSignLocaleSelectionChanged(Locale selected) {
+ log.debug("Selected Sign Locale: " + selected); //$NON-NLS-1$
+ this.configurationContainer.setSignLocale(selected);
+ this.cmbSigningLangAuswahl.select(this.getSignLocaleElementIndex(selected));
+ }
void performPositionSelection(boolean automatic) {
log.debug("Selected Position: " + automatic); //$NON-NLS-1$
@@ -543,6 +620,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.sclTransparenz.setSelection(this.configurationContainer
.getPlaceholderTransparency());
this.performLocaleSelectionChanged(this.configurationContainer.getLocale());
+ this.performSignLocaleSelectionChanged(this.configurationContainer.getSignLocale());
}
/*
@@ -609,5 +687,8 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.lblTransparenz.setText(Messages
.getString("advanced_config.SigPHTransparency")); //$NON-NLS-1$
+
+ this.lblSigningLanguage.setText(Messages.getString("advanced_config.SigBlockLang")); //$NON-NLS-1$
+ this.cmbSigningLangAuswahl.setToolTipText(Messages.getString("advanced_config.SigBlockLang_ToolTip")); //$NON-NLS-1$
}
}
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 9376c0ae..bbe37ea2 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
@@ -292,6 +292,8 @@ public class ConfigurationComposite extends StateComposite {
this.configurationContainer.setLocale(this.configProvider.getConfigLocale());
+ this.configurationContainer.setSignLocale(this.configProvider.getSignLocale());
+
this.configurationContainer.setBKUSelection(this.configProvider
.getDefaultBKU());
try {
@@ -403,6 +405,7 @@ public class ConfigurationComposite extends StateComposite {
}
this.configManipulator.setLocale(this.configurationContainer.getLocale());
+ this.configManipulator.setSignLocale(this.configurationContainer.getSignLocale());
this.configManipulator
.setPlaceholderTransparency(this.configurationContainer
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 6764b0ef..c1c6ce04 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
@@ -467,7 +467,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
@Override
public void widgetSelected(SelectionEvent e) {
SimpleConfigurationComposite.this.txtSignatureNote.setText(
- Messages.getString("simple_config.Note_Default")); //$NON-NLS-1$
+ Messages.getString("simple_config.Note_Default", //$NON-NLS-1$
+ SimpleConfigurationComposite.this.configurationContainer.getSignLocale()));
}
});
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
index c5f0b930..02633774 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
@@ -80,6 +80,11 @@ public interface ConfigManipulator {
public static final String LOCALE_CONFIG = "LOCALE"; //$NON-NLS-1$
/**
+ * The locale config parameter
+ */
+ public static final String SIGN_LOCALE_CONFIG = "SIGNLOCALE"; //$NON-NLS-1$
+
+ /**
* The proxy host config parameter
*/
public static final String PROXY_HOST_CONFIG = "PROXY_HOST"; //$NON-NLS-1$
@@ -175,4 +180,10 @@ public interface ConfigManipulator {
* @param locale the locale
*/
public void setLocale(Locale locale);
+
+ /**
+ * Sets the locale to be used!
+ * @param locale the locale
+ */
+ public void setSignLocale(Locale locale);
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java
index f0b53cbf..af3e3b05 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java
@@ -117,6 +117,12 @@ public interface ConfigProvider {
public Locale getConfigLocale();
/**
+ * Gets the configured locale
+ * @return the configured locale
+ */
+ public Locale getSignLocale();
+
+ /**
* Loads the current configuration to the current configuration file
* @param configSource
* @throws IOException
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java
index e0b8872b..ccfae554 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java
@@ -67,6 +67,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
private String defaultPassword = STRING_EMPTY;
private Locale locale = Locale.getDefault();
+ private Locale signLocale = Locale.getDefault();
private String emblem = STRING_EMPTY;
@@ -371,6 +372,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
props.setProperty(LOCALE_CONFIG, LocaleSerializer.getParsableString(configLocale));
}
+ Locale signLocale = this.getSignLocale();
+ if(signLocale != null) {
+ props.setProperty(SIGN_LOCALE_CONFIG, LocaleSerializer.getParsableString(signLocale));
+ }
+
SignaturePosition pos = this.getDefaultSignaturePosition();
if (pos == null) {
@@ -431,6 +437,13 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
if(targetLocale != null) {
this.setLocale(targetLocale);
}
+
+ String signlocalString = config.getProperty(ConfigManipulator.SIGN_LOCALE_CONFIG);
+
+ Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString);
+ if(signtargetLocale != null) {
+ this.setSignLocale(signtargetLocale);
+ }
String bku = config
.getProperty(ConfigManipulator.MOBILE_BKU_URL_CONFIG);
@@ -588,4 +601,24 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
}
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setSignLocale(java.util.Locale)
+ */
+ @Override
+ public void setSignLocale(Locale locale) {
+ if(locale == null) {
+ this.signLocale = Locale.getDefault();
+ } else {
+ this.signLocale = locale;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignLocale()
+ */
+ @Override
+ public Locale getSignLocale() {
+ return this.signLocale;
+ }
+
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java
index 9d4d2ccc..b9c80f6b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java
@@ -155,4 +155,16 @@ public interface ConfigurationContainer {
* @return the locale
*/
public Locale getLocale();
+
+ /**
+ * Sets the locale
+ * @param locale the locale
+ */
+ public void setSignLocale(Locale locale);
+
+ /**
+ * Gets the locale
+ * @return the locale
+ */
+ public Locale getSignLocale();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
index b5565963..1e8db610 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
@@ -75,6 +75,11 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
protected Locale locale = null;
/**
+ * Holds the locale
+ */
+ protected Locale signLocale = null;
+
+ /**
* Holds the output folder
*/
protected String folder = null;
@@ -303,5 +308,23 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
public Locale getLocale() {
return this.locale;
}
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignLocale(java.util.Locale)
+ */
+ @Override
+ public void setSignLocale(Locale locale) {
+ this.signLocale = locale;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignLocale()
+ */
+ @Override
+ public Locale getSignLocale() {
+ return this.signLocale;
+ }
}
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 4a097e8f..e3fac772 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
@@ -101,6 +101,8 @@ public class PrepareSigningState extends State {
this.state.signatureParameter.setProperty("SIG_NOTE", configuration.getSigantureNote()); //$NON-NLS-1$
}
+ this.state.signatureParameter.setSignatureLanguage(configuration.getSignLocale().getLanguage());
+
this.state.signingState = this.state.signer.prepare(this.state.signatureParameter);
} catch (Exception e) {
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
index a0510ec9..740a09d1 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
@@ -20,6 +20,8 @@ advanced_config.Signature_Title=Si&gnature
advanced_config.SigPHTransparency=Signature placeholder transparency
advanced_config.SigPHTransparencyMax=Opaque
advanced_config.SigPHTransparencyMin=Invisible
+advanced_config.SigBlockLang=Signature block language
+advanced_config.SigBlockLang_ToolTip=Select the language used in the signature block
argument.error.output=is not a directory
argument.help.bku=Select the CCE to use. Values are: LOCAL, MOBILE. Example: -b <option>
argument.help.config=Defines which configuration file to use. Example: -c <config file>
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
index df95a8fb..419496b2 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
@@ -20,6 +20,8 @@ advanced_config.Signature_Title=Si&gnatur
advanced_config.SigPHTransparency=Signaturplatzhalter-Transparenz
advanced_config.SigPHTransparencyMax=Undurchsichtig
advanced_config.SigPHTransparencyMin=Unsichtbar
+advanced_config.SigBlockLang=Sprache für Signaturblock
+advanced_config.SigBlockLang_ToolTip=Wählen Sie eine Sprache für den Signaturblock
argument.error.output=ist kein Ordner
argument.help.bku=Wählen Sie die BKU. Gültige Werte: LOCAL, MOBILE. Bsp.: -b <bku>
argument.help.config=Auswahl der Konfigurationsdatei. Bsp.: -c <Dateiname>