diff options
6 files changed, 349 insertions, 288 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 4819e00a..2ce3171b 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 @@ -33,10 +33,10 @@ public class Constants { public static final Locale[] SUPPORTED_LOCALES = { Locale.GERMAN, Locale.ENGLISH }; /** Main window height */ - public static final int MAINWINDOW_HEIGHT = 780; + public static final int DEFAULT_MAINWINDOW_HEIGHT = 780; /** Main window width */ - public static final int MAINWINDOW_WIDTH = 600; + public static final int DEFAULT_MAINWINDOW_WIDTH = 600; /** Main bar height */ public static final int MAINBAR_HEIGHT = 60; @@ -141,4 +141,6 @@ public class Constants { /** 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/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index 8f670bd3..92688c82 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -203,7 +203,7 @@ public class MainWindow { */ protected void createContents() { this.shell = new Shell(); - getShell().setSize(Constants.MAINWINDOW_WIDTH, Constants.MAINWINDOW_HEIGHT); + this.shell.setSize(this.stateMachine.getConfigProvider().getMainWindowSize()); try { Display display = Display.getCurrent(); Monitor primary = display.getPrimaryMonitor(); @@ -223,9 +223,9 @@ public class MainWindow { this.shell.setImage(shellicon); - getShell().setLayout(new FormLayout()); + this.shell.setLayout(new FormLayout()); - this.mainbar = new Composite(getShell(), SWT.NONE); + this.mainbar = new Composite(this.shell, SWT.NONE); this.mainbar.setLayout(new FormLayout()); this.mainBarFormData = new FormData(); this.mainBarFormData.left = new FormAttachment(0, 10); @@ -337,7 +337,7 @@ public class MainWindow { this.btn_end.setToolTipText(Messages.getString("main.done")); //$NON-NLS-1$ this.buttonMap.put(Buttons.FINAL, this.btn_end); - this.container = new Composite(getShell(), SWT.RESIZE); + this.container = new Composite(this.shell, SWT.RESIZE); this.containerFormData = new FormData(); this.containerFormData.bottom = new FormAttachment(100, -10); this.containerFormData.right = new FormAttachment(100, -10); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java index df443b94..416a3a85 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java @@ -105,7 +105,7 @@ public class SignaturePanel extends JPanel { public SignaturePanel(PDFFile pdf) { super(new BorderLayout()); setDocument(pdf); - setPreferredSize(new Dimension(Constants.MAINWINDOW_WIDTH, Constants.MAINWINDOW_HEIGHT - Constants.MAINBAR_HEIGHT)); + setPreferredSize(new Dimension(Constants.DEFAULT_MAINWINDOW_WIDTH, Constants.DEFAULT_MAINWINDOW_HEIGHT - Constants.MAINBAR_HEIGHT)); setFocusable(true); addMouseListener(this.mouseListener); addMouseMotionListener(this.mouseListener); 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 8784dc02..68922802 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 @@ -18,11 +18,13 @@ package at.asit.pdfover.gui.workflow; import java.io.IOException; import java.util.Locale; +import org.eclipse.swt.graphics.Point; + import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; /** - * + * An interface for setting the configuration */ public interface ConfigManipulator { /** @@ -30,86 +32,92 @@ public interface ConfigManipulator { * @param bku the bku type */ public void setDefaultBKU(BKUs bku); - + /** * Sets the default signature position * * @param signaturePosition the default signature position */ public void setDefaultSignaturePosition(SignaturePosition signaturePosition); - + /** * Sets the signature placeholder transparency * * @param transparency the signature placeholder transparency */ void setPlaceholderTransparency(int transparency); - + /** * Sets the default mobile number * @param number the default mobile number */ public void setDefaultMobileNumber(String number); - + /** * Sets the default password * @param password the default password */ public void setDefaultPassword(String password); - + /** * Sets the default emblem * * @param emblem the default emblem */ public void setDefaultEmblem(String emblem); - + /** * Sets the proxy host * @param host the proxy host */ public void setProxyHost(String host); - + /** * Sets the proxy port * * @param port the proxy port */ public void setProxyPort(int port); - + /** * Sets the configuration file * @param configurationFile */ public void setConfigurationFile(String configurationFile); - + /** * Sets the default output folder * @param outputFolder the default output folder */ public void setDefaultOutputFolder(String outputFolder); - + /** * Sets the signature note text * @param note the signature note text */ public void setSignatureNote(String note); - + /** * Saves the current configuration to the current configuration file * @throws IOException */ public void saveCurrentConfiguration() throws IOException; - + /** - * Sets the locale to be used! + * Sets the locale to be used * @param locale the locale */ public void setLocale(Locale locale); - + /** - * Sets the locale to be used! - * @param locale the locale + * Sets the signature locale to be used + * @param locale the signature locale */ public void setSignLocale(Locale locale); + + /** + * Sets the default main window size + * @param size a Point describing the size + */ + public void setMainWindowSize(Point size); } 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 f98edd2e..c5d7fdd7 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 @@ -19,11 +19,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.Locale; +import org.eclipse.swt.graphics.Point; + import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; /** - * + * An interface for reading the configuration */ public interface ConfigProvider { /** @@ -31,31 +33,31 @@ public interface ConfigProvider { */ public static final String SIGN_POS_REGEX = "(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?);p=(\\d))|(auto)|(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?))"; //$NON-NLS-1$ - + /** * Gets the configuration file * @return the configuration file */ public String getConfigurationFile(); - + /** * Gets the configuration directory * @return the configuration directory */ public String getConfigurationDirectory(); - + /** * Gets the default Mobile number * @return the default mobile number */ public String getDefaultMobileNumber(); - + /** * Gets the password to use for Mobile BKU * @return the password */ public String getDefaultPassword(); - + /** * Gets the filename of the default emblem * @return the emblem @@ -67,61 +69,67 @@ public interface ConfigProvider { * @return the proxy hostname or ip address */ public String getProxyHost(); - + /** * Gets the proxy port * @return the proxy port */ public int getProxyPort(); - + /** * Get the default configured BKU * @return the default configured BKU */ public BKUs getDefaultBKU(); - + /** * Get the default configured SignaturePosition * @return the default configured SignaturePosition or null if not configured */ public SignaturePosition getDefaultSignaturePosition(); - + /** * Get the transparency of the signature placeholder * @return the transparency of the signature placeholder */ public int getPlaceholderTransparency(); - + /** * Gets the default output folder for signed documents * @return the default output folder */ public String getDefaultOutputFolder(); - + /** * Gets the mobile BKU URL * @return the mobile BKU URL */ public String getMobileBKUURL(); - + /** * Get the signature note text to use * @return the signature note text */ public String getSignatureNote(); - + /** * Gets the configured locale * @return the configured locale */ public Locale getConfigLocale(); - + /** * Gets the configured locale * @return the configured locale */ public Locale getSignLocale(); - + + /** + * Gets the configured MainWindow size + * @return the configured MainWindow size + */ + public Point getMainWindowSize(); + /** * Loads the current configuration to the current configuration file * @param configSource 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 83dea41f..daa04261 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 @@ -25,6 +25,7 @@ import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.swt.graphics.Point; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,7 +69,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private int proxyPort = -1; - private String mobileBKU = Constants.DEFAULT_MOBILE_BKU_URL; + private String mobileBKUURL = Constants.DEFAULT_MOBILE_BKU_URL; private String outputFolder = STRING_EMPTY; @@ -76,6 +77,278 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private int placeholderTransparency = 170; + private Point mainWindowSize; + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#loadConfiguration(java.io + * .InputStream) + */ + @Override + public void loadConfiguration(InputStream configSource) throws IOException { + + Properties config = new Properties(); + + config.load(configSource); + + // Set Emblem + this.setDefaultEmblem(config + .getProperty(Constants.CFG_EMBLEM)); + + // Set Mobile Phone Number + this.setDefaultMobileNumber(config + .getProperty(Constants.CFG_MOBILE_NUMBER)); + + // Set signature note + this.setSignatureNote(config + .getProperty(Constants.CFG_SIGNATURE_NOTE)); + + // Set Proxy Host + this.setProxyHost(config + .getProperty(Constants.CFG_PROXY_HOST)); + + // Set Output Folder + this.setDefaultOutputFolder(config + .getProperty(Constants.CFG_OUTPUT_FOLDER)); + + String localString = config.getProperty(Constants.CFG_LOCALE); + + Locale targetLocale = LocaleSerializer.parseFromString(localString); + if(targetLocale != null) { + this.setLocale(targetLocale); + } + + String signlocalString = config.getProperty(Constants.CFG_SIGN_LOCALE); + + Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString); + if(signtargetLocale != null) { + this.setSignLocale(signtargetLocale); + } + + String bku = config + .getProperty(Constants.CFG_MOBILE_BKU_URL); + + if (bku != null && !bku.isEmpty()) { + this.mobileBKUURL = bku; + } + + // Set Proxy Port + String proxyPortString = config + .getProperty(Constants.CFG_PROXY_PORT); + + if (proxyPortString != null && !proxyPortString.trim().isEmpty()) { + int port = Integer.parseInt(proxyPortString); + + if (port > 0 && port <= 0xFFFF) { + this.setProxyPort(port); + } else { + log.warn("Proxy port is out of range!: " + port); //$NON-NLS-1$ + } + } + + // Set Default BKU + String bkuString = config.getProperty(Constants.CFG_BKU); + + BKUs defaultBKU = BKUs.NONE; + + try { + defaultBKU = BKUs.valueOf(bkuString); + } catch (IllegalArgumentException ex) { + log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ + defaultBKU = BKUs.NONE; + } catch (NullPointerException ex) { + log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ + defaultBKU = BKUs.NONE; + } + + this.setDefaultBKU(defaultBKU); + + // Set Signature placeholder transparency + int transparency = 170; + try { + transparency = Integer + .parseInt(config + .getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY)); + } catch (NumberFormatException e) { + log.debug("Couldn't parse placeholder transparency", e); //$NON-NLS-1$ + // ignore parsing exception + } + this.setPlaceholderTransparency(transparency); + + // Set MainWindow size + int width = Constants.DEFAULT_MAINWINDOW_WIDTH; + int height = Constants.DEFAULT_MAINWINDOW_HEIGHT; + String size = config.getProperty(Constants.CFG_MAINWINDOW_SIZE); + parse: { + if (size == null) + break parse; + int pos = size.indexOf(','); + if (pos <= 0) + break parse; + + try { + width = Integer.parseInt(size.substring(0, pos).trim()); + height = Integer.parseInt(size.substring(pos + 1).trim()); + } catch (NumberFormatException e) { + log.debug("Couldn't parse main window size", e); //$NON-NLS-1$ + // ignore parsing exception + } + } + this.mainWindowSize = new Point(width, height); + + // Set Signature Position + String signaturePosition = config + .getProperty(Constants.CFG_SIGNATURE_POSITION); + + SignaturePosition position = null; + + if (signaturePosition != null && !signaturePosition.trim().isEmpty()) { + + signaturePosition = signaturePosition.trim().toLowerCase(); + + Pattern pattern = Pattern.compile(SIGN_POS_REGEX); + + Matcher matcher = pattern.matcher(signaturePosition); + + if (matcher.matches()) { + if (matcher.groupCount() == 8) { + if (matcher.group(1) != null) { + // we have format: x=..;y=..;p=... + try { + // group 2 = x value + float x = Float.parseFloat(matcher.group(2)); + + // group 3 = y value + float y = Float.parseFloat(matcher.group(3)); + + // group 4 = p value + int p = Integer.parseInt(matcher.group(3)); + + position = new SignaturePosition(x, y, p); + } catch (NumberFormatException ex) { + log.error( + "Signature Position read from config failed: Not a valid number", ex); //$NON-NLS-1$ + } + } else if (matcher.group(5) != null) { + // we have format auto + position = new SignaturePosition(); + } else if (matcher.group(6) != null) { + // we have format x=...;y=...; + // group 7 = x value + float x = Float.parseFloat(matcher.group(7)); + + // group 8 = y value + float y = Float.parseFloat(matcher.group(8)); + + position = new SignaturePosition(x, y); + } + } else { + log.error("Signature Position read from config failed: wrong group Count!"); //$NON-NLS-1$ + } + } else { + log.error("Signature Position read from config failed: not matching string"); //$NON-NLS-1$ + } + + } + + this.setDefaultSignaturePosition(position); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#saveCurrentConfiguration() + */ + @Override + public void saveCurrentConfiguration() throws IOException { + String filename = this.getConfigurationFile(); + + File configFile = new File(this.getConfigurationDirectory() + + File.separator + filename); + + Properties props = new Properties(); + props.clear(); + + props.setProperty(Constants.CFG_BKU, this.getDefaultBKU().toString()); + props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHost()); + props.setProperty(Constants.CFG_PROXY_PORT, + Integer.toString(this.getProxyPort())); + props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblem()); + props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote()); + props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumber()); + props.setProperty(Constants.CFG_OUTPUT_FOLDER, this.getDefaultOutputFolder()); + props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, + Integer.toString(this.getPlaceholderTransparency())); + + props.setProperty(Constants.CFG_MAINWINDOW_SIZE, + this.mainWindowSize.x + "," + this.mainWindowSize.y); //$NON-NLS-1$ + + Locale configLocale = this.getConfigLocale(); + if(configLocale != null) { + props.setProperty(Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale)); + } + + Locale signLocale = this.getSignLocale(); + if(signLocale != null) { + props.setProperty(Constants.CFG_SIGN_LOCALE, LocaleSerializer.getParsableString(signLocale)); + } + + SignaturePosition pos = this.getDefaultSignaturePosition(); + + if (pos == null) { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, ""); //$NON-NLS-1$ + } else if (pos.useAutoPositioning()) { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, "auto"); //$NON-NLS-1$ + } else { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, + String.format((Locale) null, "x=%f;y=%f;p=%d", //$NON-NLS-1$ + pos.getX(), pos.getY(), pos.getPage())); + } + + FileOutputStream outputstream = new FileOutputStream(configFile, false); + + props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$ + + log.info("Configuration file saved to " + configFile.getAbsolutePath()); //$NON-NLS-1$ + } + + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() + */ + @Override + public String getConfigurationDirectory() { + return Constants.CONFIG_DIRECTORY; + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setConfigurationFile(java + * .lang.String) + */ + @Override + public void setConfigurationFile(String configurationFile) { + this.configurationFile = configurationFile; + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationFile() + */ + @Override + public String getConfigurationFile() { + return this.configurationFile; + } + /** * Sets the default bku type * @@ -295,253 +568,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { */ @Override public String getMobileBKUURL() { - return this.mobileBKU; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() - */ - @Override - public String getConfigurationDirectory() { - return Constants.CONFIG_DIRECTORY; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#setConfigurationFile(java - * .lang.String) - */ - @Override - public void setConfigurationFile(String configurationFile) { - this.configurationFile = configurationFile; - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationFile() - */ - @Override - public String getConfigurationFile() { - return this.configurationFile; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#saveCurrentConfiguration() - */ - @Override - public void saveCurrentConfiguration() throws IOException { - String filename = this.getConfigurationFile(); - - File configFile = new File(this.getConfigurationDirectory() - + File.separator + filename); - - Properties props = new Properties(); - props.clear(); - - props.setProperty(Constants.CFG_BKU, this.getDefaultBKU().toString()); - props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHost()); - props.setProperty(Constants.CFG_PROXY_PORT, - Integer.toString(this.getProxyPort())); - props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblem()); - props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote()); - props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumber()); - props.setProperty(Constants.CFG_OUTPUT_FOLDER, this.getDefaultOutputFolder()); - props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, - Integer.toString(this.getPlaceholderTransparency())); - - Locale configLocale = this.getConfigLocale(); - if(configLocale != null) { - props.setProperty(Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale)); - } - - Locale signLocale = this.getSignLocale(); - if(signLocale != null) { - props.setProperty(Constants.CFG_SIGN_LOCALE, LocaleSerializer.getParsableString(signLocale)); - } - - SignaturePosition pos = this.getDefaultSignaturePosition(); - - if (pos == null) { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, ""); //$NON-NLS-1$ - } else if (pos.useAutoPositioning()) { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, "auto"); //$NON-NLS-1$ - } else { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, - String.format((Locale) null, "x=%f;y=%f;p=%d", //$NON-NLS-1$ - pos.getX(), pos.getY(), pos.getPage())); - } - - FileOutputStream outputstream = new FileOutputStream(configFile, false); - - props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$ - - log.info("Configuration file saved to " + configFile.getAbsolutePath()); //$NON-NLS-1$ - - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#loadConfiguration(java.io - * .InputStream) - */ - @Override - public void loadConfiguration(InputStream configSource) throws IOException { - - Properties config = new Properties(); - - config.load(configSource); - - // Set Emblem - this.setDefaultEmblem(config - .getProperty(Constants.CFG_EMBLEM)); - - // Set Mobile Phone Number - this.setDefaultMobileNumber(config - .getProperty(Constants.CFG_MOBILE_NUMBER)); - - // Set signature note - this.setSignatureNote(config - .getProperty(Constants.CFG_SIGNATURE_NOTE)); - - // Set Proxy Host - this.setProxyHost(config - .getProperty(Constants.CFG_PROXY_HOST)); - - // Set Output Folder - this.setDefaultOutputFolder(config - .getProperty(Constants.CFG_OUTPUT_FOLDER)); - - String localString = config.getProperty(Constants.CFG_LOCALE); - - Locale targetLocale = LocaleSerializer.parseFromString(localString); - if(targetLocale != null) { - this.setLocale(targetLocale); - } - - String signlocalString = config.getProperty(Constants.CFG_SIGN_LOCALE); - - Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString); - if(signtargetLocale != null) { - this.setSignLocale(signtargetLocale); - } - - String bku = config - .getProperty(Constants.CFG_MOBILE_BKU_URL); - - if (bku != null && !bku.isEmpty()) { - this.mobileBKU = bku; - } - - // Set Proxy Port - String proxyPortString = config - .getProperty(Constants.CFG_PROXY_PORT); - - if (proxyPortString != null && !proxyPortString.trim().isEmpty()) { - int port = Integer.parseInt(proxyPortString); - - if (port > 0 && port <= 0xFFFF) { - this.setProxyPort(port); - } else { - log.warn("Proxy port is out of range!: " + port); //$NON-NLS-1$ - } - } - - // Set Default BKU - String bkuString = config.getProperty(Constants.CFG_BKU); - - BKUs defaultBKU = BKUs.NONE; - - try { - defaultBKU = BKUs.valueOf(bkuString); - } catch (IllegalArgumentException ex) { - log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ - defaultBKU = BKUs.NONE; - } catch (NullPointerException ex) { - log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ - defaultBKU = BKUs.NONE; - } - - this.setDefaultBKU(defaultBKU); - - // Set Signature placeholder transparency - int transparency = 170; - try { - transparency = Integer - .parseInt(config - .getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY)); - } catch (NumberFormatException e) { - log.debug("Couldn't parse placeholder transparency", e); //$NON-NLS-1$ - // ignore parsing exception - } - this.setPlaceholderTransparency(transparency); - - // Set Signature Position - String signaturePosition = config - .getProperty(Constants.CFG_SIGNATURE_POSITION); - - SignaturePosition position = null; - - if (signaturePosition != null && !signaturePosition.trim().isEmpty()) { - - signaturePosition = signaturePosition.trim().toLowerCase(); - - Pattern pattern = Pattern.compile(SIGN_POS_REGEX); - - Matcher matcher = pattern.matcher(signaturePosition); - - if (matcher.matches()) { - if (matcher.groupCount() == 8) { - if (matcher.group(1) != null) { - // we have format: x=..;y=..;p=... - try { - // group 2 = x value - float x = Float.parseFloat(matcher.group(2)); - - // group 3 = y value - float y = Float.parseFloat(matcher.group(3)); - - // group 4 = p value - int p = Integer.parseInt(matcher.group(3)); - - position = new SignaturePosition(x, y, p); - } catch (NumberFormatException ex) { - log.error( - "Signature Position read from config failed: Not a valid number", ex); //$NON-NLS-1$ - } - } else if (matcher.group(5) != null) { - // we have format auto - position = new SignaturePosition(); - } else if (matcher.group(6) != null) { - // we have format x=...;y=...; - // group 7 = x value - float x = Float.parseFloat(matcher.group(7)); - - // group 8 = y value - float y = Float.parseFloat(matcher.group(8)); - - position = new SignaturePosition(x, y); - } - } else { - log.error("Signature Position read from config failed: wrong group Count!"); //$NON-NLS-1$ - } - } else { - log.error("Signature Position read from config failed: not matching string"); //$NON-NLS-1$ - } - - } - - this.setDefaultSignaturePosition(position); + return this.mobileBKUURL; } /* @@ -612,4 +639,20 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { return this.signLocale; } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setMainWindowSize(org.eclipse.swt.graphics.Point) + */ + @Override + public void setMainWindowSize(Point size) { + this.mainWindowSize = size; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMainWindowSize() + */ + @Override + public Point getMainWindowSize() { + return this.mainWindowSize; + } + } |