From 29fe21cebaa0ed7811da9373ef514f6f5057b4e9 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:13:10 +0000 Subject: + added signature note (TODO: localize in composite) git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@201 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../gui/composites/ConfigurationComposite.java | 6 ++ .../composites/SimpleConfigurationComposite.java | 68 ++++++++++++++++++ .../pdfover/gui/workflow/ConfigManipulator.java | 12 ++++ .../asit/pdfover/gui/workflow/ConfigProvider.java | 6 ++ .../pdfover/gui/workflow/ConfigProviderImpl.java | 82 ++++++++++++++++------ .../gui/workflow/ConfigurationContainer.java | 12 ++++ .../gui/workflow/ConfigurationContainerImpl.java | 23 ++++++ .../gui/workflow/states/PrepareSigningState.java | 4 ++ 8 files changed, 193 insertions(+), 20 deletions(-) (limited to 'pdf-over-gui/src/main/java') 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 52cf567c..f87604f0 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 @@ -279,6 +279,9 @@ public class ConfigurationComposite extends StateComposite { .setPlaceholderTransparency(this.configProvider .getPlaceholderTransparency()); + this.configurationContainer.setSignatureNote( + this.configProvider.getSigantureNote()); + this.configurationContainer.setBKUSelection(this.configProvider .getDefaultBKU()); try { @@ -397,6 +400,9 @@ public class ConfigurationComposite extends StateComposite { .setDefaultOutputFolder(this.configurationContainer .getOutputFolder()); + this.configManipulator.setSignatureNote(this.configurationContainer + .getSignatureNote()); + this.configManipulator.setProxyHost(this.configurationContainer .getProxyHost()); this.configManipulator.setProxyPort(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 6e707156..5d32ec30 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 @@ -522,6 +522,60 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { 100, -1 * (portSize.y + 10)); } }); + + // TODO: localize ... + Group grpSignatureNote = new Group(this, SWT.NONE); + FormData fd_grpSignatureNote = new FormData(); + fd_grpSignatureNote.right = new FormAttachment(100, -5); + fd_grpSignatureNote.top = new FormAttachment(grpProxy, 5); + fd_grpSignatureNote.left = new FormAttachment(0, 5); + grpSignatureNote.setLayoutData(fd_grpSignatureNote); + grpSignatureNote.setLayout(new GridLayout(2, false)); + grpSignatureNote.setText("Signature Note"); + + FontData[] fD_grpSignatureNote = grpSignatureNote.getFont().getFontData(); + fD_grpSignatureNote[0].setHeight(Constants.TEXT_SIZE_NORMAL); + grpSignatureNote.setFont(new Font(Display.getCurrent(), fD_grpSignatureNote[0])); + + + Label lblSignatureNote = new Label(grpSignatureNote, SWT.NONE); + GridData gd_lblSignatureNote = new GridData(SWT.LEFT, SWT.CENTER, false, + false, 1, 1); + gd_lblSignatureNote.widthHint = 66; + lblSignatureNote.setLayoutData(gd_lblSignatureNote); + lblSignatureNote.setBounds(0, 0, 57, 15); + lblSignatureNote.setText("Text:"); + + FontData[] fD_lblSignatureNote = lblSignatureNote.getFont().getFontData(); + fD_lblSignatureNote[0].setHeight(Constants.TEXT_SIZE_NORMAL); + lblSignatureNote.setFont(new Font(Display.getCurrent(), fD_lblSignatureNote[0])); + + this.txtSignatureNote = new Text(grpSignatureNote, SWT.BORDER); + this.txtSignatureNote.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, + 1, 1)); + + FontData[] fD_txtSignatureNote = this.txtProxyHost.getFont().getFontData(); + fD_txtSignatureNote[0].setHeight(Constants.TEXT_SIZE_NORMAL); + this.txtSignatureNote.setFont(new Font(Display.getCurrent(), + fD_txtSignatureNote[0])); + + this.txtSignatureNote.addFocusListener(new FocusAdapter() { + + @Override + public void focusLost(FocusEvent e) { + processSignatureNoteChanged(); + } + }); + + this.txtSignatureNote.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_RETURN) { + processSignatureNoteChanged(); + } + } + }); } /** @@ -564,6 +618,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { Label lblEmblem; private Text txtProxyHost; Text txtProxyPort; + Text txtSignatureNote; Text txtMobileNumber; // Text txtEmblemFile; String emblemFile; @@ -765,6 +820,11 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { log.error("processProxyHost: ", ex); //$NON-NLS-1$ } } + + void processSignatureNoteChanged() { + String note = this.txtSignatureNote.getText(); + this.configurationContainer.setSignatureNote(note); + } /** * @@ -878,6 +938,12 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { this.txtProxyPort.setText(Integer.toString(port)); } + String note = this.configurationContainer.getSignatureNote(); + + if (note != null) { + this.txtSignatureNote.setText(note); + } + String host = this.configurationContainer.getProxyHost(); if (host != null) { @@ -905,6 +971,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { // Fall through case 2: this.plainProxyPortSetter(); + case 3: + this.processSignatureNoteChanged(); } //this.plainEmblemSetter(this.emblemFile); } 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 1e584f40..d7b23e58 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 @@ -57,6 +57,12 @@ public interface ConfigManipulator { */ public static final String MOBILE_NUMBER_CONFIG = "MOBILE_NUMBER"; //$NON-NLS-1$ + /** + * The signature note config parameter + */ + public static final String SIGNATURE_NOTE_CONFIG = "SIGNATURE_NOTE"; //$NON-NLS-1$ + + /** * Mobile bku url config parameter */ @@ -146,6 +152,12 @@ public interface ConfigManipulator { */ 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 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 910bdcbb..b545f400 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 @@ -103,6 +103,12 @@ public interface ConfigProvider { */ public String getMobileBKUURL(); + /** + * Get the signature note text to use + * @return the signature note text + */ + public String getSigantureNote(); + /** * 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 49747262..8da0a069 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 @@ -48,13 +48,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { */ public static String CONFIG_DIRECTORY = System.getProperty("user.home") + "/.pdfover"; //$NON-NLS-1$ //$NON-NLS-2$ - /** * Gets the Default Mobile URL */ public static final String DEFAULT_MOBILE_URL = "https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ - - + private SignaturePosition defaultSignaturePosition = null; /** @@ -73,11 +71,13 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private String configurationFile = ConfigManipulator.DEFAULT_CONFIG_FILE; private int proxyPort = -1; - + private String mobileBKU = DEFAULT_MOBILE_URL; private String outputFolder = STRING_EMPTY; + private String signatureNote = STRING_EMPTY; + private int placeholderTransparency = 170; /** @@ -134,8 +134,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.placeholderTransparency = transparency; } - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getPlaceholderTransparency() + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getPlaceholderTransparency() */ @Override public int getPlaceholderTransparency() { @@ -289,7 +292,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { return this.outputFolder; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUURL() */ @Override @@ -297,8 +302,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { return this.mobileBKU; } - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() */ @Override public String getConfigurationDirectory() { @@ -337,7 +345,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { public void saveCurrentConfiguration() throws IOException { String filename = this.getConfigurationFile(); - File configFile = new File(this.getConfigurationDirectory() + "/" + filename); //$NON-NLS-1$ + File configFile = new File(this.getConfigurationDirectory() + + "/" + filename); //$NON-NLS-1$ Properties props = new Properties(); props.clear(); @@ -347,9 +356,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { props.setProperty(PROXY_PORT_CONFIG, Integer.toString(this.getProxyPort())); props.setProperty(EMBLEM_CONFIG, this.getDefaultEmblem()); + props.setProperty(SIGNATURE_NOTE_CONFIG, this.getSigantureNote()); props.setProperty(MOBILE_NUMBER_CONFIG, this.getDefaultMobileNumber()); props.setProperty(OUTPUT_FOLDER_CONFIG, this.getDefaultOutputFolder()); - props.setProperty(SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG, Integer.toString(this.getPlaceholderTransparency())); + props.setProperty(SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG, + Integer.toString(this.getPlaceholderTransparency())); SignaturePosition pos = this.getDefaultSignaturePosition(); @@ -382,9 +393,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { public void loadConfiguration(InputStream configSource) throws IOException { Properties config = new Properties(); - + config.load(configSource); - + // Set Emblem this.setDefaultEmblem(config .getProperty(ConfigManipulator.EMBLEM_CONFIG)); @@ -393,21 +404,25 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.setDefaultMobileNumber(config .getProperty(ConfigManipulator.MOBILE_NUMBER_CONFIG)); + // Set signature note + this.setSignatureNote(config + .getProperty(ConfigManipulator.SIGNATURE_NOTE_CONFIG)); + // Set Proxy Host this.setProxyHost(config .getProperty(ConfigManipulator.PROXY_HOST_CONFIG)); // Set Output Folder this.setDefaultOutputFolder(config - .getProperty(ConfigManipulator.OUTPUT_FOLDER_CONFIG)); - + .getProperty(ConfigManipulator.OUTPUT_FOLDER_CONFIG)); + String bku = config .getProperty(ConfigManipulator.MOBILE_BKU_URL_CONFIG); - - if(bku != null && !bku.equals("")) { //$NON-NLS-1$ + + if (bku != null && !bku.equals("")) { //$NON-NLS-1$ this.mobileBKU = bku; } - + // Set Proxy Port String proxyPortString = config .getProperty(ConfigManipulator.PROXY_PORT_CONFIG); @@ -442,8 +457,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { // Set Signature placeholder transparency int transparency = 170; try { - transparency = Integer.parseInt(config - .getProperty(ConfigManipulator.SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG)); + transparency = Integer + .parseInt(config + .getProperty(ConfigManipulator.SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG)); } catch (NumberFormatException e) { log.debug("Couldn't parse placeholder transparency", e); //$NON-NLS-1$ // ignore parsing exception @@ -508,4 +524,30 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.setDefaultSignaturePosition(position); } + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSigantureNote() + */ + @Override + public String getSigantureNote() { + return this.signatureNote; + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setSignatureNote(java. + * lang.String) + */ + @Override + public void setSignatureNote(String note) { + if (note == null || note.trim().equals("")) { //$NON-NLS-1$ + this.signatureNote = STRING_EMPTY; + } else { + this.signatureNote = note; + } + } + } 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 693d5e16..0c4e1065 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 @@ -63,6 +63,18 @@ public interface ConfigurationContainer { */ public void setProxyHost(String host); + /** + * Gets the signature note + * @return the signature note + */ + public String getSignatureNote(); + + /** + * Sets the signature note + * @param note the signature note + */ + public void setSignatureNote(String note); + /** * Gets the proxy port * 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 de6ef608..2cf03444 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 @@ -58,6 +58,11 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { */ protected String proxyHost = null; + /** + * Holds the signatureNote + */ + protected String signatureNote = null; + /** * Holds the proxy port number */ @@ -256,5 +261,23 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { public void setOutputFolder(String folder) { this.folder = folder; } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignatureNote() + */ + @Override + public String getSignatureNote() { + return this.signatureNote; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignatureNote(java.lang.String) + */ + @Override + public void setSignatureNote(String note) { + this.signatureNote = note; + } } 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 77362682..504bd3b7 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 @@ -97,6 +97,10 @@ public class PrepareSigningState extends State { this.state.signatureParameter.setEmblem(new FileNameEmblem(configuration.getDefaultEmblem())); } + if(configuration.getSigantureNote() != null && !configuration.getSigantureNote().equals("")) { //$NON-NLS-1$ + this.state.signatureParameter.setProperty("SIG_NOTE", configuration.getSigantureNote()); //$NON-NLS-1$ + } + this.state.signingState = this.state.signer.prepare(this.state.signatureParameter); } catch (Exception e) { -- cgit v1.2.3