summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:15:21 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:15:21 +0000
commitb0c952a6b07d622a4ff3fc213605357781217370 (patch)
tree688c9dd36563651248eed91453243e221567e883 /pdf-over-gui
parenteff7792da78754417d26e615f49e610d8c8ab999 (diff)
downloadpdf-over-b0c952a6b07d622a4ff3fc213605357781217370.tar.gz
pdf-over-b0c952a6b07d622a4ff3fc213605357781217370.tar.bz2
pdf-over-b0c952a6b07d622a4ff3fc213605357781217370.zip
Use localized strings for lang selection
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@224 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java92
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java16
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java8
4 files changed, 52 insertions, 75 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
index 46ff7977..e570a773 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
@@ -15,6 +15,8 @@
*/
package at.asit.pdfover.gui;
+import java.util.Locale;
+
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
@@ -24,7 +26,10 @@ import org.eclipse.swt.widgets.Display;
public class Constants {
/** Current display - used for Colors */
- static private Display display = Display.getCurrent();
+ private static Display display = Display.getCurrent();
+
+ /** Supported locales */
+ public static final Locale[] SUPPORTED_LOCALES = { Locale.ENGLISH, Locale.GERMAN };
/** Main window height */
public static final int MAINWINDOW_HEIGHT = 780;
@@ -50,9 +55,7 @@ public class Constants {
/** Main bar inactive text color */
public static final Color MAINBAR_INACTIVE_TEXTCOLOR = new Color(display, 0x40, 0x40, 0x40);
- /**
- * Drag and Drop background color
- */
+ /** Drop background color */
public static final Color DROP_BACK = new Color(display, 0xFF, 0xFF, 0xFF);
/** Drop border color */
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 2f061402..b5537ba0 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
@@ -68,7 +68,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
Combo cmbBKUAuswahl;
Combo cmbLocaleAuswahl;
String[] bkuStrings;
- String[] localeStrings;
Button btnAutomatischePositionierung;
Scale sclTransparenz;
private Group grpSignatur;
@@ -394,12 +393,13 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.cmbLocaleAuswahl.setFont(new Font(Display.getCurrent(),
fD_cmbLocaleAuswahl[0]));
- this.localeStrings = new String[2];
-
- this.localeStrings[0] = LocaleSerializer.getParseableString(Locale.ENGLISH);
- this.localeStrings[1] = LocaleSerializer.getParseableString(Locale.GERMAN);
-
- this.cmbLocaleAuswahl.setItems(this.localeStrings);
+ String[] localeStrings = new String[Constants.SUPPORTED_LOCALES.length];
+
+ for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; ++i) {
+ localeStrings[i] = Constants.SUPPORTED_LOCALES[i].getDisplayLanguage();
+ }
+
+ this.cmbLocaleAuswahl.setItems(localeStrings);
this.cmbLocaleAuswahl.setLayoutData(fd_cmbLocaleAuswahl);
@@ -410,14 +410,13 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
@Override
public void widgetSelected(SelectionEvent e) {
- int selectionIndex = getLocaleElementIndex((AdvancedConfigurationComposite.this.configurationContainer
- .getLocale()));
- if (AdvancedConfigurationComposite.this.cmbLocaleAuswahl
- .getSelectionIndex() != selectionIndex) {
- selectionIndex = AdvancedConfigurationComposite.this.cmbLocaleAuswahl
- .getSelectionIndex();
- performLocleSelectionChanged((AdvancedConfigurationComposite.this.cmbLocaleAuswahl
- .getItem(selectionIndex)));
+ Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer
+ .getLocale();
+ Locale selectedLocale = Constants.
+ SUPPORTED_LOCALES[AdvancedConfigurationComposite.this.cmbLocaleAuswahl
+ .getSelectionIndex()];
+ if (!currentLocale.equals(selectedLocale)) {
+ performLocaleSelectionChanged(selectedLocale);
}
}
});
@@ -454,47 +453,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
log.warn("NO BKU match for " + bkuName); //$NON-NLS-1$
return 0;
}
-
- int getLocaleElementIndex(Locale locale) {
- String lookup = LocaleSerializer.getParseableString(locale);
- //String bkuName = Messages.getString(lookup);
-
- for (int i = 0; i < this.localeStrings.length; i++) {
- if (this.localeStrings[i].equals(lookup)) {
- log.debug("BKU: " + lookup + " IDX: " + i); //$NON-NLS-1$ //$NON-NLS-2$
- return i;
- }
- }
-
- log.warn("NO Locale match for " + lookup); //$NON-NLS-1$
- return 0;
- }
-
- void performLocleSelectionChanged(String selected) {
- try {
- Locale locale = LocaleSerializer.parseFromString(selected);
- if(locale != null) {
- this.performLocaleSelectionChanged(locale);
- } else {
- log.error("Failed to parse LOCALE value: " + selected); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.getString("error.InvalidLocale"), ERROR_BUTTONS.OK); //$NON-NLS-1$
- dialog.open();
- }
- } catch (Exception ex) {
- log.error("Failed to parse LOCALE value: " + selected, ex); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.getString("error.InvalidLocale"), ERROR_BUTTONS.OK); //$NON-NLS-1$
- dialog.open();
- }
- }
-
- void performLocaleSelectionChanged(Locale selected) {
- log.debug("Selected Locale: " + selected.toString()); //$NON-NLS-1$
- this.configurationContainer.setLocale(selected);
- this.cmbLocaleAuswahl.select(this.getLocaleElementIndex(selected));
- }
-
void performBKUSelectionChanged(BKUs selected) {
log.debug("Selected BKU: " + selected.toString()); //$NON-NLS-1$
@@ -504,7 +462,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
void performBKUSelectionChanged(String selected) {
try {
- BKUs bkuvalue = resolvBKU(selected);
+ BKUs bkuvalue = resolveBKU(selected);
this.performBKUSelectionChanged(bkuvalue);
} catch (Exception ex) {
log.error("Failed to parse BKU value: " + selected, ex); //$NON-NLS-1$
@@ -514,7 +472,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
}
- BKUs resolvBKU(String localizedBKU) {
+ BKUs resolveBKU(String localizedBKU) {
int blen = BKUs.values().length;
for (int i = 0; i < blen; i++) {
@@ -527,6 +485,24 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
return BKUs.NONE;
}
+ int getLocaleElementIndex(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 performPositionSelection(boolean automatic) {
log.debug("Selected Position: " + automatic); //$NON-NLS-1$
this.configurationContainer.setAutomaticPosition(automatic);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java
index fccbedc8..cdd5b5cc 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java
@@ -22,7 +22,6 @@ import java.util.Locale;
*
*/
public class LocaleSerializer {
-
/**
* Parse a locale from a string
* @param localeString the string
@@ -34,24 +33,23 @@ public class LocaleSerializer {
return null;
}
- Locale targetLocal = null;
+ Locale targetLocale = null;
Locale[] locale = Locale.getAvailableLocales();
for(int i = 0; i < locale.length; i++) {
if(locale[i].toString().equals(localeString)) {
- targetLocal = locale[i];
+ targetLocale = locale[i];
break;
}
}
- return targetLocal;
+ return targetLocale;
}
-
+
/**
- * creates a parseable string for a locale
+ * creates a parsable string for a locale
* @param locale the locale
- * @return the parseable string
+ * @return the parsable string
*/
- public static String getParseableString(Locale locale) {
+ public static String getParsableString(Locale locale) {
return locale.toString();
}
-
}
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 801f626c..e0b8872b 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
@@ -368,7 +368,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
Locale configLocale = this.getConfigLocale();
if(configLocale != null) {
- props.setProperty(LOCALE_CONFIG, LocaleSerializer.getParseableString(configLocale));
+ props.setProperty(LOCALE_CONFIG, LocaleSerializer.getParsableString(configLocale));
}
SignaturePosition pos = this.getDefaultSignaturePosition();
@@ -427,9 +427,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
String localString = config.getProperty(ConfigManipulator.LOCALE_CONFIG);
- Locale targetLocal = LocaleSerializer.parseFromString(localString);
- if(targetLocal != null) {
- this.setLocale(targetLocal);
+ Locale targetLocale = LocaleSerializer.parseFromString(localString);
+ if(targetLocale != null) {
+ this.setLocale(targetLocale);
}
String bku = config