summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:56:29 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:56:29 +0000
commit12fe32df6f5b17abb5d1f9bac9f5fb87b961f0c2 (patch)
tree814ddcd71dee2298e62825a615e37da72cdc123a /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
parent9cdc13fdb999f0e3482e22c1eb63ed0ee4d72c6f (diff)
downloadpdf-over-12fe32df6f5b17abb5d1f9bac9f5fb87b961f0c2.tar.gz
pdf-over-12fe32df6f5b17abb5d1f9bac9f5fb87b961f0c2.tar.bz2
pdf-over-12fe32df6f5b17abb5d1f9bac9f5fb87b961f0c2.zip
Configuration Changes
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@49 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java60
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java42
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java218
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainer.java114
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainerImpl.java227
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java96
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java349
7 files changed, 1046 insertions, 60 deletions
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
new file mode 100644
index 00000000..5b826097
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import org.eclipse.swt.widgets.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.states.State;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.SWT;
+
+/**
+ *
+ */
+public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
+ /**
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public AdvancedConfigurationComposite(Composite parent, int style,
+ State state, ConfigurationContainer container) {
+ super(parent, style, state, container);
+
+ Label lblAdvancedConfigLayout = new Label(this, SWT.NONE);
+ lblAdvancedConfigLayout.setBounds(113, 126, 243, 15);
+ lblAdvancedConfigLayout.setText("Advanced Config Layout!");
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(AdvancedConfigurationComposite.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
new file mode 100644
index 00000000..831a4aa6
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+
+import org.eclipse.swt.widgets.Composite;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ *
+ */
+public abstract class BaseConfigurationComposite extends StateComposite {
+
+ /**
+ * the configuration container
+ */
+ protected ConfigurationContainer configurationContainer;
+
+ /**
+ * @param parent
+ * @param style
+ * @param state
+ * @param configuration
+ */
+ public BaseConfigurationComposite(Composite parent, int style, State state, ConfigurationContainer configuration) {
+ super(parent, style, state);
+ this.configurationContainer = configuration;
+ }
+}
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
new file mode 100644
index 00000000..db58ae4a
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.states.State;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormAttachment;
+
+/**
+ *
+ */
+public class ConfigurationComposite extends StateComposite {
+
+ /**
+ *
+ */
+ private final class ConfigurationModeSelectionListener implements
+ SelectionListener {
+ /**
+ *
+ */
+ public ConfigurationModeSelectionListener() {
+ // Nothing to do
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (ConfigurationComposite.this.configComposite instanceof SimpleConfigurationComposite) {
+ // switch to advanced
+ ConfigurationComposite.this.configComposite.dispose();
+ ConfigurationComposite.this.configComposite = new AdvancedConfigurationComposite(
+ ConfigurationComposite.this.containerComposite,
+ ConfigurationComposite.this.style,
+ ConfigurationComposite.this.state,
+ ConfigurationComposite.this.configurationContainer);
+ ConfigurationComposite.this.btnAdvanced.setText("Simple");
+ } else {
+ // switch to simple
+ ConfigurationComposite.this.configComposite.dispose();
+ ConfigurationComposite.this.configComposite = new SimpleConfigurationComposite(
+ ConfigurationComposite.this.containerComposite,
+ ConfigurationComposite.this.style,
+ ConfigurationComposite.this.state,
+ ConfigurationComposite.this.configurationContainer);
+ ConfigurationComposite.this.btnAdvanced.setText("Advanced");
+ }
+
+ ConfigurationComposite.this.compositeStack.topControl = ConfigurationComposite.this.configComposite;
+ ConfigurationComposite.this.doLayout();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do
+ }
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(ConfigurationComposite.class);
+
+ ConfigManipulator configManipulator = null;
+
+ BaseConfigurationComposite configComposite;
+
+ ConfigurationContainer configurationContainer = new ConfigurationContainerImpl();
+
+ StackLayout compositeStack = new StackLayout();
+
+ int style;
+
+ Composite containerComposite;
+
+ boolean userDone = false;
+
+ Button btnAdvanced;
+
+ /**
+ * Sets the configuration manipulator
+ *
+ * @param manipulator
+ */
+ public void setConfigManipulator(ConfigManipulator manipulator) {
+ this.configManipulator = manipulator;
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public ConfigurationComposite(Composite parent, int style, State state) {
+ super(parent, SWT.FILL | style, state);
+ this.style = SWT.FILL | style;
+
+ this.setLayout(new FormLayout());
+
+ this.containerComposite = new Composite(this, SWT.FILL | SWT.RESIZE);
+
+ this.configComposite = new SimpleConfigurationComposite(
+ this.containerComposite, SWT.FILL | style, state, this.configurationContainer);
+
+ FormData fd_composite = new FormData();
+ fd_composite.top = new FormAttachment(0, 5);
+ fd_composite.bottom = new FormAttachment(90, -5);
+ fd_composite.left = new FormAttachment(0, 5);
+ fd_composite.right = new FormAttachment(100, -5);
+ this.containerComposite.setLayoutData(fd_composite);
+ this.containerComposite.setLayout(this.compositeStack);
+ this.compositeStack.topControl = this.configComposite;
+
+ this.doLayout();
+
+ Button btnSpeichern = new Button(this, SWT.NONE);
+ FormData fd_btnSpeichern = new FormData();
+ fd_btnSpeichern.left = new FormAttachment(0, 5);
+ fd_btnSpeichern.bottom = new FormAttachment(100, -5);
+ btnSpeichern.setLayoutData(fd_btnSpeichern);
+ btnSpeichern.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+ btnSpeichern.setText("Speichern");
+
+ Button btnAbbrechen = new Button(this, SWT.NONE);
+ FormData fd_btnAbrechen = new FormData();
+ fd_btnAbrechen.left = new FormAttachment(btnSpeichern, 10);
+ fd_btnAbrechen.bottom = new FormAttachment(100, -5);
+ btnAbbrechen.setLayoutData(fd_btnAbrechen);
+ btnAbbrechen.setText("Abbrechen");
+ btnAbbrechen.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ConfigurationComposite.this.userDone = true;
+ ConfigurationComposite.this.state.updateStateMachine();
+ }
+ });
+
+ this.btnAdvanced = new Button(this, SWT.NONE);
+ FormData fd_btnAdvanced = new FormData();
+ fd_btnAdvanced.right = new FormAttachment(100, -5);
+ fd_btnAdvanced.bottom = new FormAttachment(100, -5);
+ this.btnAdvanced.setLayoutData(fd_btnAdvanced);
+ this.btnAdvanced.setText("Advanced");
+ this.btnAdvanced
+ .addSelectionListener(new ConfigurationModeSelectionListener());
+
+ }
+
+ private void storeConfiguration() {
+ // TODO: Collect info from UI and set in ConfigManipulator
+
+ // TODO: call save configuration in ConfigManipulator
+ }
+
+ /**
+ * Checks if the user has finished working with the configuration composite
+ *
+ * @return
+ */
+ public boolean isUserDone() {
+ return this.userDone;
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ Control ctrl = this.compositeStack.topControl;
+ this.containerComposite.layout(true, true);
+ this.getShell().layout(true, true);
+ // Note: SWT only layouts children! No grandchildren!
+ if (ctrl instanceof StateComposite) {
+ ((StateComposite) ctrl).doLayout();
+ }
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainer.java
new file mode 100644
index 00000000..dbc32206
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainer.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
+import at.asit.pdfover.gui.exceptions.InvalidNumberException;
+import at.asit.pdfover.gui.exceptions.InvalidPortException;
+import at.asit.pdfover.signator.BKUs;
+
+/**
+ *
+ */
+public interface ConfigurationContainer {
+
+ /**
+ * Gets the configured emblem
+ * @return the configured emblem
+ */
+ public String getEmblem();
+
+ /**
+ * Sets the emblem
+ * @param emblem the emblem
+ * @throws InvalidEmblemFile
+ */
+ public void setEmblem(String emblem) throws InvalidEmblemFile;
+
+ /**
+ * Gets the mobile phone number
+ * @return the mobile phone number
+ */
+ public String getNumber();
+
+ /**
+ * Sets the mobile phone number
+ * @param number the mobile phone number
+ * @throws InvalidNumberException
+ */
+ public void setNumber(String number) throws InvalidNumberException;
+
+ /**
+ * Gets the proxy host
+ * @return the proxy host
+ */
+ public String getProxyHost();
+
+ /**
+ * Sets the proxy host
+ * @param host the proxy host
+ */
+ public void setProxyHost(String host);
+
+ /**
+ * Gets the proxy port
+ * @return the proxy port
+ */
+ public int getProxyPort();
+
+ /**
+ * Sets the proxy port
+ * @param port the proxy port
+ * @throws InvalidPortException
+ */
+ public void setProxyPort(int port) throws InvalidPortException;
+
+ /**
+ * Gets the automatic position
+ * @return the automatic position
+ */
+ public boolean getAutomaticPosition();
+
+ /**
+ * Sets the automatic position
+ * @param automatic the automatic position
+ */
+ public void setAutomaticPosition(boolean automatic);
+
+ /**
+ * Gets the default BKU
+ * @return the default BKU
+ */
+ public BKUs getBKUSelection();
+
+ /**
+ * Sets the default BKU
+ * @param bkuSelection the default BKU
+ */
+ public void setBKUSelection(BKUs bkuSelection);
+
+ /**
+ * Gets the default output folder
+ * @return the default output folder
+ */
+ public String getOutputFolder();
+
+ /**
+ * Sets the default output folder
+ * @param folder the default output folder
+ */
+ public void setOutputFolder(String folder);
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainerImpl.java
new file mode 100644
index 00000000..f8489d71
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainerImpl.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Display;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
+import at.asit.pdfover.gui.exceptions.InvalidNumberException;
+import at.asit.pdfover.gui.exceptions.InvalidPortException;
+import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper;
+import at.asit.pdfover.signator.BKUs;
+
+/**
+ *
+ */
+public class ConfigurationContainerImpl implements ConfigurationContainer {
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(ConfigurationContainerImpl.class);
+
+
+ /**
+ * the emblem File
+ */
+ protected String emblemFile = null;
+
+ /**
+ * The mobile phone number
+ */
+ protected String mobileNumber = null;
+
+ /**
+ * Holds the proxy Host
+ */
+ protected String proxyHost = null;
+
+ /**
+ * Holds the proxy port number
+ */
+ protected int proxyPort = -1;
+
+ /**
+ * Holds the output folder
+ */
+ protected String folder = null;
+
+ /**
+ * Holds the default BKU to use
+ */
+ protected BKUs defaulBKU = BKUs.NONE;
+
+ /**
+ * Holds the automatic positioning value
+ */
+ protected boolean automaticPositioning = false;
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem()
+ */
+ @Override
+ public String getEmblem() {
+ return this.emblemFile;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setEmblem(java.lang.String)
+ */
+ @Override
+ public void setEmblem(String emblemFile) throws InvalidEmblemFile {
+ if (this.emblemFile == null || this.emblemFile.trim().equals("")) { //$NON-NLS-1$
+ // Ok to set no file ...
+ } else {
+ File imageFile = new File(emblemFile);
+ if (!imageFile.exists()) {
+ throw new InvalidEmblemFile(imageFile,
+ new FileNotFoundException(emblemFile));
+ }
+
+ try {
+ Image img = new Image(Display.getDefault(), new ImageData(
+ emblemFile));
+
+ img.dispose();
+ } catch (Exception ex) {
+ throw new InvalidEmblemFile(imageFile, ex);
+ }
+ }
+
+ this.emblemFile = emblemFile;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getNumber()
+ */
+ @Override
+ public String getNumber() {
+ return this.mobileNumber;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setNumber(java.lang.String)
+ */
+ @Override
+ public void setNumber(String number) throws InvalidNumberException {
+ this.mobileNumber = ATrustHelper.normalizeMobileNumber(number);
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyHost()
+ */
+ @Override
+ public String getProxyHost() {
+ return this.proxyHost;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyHost(java.lang.String)
+ */
+ @Override
+ public void setProxyHost(String host) {
+ this.proxyHost = host;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyPort()
+ */
+ @Override
+ public int getProxyPort() {
+ return this.proxyPort;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyPort(int)
+ */
+ @Override
+ public void setProxyPort(int port) throws InvalidPortException {
+ if(port > 0 && port < 0xFFFF) {
+ this.proxyPort = port;
+ }
+ throw new InvalidPortException(port);
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getAutomaticPosition()
+ */
+ @Override
+ public boolean getAutomaticPosition() {
+ return this.automaticPositioning;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setAutomaticPosition(boolean)
+ */
+ @Override
+ public void setAutomaticPosition(boolean automatic) {
+ this.automaticPositioning = automatic;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getBKUSelection()
+ */
+ @Override
+ public BKUs getBKUSelection() {
+ return this.defaulBKU;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setBKUSelection(at.asit.pdfover.signator.BKUs)
+ */
+ @Override
+ public void setBKUSelection(BKUs bkuSelection) {
+ this.defaulBKU = bkuSelection;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getOutputFolder()
+ */
+ @Override
+ public String getOutputFolder() {
+ return this.folder;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setOutputFolder(java.lang.String)
+ */
+ @Override
+ public void setOutputFolder(String folder) {
+ this.folder = folder;
+ }
+
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
index c1a72fb2..bd630f8e 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
@@ -32,7 +32,17 @@ import org.eclipse.swt.widgets.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.exceptions.InvalidNumberException;
+import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
import at.asit.pdfover.gui.workflow.states.State;
+import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper;
+
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
/**
*
@@ -47,18 +57,8 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
/**
*
*/
- private final class OkSelectionListener extends SelectionAdapter {
- /**
- * Regular expression for mobile phone numbers:
- * this allows the entrance of mobile numbers in the following formats:
- *
- * +(countryCode)99999999999
- * 00(countryCode)99999999999
- * 099999999999
- * 1030199999999999 (A-Trust Test bku)
- */
- private static final String NUMBER_REGEX = "^((\\+[\\d]{2})|(00[\\d]{2})|(0)|(10301))([1-9][\\d]+)$"; //$NON-NLS-1$
-
+ private final class OkSelectionListener implements SelectionListener {
+
/**
* Empty constructor
*/
@@ -71,40 +71,9 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
String number = MobileBKUEnterNumberComposite.this.txt_number
.getText();
- // Verify number and normalize
-
- // Compile and use regular expression
- Pattern pattern = Pattern.compile(NUMBER_REGEX);
- Matcher matcher = pattern.matcher(number);
-
- if (!matcher.find()) {
- MobileBKUEnterNumberComposite.this
- .setErrorMessage("Given phone number is invalid! Example: +43664123456789");
- return;
- }
-
- if (matcher.groupCount() != 6) {
- MobileBKUEnterNumberComposite.this
- .setErrorMessage("Given phone number is invalid! Example: +43664123456789");
- return;
- }
-
- String countryCode = matcher.group(1);
-
- String normalNumber = matcher.group(6);
-
- if (countryCode.equals("10301")) { //$NON-NLS-1$
- // A-Trust Testnumber!
- } else {
-
- countryCode = countryCode.replace("00", "+"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (countryCode.equals("0")) { //$NON-NLS-1$
- countryCode = "+43"; //$NON-NLS-1$
- }
-
- number = countryCode + normalNumber;
- }
+
+ number = ATrustHelper.normalizeMobileNumber(number);
+
MobileBKUEnterNumberComposite.this.setMobileNumber(number);
MobileBKUEnterNumberComposite.this.mobileNumber = number;
@@ -112,30 +81,37 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
String password = MobileBKUEnterNumberComposite.this.txt_password
.getText();
- // TODO: Logic to verify password
-
- if (password.length() < 6 || password.length() > 20) {
- if (password.length() < 6) {
- MobileBKUEnterNumberComposite.this
- .setErrorMessage("Given password is too short!");
- } else {
- MobileBKUEnterNumberComposite.this
- .setErrorMessage("Given password is too long!");
- }
- return;
- }
+ ATrustHelper.validatePassword(password);
MobileBKUEnterNumberComposite.this.mobilePassword = password;
MobileBKUEnterNumberComposite.this.setUserAck(true);
- } catch (Exception ex) {
+ } catch(InvalidNumberException ex) {
+ log.error("Validating input for Mobile BKU failed!", ex); //$NON-NLS-1$
+ MobileBKUEnterNumberComposite.this
+ .setErrorMessage("Given phone number is invalid! Example: +43664123456789");
+ } catch(InvalidPasswordException ex) {
+ log.error("Validating input for Mobile BKU failed!", ex); //$NON-NLS-1$
+ MobileBKUEnterNumberComposite.this
+ .setErrorMessage(ex.getMessage());
+ }
+ catch (Exception ex) {
log.error("Validating input for Mobile BKU failed!", ex); //$NON-NLS-1$
- // TODO: NOT VALID
MobileBKUEnterNumberComposite.this
.setErrorMessage("Given phone number is invalid! Example: +43664123456789");
return;
}
+
MobileBKUEnterNumberComposite.this.state.updateStateMachine();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
}
String mobileNumber;
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
new file mode 100644
index 00000000..b8f31dec
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
@@ -0,0 +1,349 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.apache.fontbox.afm.Composite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ *
+ */
+public class SimpleConfigurationComposite extends BaseConfigurationComposite {
+
+ private Label lblEmblem;
+ private Text text;
+ private Text text_1;
+ private Text txtMobileNumber;
+ Text txtEmblemFile;
+ private Image origEmblem = null;
+
+
+
+ void recalculateEmblemSize() {
+ if (this.origEmblem != null) {
+
+ int width = this.origEmblem.getBounds().width;
+ int height = this.origEmblem.getBounds().height;
+
+ int scaledWidth = this.lblEmblem.getSize().x;
+ int scaledHeight = this.lblEmblem.getSize().y;
+
+ float scaleFactorWidth = (float) scaledWidth / (float) width;
+ float scaleFactorHeight = (float) scaledHeight / (float) height;
+
+ float betterFactor = 1;
+
+ int testHeight = (int) (height * scaleFactorWidth);
+ int testWidth = (int) (width * scaleFactorHeight);
+
+ // check for better scale factor ...
+
+ if (testHeight > scaledHeight) {
+ // width scaling fails!! use Height scaling
+ betterFactor = scaleFactorHeight;
+ } else if (testWidth > scaledWidth) {
+ // height scaling fails!! use Width scaling
+ betterFactor = scaleFactorWidth;
+ } else {
+ // Both are ok test* < scaled*
+
+ int heightDiff = scaledHeight - testHeight;
+
+ int widthDiff = scaledWidth - testWidth;
+
+ if (widthDiff < heightDiff) {
+ // width diff better use scaleFactorHeight
+ betterFactor = scaleFactorHeight;
+ } else {
+ // height diff better or equal so use scaleFactorWidth
+ betterFactor = scaleFactorWidth;
+ }
+ }
+
+ log.debug("Scaling factor: " + betterFactor); //$NON-NLS-1$
+
+ Image emblem = new Image(this.getDisplay(), this.origEmblem
+ .getImageData().scaledTo((int) (width * betterFactor),
+ (int) (height * betterFactor)));
+
+ Image old = this.lblEmblem.getImage();
+
+ if(old != null) {
+ old.dispose();
+ }
+
+ this.lblEmblem.setText(""); //$NON-NLS-1$
+ this.lblEmblem.setImage(emblem);
+ }
+ }
+
+ private void setEmblemFileInternal(final String filename) throws Exception {
+ if (this.configurationContainer.getEmblem() != null) {
+ if (this.configurationContainer.getEmblem().equals(filename)) {
+ return; // Ignore ...
+ }
+ }
+
+ try {
+ this.configurationContainer.setEmblem(filename);
+
+ this.txtEmblemFile.setText(this.configurationContainer.getEmblem());
+
+ if(this.origEmblem != null) {
+ this.origEmblem.dispose();
+ }
+
+ this.origEmblem = new Image(this.getDisplay(), new ImageData(
+ filename));
+
+ this.lblEmblem.setText(""); //$NON-NLS-1$
+
+ this.recalculateEmblemSize();
+ } catch (Exception e) {
+ this.lblEmblem.setText("No Image");
+ this.lblEmblem.setImage(null);
+ if(this.origEmblem != null) {
+ this.origEmblem.dispose();
+ }
+ this.origEmblem = null;
+ throw e;
+ }
+
+ this.lblEmblem.pack();
+ this.lblEmblem.getParent().pack();
+ this.doLayout();
+ }
+
+ void processEmblemChanged() {
+ try {
+ String filename = this.txtEmblemFile.getText();
+ this.setEmblemFileInternal(filename);
+ } catch (Exception ex) {
+ // TODO: Show error message!
+ log.error("processEmblemChanged: ", ex); //$NON-NLS-1$
+ }
+ }
+
+ ConfigurationComposite configurationComposite;
+
+ /**
+ * @return the configurationComposite
+ */
+ public ConfigurationComposite getConfigurationComposite() {
+ return this.configurationComposite;
+ }
+
+ /**
+ * @param configurationComposite the configurationComposite to set
+ */
+ public void setConfigurationComposite(
+ ConfigurationComposite configurationComposite) {
+ this.configurationComposite = configurationComposite;
+ }
+
+ /**
+ * @param parent
+ * @param style
+ * @param state
+ * @param container
+ */
+ public SimpleConfigurationComposite(
+ org.eclipse.swt.widgets.Composite parent, int style, State state, ConfigurationContainer container) {
+ super(parent, style, state, container);
+ setLayout(new FormLayout());
+
+ Group grpHandySignatur = new Group(this, SWT.NONE | SWT.RESIZE);
+ FormData fd_grpHandySignatur = new FormData();
+ fd_grpHandySignatur.right = new FormAttachment(100, -5);
+ fd_grpHandySignatur.left = new FormAttachment(0, 5);
+ fd_grpHandySignatur.top = new FormAttachment(0, 5);
+ fd_grpHandySignatur.bottom = new FormAttachment(20, -5);
+ grpHandySignatur.setLayoutData(fd_grpHandySignatur);
+ grpHandySignatur.setText("Handy Signatur");
+ grpHandySignatur.setLayout(new GridLayout(2, false));
+
+ Label lblMobileNumber = new Label(grpHandySignatur, SWT.NONE
+ | SWT.RESIZE);
+ lblMobileNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
+ false, 1, 1));
+ lblMobileNumber.setText("Handy Nummer:");
+
+ this.txtMobileNumber = new Text(grpHandySignatur, SWT.BORDER
+ | SWT.RESIZE);
+ this.txtMobileNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
+ true, false, 1, 1));
+
+ Group grpBildmarke = new Group(this, SWT.NONE);
+ FormData fd_grpBildmarke = new FormData();
+ fd_grpBildmarke.left = new FormAttachment(0, 5);
+ fd_grpBildmarke.right = new FormAttachment(100, -5);
+ fd_grpBildmarke.bottom = new FormAttachment(65, -5);
+ fd_grpBildmarke.top = new FormAttachment(20, 5);
+ grpBildmarke.setLayoutData(fd_grpBildmarke);
+ grpBildmarke.setLayout(new GridLayout(3, false));
+ grpBildmarke.setText("Bildmarke");
+
+ this.lblEmblem = new Label(grpBildmarke, SWT.BORDER | SWT.RESIZE);
+ this.lblEmblem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+ true, 1, 4));
+ this.lblEmblem.setAlignment(SWT.CENTER);
+ this.lblEmblem.setText("No Image");
+ this.lblEmblem.addListener(SWT.Resize, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ SimpleConfigurationComposite.this.recalculateEmblemSize();
+ }
+ });
+
+ Label lblDateiname = new Label(grpBildmarke, SWT.NONE);
+ lblDateiname.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
+ false, 1, 1));
+ lblDateiname.setText("Dateiname:");
+ new Label(grpBildmarke, SWT.NONE);
+
+ this.txtEmblemFile = new Text(grpBildmarke, SWT.BORDER);
+ GridData gd_txtEmblemFile = new GridData(SWT.FILL, SWT.FILL, false,
+ false, 2, 1);
+ gd_txtEmblemFile.widthHint = 123;
+ this.txtEmblemFile.setLayoutData(gd_txtEmblemFile);
+ this.txtEmblemFile.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ processEmblemChanged();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ // Nothing to do here!
+ }
+ });
+ this.txtEmblemFile.addTraverseListener(new TraverseListener() {
+
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processEmblemChanged();
+ }
+ }
+ });
+ new Label(grpBildmarke, SWT.NONE);
+
+ Button btnBrowseEmblem = new Button(grpBildmarke, SWT.NONE);
+ btnBrowseEmblem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(SimpleConfigurationComposite.this
+ .getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] { "*.jpg", "*.gif" }); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setFilterNames(new String[] { "JPG Dateien",
+ "Gif Dateien" });
+ String fileName = dialog.open();
+ File file = null;
+ if (fileName != null) {
+ file = new File(fileName);
+ if (file.exists()) {
+ SimpleConfigurationComposite.this.txtEmblemFile
+ .setText(fileName);
+ processEmblemChanged();
+ }
+ }
+ }
+ });
+ btnBrowseEmblem.setText("Browse");
+
+ Label label = new Label(grpBildmarke, SWT.NONE);
+ GridData gd_label = new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1);
+ gd_label.widthHint = 189;
+ label.setLayoutData(gd_label);
+
+ Group grpProxy = new Group(this, SWT.NONE);
+ FormData fd_grpProxy = new FormData();
+ fd_grpProxy.right = new FormAttachment(100, -5);
+ fd_grpProxy.top = new FormAttachment(65, 5);
+ fd_grpProxy.left = new FormAttachment(0, 5);
+ fd_grpProxy.bottom = new FormAttachment(90, -5);
+ grpProxy.setLayoutData(fd_grpProxy);
+ grpProxy.setText("Proxy");
+ grpProxy.setLayout(new GridLayout(2, false));
+
+ Label lblNewLabel = new Label(grpProxy, SWT.NONE);
+ GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false,
+ false, 1, 1);
+ gd_lblNewLabel.widthHint = 66;
+ lblNewLabel.setLayoutData(gd_lblNewLabel);
+ lblNewLabel.setBounds(0, 0, 57, 15);
+ lblNewLabel.setText("Host:");
+
+ this.text = new Text(grpProxy, SWT.BORDER);
+ this.text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
+ 1, 1));
+
+ Label lblNewLabel_1 = new Label(grpProxy, SWT.NONE);
+ lblNewLabel_1.setBounds(0, 0, 57, 15);
+ lblNewLabel_1.setText("Port:");
+
+ this.text_1 = new Text(grpProxy, SWT.BORDER);
+ this.text_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
+ 1, 1));
+
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(SimpleConfigurationComposite.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // TODO Auto-generated method stub
+
+ }
+
+}