diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java | 199 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java | 3 |
2 files changed, 118 insertions, 84 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 ecf84865..2be35d56 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 @@ -16,7 +16,9 @@ package at.asit.pdfover.gui; import java.io.File; +import java.io.FileInputStream; import java.util.Locale; +import java.util.Properties; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; @@ -31,13 +33,115 @@ public class Constants { /** Current display - used for Colors */ private static Display display = Display.getCurrent(); - private static enum Themes { DEFAULT, GEMPLUSH }; - - private static Themes theme = Themes.DEFAULT; - /** Supported locales */ public static final Locale[] SUPPORTED_LOCALES = { Locale.GERMAN, Locale.ENGLISH }; + /** Configuration directory */ + public static String CONFIG_DIRECTORY = System.getProperty("user.home") + File.separator + ".pdf-over"; //$NON-NLS-1$ //$NON-NLS-2$ + + /** The default configuration file name */ + public static final String DEFAULT_CONFIG_FILENAME = "PDF-Over.config"; //$NON-NLS-1$ + + /** The default log4j file name */ + public static final String DEFAULT_LOG4J_FILENAME = "log4j.properties"; //$NON-NLS-1$ + + /** File suffix for the signed document */ + public final static String SIGNED_SUFFIX = "_signed"; //$NON-NLS-1$ + + /** Default Mobile BKU URL */ + public static final String DEFAULT_MOBILE_BKU_URL = "https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ + + /** Default Mobile BKU type */ + public static final MobileBKUs DEFAULT_MOBILE_BKU_TYPE = MobileBKUs.A_TRUST; + + /** Default signature placeholder transparency */ + public static final int DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY = 170; + + /** How far to displace the signature with the arrow keys */ + public static final int SIGNATURE_KEYBOARD_POSITIONING_OFFSET = 15; + + + /* Configuration parameters */ + + /** The bku config parameter */ + public static final String CFG_BKU = "BKU"; //$NON-NLS-1$ + + /** The value for the Signature position in the configuration file + * values for this entry are: + * + * x=vx;y=vy;p=vp or auto + * + * vx:= float value + * vy:= float value + * vp:= integer value + */ + public static final String CFG_SIGNATURE_POSITION = "SIGNATURE_POSITION"; //$NON-NLS-1$ + + /** This signature placeholder transparency config parameter (0-255) */ + public static final String CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY = "SIGNATURE_PLACEHOLDER_TRANSPARENCY"; //$NON-NLS-1$ + + /** The mobile number config parameter */ + public static final String CFG_MOBILE_NUMBER = "MOBILE_NUMBER"; //$NON-NLS-1$ + + /** The signature note config parameter */ + public static final String CFG_SIGNATURE_NOTE = "SIGNATURE_NOTE"; //$NON-NLS-1$ + + /** Mobile bku url config parameter */ + public static final String CFG_MOBILE_BKU_URL = "MOBILE_BKU_URL"; //$NON-NLS-1$ + + /** Mobile bku type config parameter */ + public static final String CFG_MOBILE_BKU_TYPE = "MOBILE_BKU_TYPE"; //$NON-NLS-1$ + + /** The emblem config parameter */ + public static final String CFG_EMBLEM = "EMBLEM"; //$NON-NLS-1$ + + /** The locale config parameter */ + public static final String CFG_LOCALE = "LOCALE"; //$NON-NLS-1$ + + /** The signature locale config parameter */ + public static final String CFG_SIGN_LOCALE = "SIGNLOCALE"; //$NON-NLS-1$ + + /** The proxy host config parameter */ + public static final String CFG_PROXY_HOST = "PROXY_HOST"; //$NON-NLS-1$ + + /** The proxy port config parameter */ + public static final String CFG_PROXY_PORT = "PROXY_PORT"; //$NON-NLS-1$ + + /** The output folder config parameter */ + public static final String CFG_OUTPUT_FOLDER = "OUTPUT_FOLDER"; //$NON-NLS-1$ + + /** The main window size (Format: width,height) */ + public static final String CFG_MAINWINDOW_SIZE = "MAINWINDOW_SIZE"; //$NON-NLS-1$ + + /** The theme */ + public static final String CFG_THEME = "THEME"; //$NON-NLS-1$ + + + /* Theme constants */ + + /** The available themes */ + public static enum Themes { + /** Default theme */ DEFAULT, + /** GemPlush theme */ GEMPLUSH + }; + + /** The used theme */ + public static final Themes THEME = getTheme(); + private static Themes getTheme() { + File f = new File(CONFIG_DIRECTORY + File.separatorChar + DEFAULT_CONFIG_FILENAME); + if (f.canRead()) + { + try { + Properties config = new Properties(); + config.load(new FileInputStream(f)); + return Themes.valueOf(config.getProperty(CFG_THEME).toUpperCase()); + } catch (Exception e) { + // Ignore + } + } + return Themes.DEFAULT; + } + /** Main window height */ public static final int DEFAULT_MAINWINDOW_HEIGHT = 780; @@ -50,7 +154,7 @@ public class Constants { /** Main bar active background - light start of gradient */ public static final Color MAINBAR_ACTIVE_BACK_LIGHT = getMainbarActiveBackLight(); private static Color getMainbarActiveBackLight() { - switch (theme) { + switch (THEME) { default: case DEFAULT: return new Color(display, 0xB4, 0xCD, 0xEC); @@ -62,7 +166,7 @@ public class Constants { /** Main bar active background - dark end of gradient */ public static final Color MAINBAR_ACTIVE_BACK_DARK = getMainbarActiveBackDark(); private static Color getMainbarActiveBackDark() { - switch (theme) { + switch (THEME) { default: case DEFAULT: return new Color(display, 0x6B, 0xA5, 0xD9); @@ -74,7 +178,7 @@ public class Constants { /** Main bar inactive background */ public static final Color MAINBAR_INACTIVE_BACK = getMainbarInactiveBack(); private static Color getMainbarInactiveBack() { - switch (theme) { + switch (THEME) { default: case DEFAULT: return new Color(display, 0xD4, 0xE7, 0xF1); @@ -107,13 +211,16 @@ public class Constants { /** Big text size */ public static final int TEXT_SIZE_BIG = 14; + + /* Resources */ + /** Shell icon resource */ public static final String RES_ICON = "/icons/icon.png"; //$NON-NLS-1$ /** Config image resource */ public static final String RES_IMG_CONFIG = getResImgConfig(); private static String getResImgConfig() { - switch (theme) { + switch (THEME) { default: case DEFAULT: return "/img/config.png"; //$NON-NLS-1$ @@ -145,80 +252,4 @@ public class Constants { /** Accepted certificate list resource */ public static final String RES_CERT_LIST = RES_CERT_PATH + "certificates.xml"; //$NON-NLS-1$ - - /** Default signature placeholder transparency */ - public static final int DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY = 170; - - /** How far to displace the signature with the arrow keys */ - public static final int SIGNATURE_KEYBOARD_POSITIONING_OFFSET = 15; - - /** File suffix for the signed document */ - public final static String SIGNED_SUFFIX = "_signed"; //$NON-NLS-1$ - - /** Default Mobile BKU URL */ - public static final String DEFAULT_MOBILE_BKU_URL = "https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ - - /** Default Mobile BKU type */ - public static final MobileBKUs DEFAULT_MOBILE_BKU_TYPE = MobileBKUs.A_TRUST; - - /** Configuration directory */ - public static String CONFIG_DIRECTORY = System.getProperty("user.home") + File.separator + ".pdf-over"; //$NON-NLS-1$ //$NON-NLS-2$ - - /** The default configuration file name */ - public static final String DEFAULT_CONFIG_FILENAME = "PDF-Over.config"; //$NON-NLS-1$ - - /** The default log4j file name */ - public static final String DEFAULT_LOG4J_FILENAME = "log4j.properties"; //$NON-NLS-1$ - - /* Configuration parameters */ - - /** The bku config parameter */ - public static final String CFG_BKU = "BKU"; //$NON-NLS-1$ - - /** The value for the Signature position in the configuration file - * values for this entry are: - * - * x=vx;y=vy;p=vp or auto - * - * vx:= float value - * vy:= float value - * vp:= integer value - */ - public static final String CFG_SIGNATURE_POSITION = "SIGNATURE_POSITION"; //$NON-NLS-1$ - - /** This signature placeholder transparency config parameter (0-255) */ - public static final String CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY = "SIGNATURE_PLACEHOLDER_TRANSPARENCY"; //$NON-NLS-1$ - - /** The mobile number config parameter */ - public static final String CFG_MOBILE_NUMBER = "MOBILE_NUMBER"; //$NON-NLS-1$ - - /** The signature note config parameter */ - public static final String CFG_SIGNATURE_NOTE = "SIGNATURE_NOTE"; //$NON-NLS-1$ - - /** Mobile bku url config parameter */ - public static final String CFG_MOBILE_BKU_URL = "MOBILE_BKU_URL"; //$NON-NLS-1$ - - /** Mobile bku type config parameter */ - public static final String CFG_MOBILE_BKU_TYPE = "MOBILE_BKU_TYPE"; //$NON-NLS-1$ - - /** The emblem config parameter */ - public static final String CFG_EMBLEM = "EMBLEM"; //$NON-NLS-1$ - - /** The locale config parameter */ - public static final String CFG_LOCALE = "LOCALE"; //$NON-NLS-1$ - - /** The signature locale config parameter */ - public static final String CFG_SIGN_LOCALE = "SIGNLOCALE"; //$NON-NLS-1$ - - /** The proxy host config parameter */ - public static final String CFG_PROXY_HOST = "PROXY_HOST"; //$NON-NLS-1$ - - /** The proxy port config parameter */ - public static final String CFG_PROXY_PORT = "PROXY_PORT"; //$NON-NLS-1$ - - /** The output folder config parameter */ - public static final String CFG_OUTPUT_FOLDER = "OUTPUT_FOLDER"; //$NON-NLS-1$ - - /** The main window size. (Format: width,height) */ - public static final String CFG_MAINWINDOW_SIZE = "MAINWINDOW_SIZE"; //$NON-NLS-1$ } 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 63a69a53..e9fbe1c2 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 @@ -319,6 +319,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, if (mobileBKUType != Constants.DEFAULT_MOBILE_BKU_TYPE) props.setProperty(Constants.CFG_MOBILE_BKU_TYPE, mobileBKUType.toString()); + if (Constants.THEME != Constants.Themes.DEFAULT) + props.setProperty(Constants.CFG_THEME, Constants.THEME.name()); + FileOutputStream outputstream = new FileOutputStream(configFile, false); props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$ |