diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow')
4 files changed, 59 insertions, 2 deletions
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 d7b23e58..c5f0b930 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 @@ -16,6 +16,7 @@ package at.asit.pdfover.gui.workflow; import java.io.IOException; +import java.util.Locale; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; @@ -74,6 +75,11 @@ public interface ConfigManipulator { public static final String EMBLEM_CONFIG = "EMBLEM"; //$NON-NLS-1$ /** + * The locale config parameter + */ + public static final String LOCALE_CONFIG = "LOCALE"; //$NON-NLS-1$ + + /** * The proxy host config parameter */ public static final String PROXY_HOST_CONFIG = "PROXY_HOST"; //$NON-NLS-1$ @@ -163,4 +169,10 @@ public interface ConfigManipulator { * @throws IOException */ public void saveCurrentConfiguration() throws IOException; + + /** + * Sets the locale to be used! + * @param locale the locale + */ + public void setLocale(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 b545f400..f0b53cbf 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 @@ -17,6 +17,7 @@ package at.asit.pdfover.gui.workflow; import java.io.IOException; import java.io.InputStream; +import java.util.Locale; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; @@ -110,6 +111,12 @@ public interface ConfigProvider { public String getSigantureNote(); /** + * Gets the configured locale + * @return the configured locale + */ + public Locale getConfigLocale(); + + /** * 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 8da0a069..801f626c 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 @@ -28,6 +28,8 @@ import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.Messages; +import at.asit.pdfover.gui.utils.LocaleSerializer; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; @@ -64,6 +66,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private String defaultPassword = STRING_EMPTY; + private Locale locale = Locale.getDefault(); + private String emblem = STRING_EMPTY; private String proxyHost = STRING_EMPTY; @@ -362,6 +366,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { props.setProperty(SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG, Integer.toString(this.getPlaceholderTransparency())); + Locale configLocale = this.getConfigLocale(); + if(configLocale != null) { + props.setProperty(LOCALE_CONFIG, LocaleSerializer.getParseableString(configLocale)); + } + SignaturePosition pos = this.getDefaultSignaturePosition(); if (pos == null) { @@ -416,9 +425,16 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.setDefaultOutputFolder(config .getProperty(ConfigManipulator.OUTPUT_FOLDER_CONFIG)); + String localString = config.getProperty(ConfigManipulator.LOCALE_CONFIG); + + Locale targetLocal = LocaleSerializer.parseFromString(localString); + if(targetLocal != null) { + this.setLocale(targetLocal); + } + String bku = config .getProperty(ConfigManipulator.MOBILE_BKU_URL_CONFIG); - + if (bku != null && !bku.equals("")) { //$NON-NLS-1$ this.mobileBKU = bku; } @@ -550,4 +566,26 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { } } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigLocale() + */ + @Override + public Locale getConfigLocale() { + return this.locale; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setLocale(java.util.Locale) + */ + @Override + public void setLocale(Locale locale) { + if(locale == null) { + this.locale = Locale.getDefault(); + } else { + this.locale = locale; + Locale.setDefault(locale); + Messages.setLocale(locale); + } + } + } 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 44513806..d877cdcf 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 @@ -101,7 +101,7 @@ public class PositioningState extends State { log.error("Failed to display PDF document", e); //$NON-NLS-1$ ErrorDialog dialog = new ErrorDialog( this.stateMachine.getGUIProvider().getMainShell(), - e.getMessage(), ERROR_BUTTONS.RETRY_CANCEL); + e.getLocalizedMessage(), ERROR_BUTTONS.RETRY_CANCEL); if(dialog.open() == SWT.RETRY) { this.stateMachine.update(); } else { |