summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:53:20 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:53:20 +0000
commit69f82291cd349961cca5d8a65b7f3f2f724ed74f (patch)
tree6cfc2d6ff7defe17a42e51d33f5288234728f485 /pdf-over-gui/src/main
parentb2968bef5d56723826cfe38f1fe5ab1d60aa79f3 (diff)
downloadpdf-over-69f82291cd349961cca5d8a65b7f3f2f724ed74f.tar.gz
pdf-over-69f82291cd349961cca5d8a65b7f3f2f724ed74f.tar.bz2
pdf-over-69f82291cd349961cca5d8a65b7f3f2f724ed74f.zip
StateMachine cleanup
JumpToState stuff git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@24 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java164
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java293
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java117
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java49
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java72
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java5
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java57
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java28
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java27
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java34
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java26
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java61
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java6
21 files changed, 918 insertions, 76 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
index 63c2dafd..1d0094c9 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
@@ -28,6 +28,9 @@ public class MainWindowBehavior {
protected Map<Buttons, Boolean> buttonsActive;
protected boolean mainBarVisible;
+ /**
+ *
+ */
public MainWindowBehavior() {
this.buttonsActive = new EnumMap<MainWindow.Buttons, Boolean>(MainWindow.Buttons.class);
this.buttonsEnabled = new EnumMap<MainWindow.Buttons, Boolean>( MainWindow.Buttons.class);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
new file mode 100644
index 00000000..24be2c5a
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
@@ -0,0 +1,164 @@
+/*
+ * 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.SWT;
+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;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.states.BKUSelectionState;
+import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ *
+ */
+public class BKUSelectionComposite extends StateComposite {
+
+
+ /**
+ * Listener for local bku selection
+ */
+ private final class LocalSelectionListener implements SelectionListener {
+
+ /**
+ * Default constructor
+ */
+ public LocalSelectionListener() {
+ // Nothing here
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ log.debug("Setting BKU to LOCAL");
+ setSelected(BKUs.LOCAL);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing here
+ }
+ }
+
+ /**
+ * Listener for mobile bku selection
+ */
+ private final class MobileSelectionListener implements SelectionListener {
+
+ /**
+ * Default constructor
+ */
+ public MobileSelectionListener() {
+ // Nothing here
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ log.debug("Setting BKU to MOBILE");
+ setSelected(BKUs.MOBILE);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing here
+ }
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(BKUSelectionComposite.class);
+
+ private BKUs selected = BKUs.NONE;
+
+ /**
+ * Gets selected BKU type
+ * @return BKUS enum
+ */
+ public BKUs getSelected() {
+ return this.selected;
+ }
+
+ /**
+ * Sets selected BKU and updates workflow
+ * @param selected
+ */
+ public void setSelected(final BKUs selected) {
+ this.selected = selected;
+ this.state.updateStateMachine();
+ }
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public BKUSelectionComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+
+ this.setLayout(new FormLayout());
+
+
+ Button btn_mobile = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ btn_mobile.setText("MOBILE");
+ //Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ FormData fd_btn_mobile = new FormData();
+ fd_btn_mobile.left = new FormAttachment(40, 0);
+ fd_btn_mobile.right = new FormAttachment(50, 0);
+ fd_btn_mobile.top = new FormAttachment(45, 0);
+ fd_btn_mobile.bottom = new FormAttachment(55, 0);
+ btn_mobile.setLayoutData(fd_btn_mobile);
+ btn_mobile.addSelectionListener(new MobileSelectionListener());
+
+ Button btn_card = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ btn_card.setText("CARD");
+ //Point card_size = btn_card.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ FormData fd_btn_card = new FormData();
+ fd_btn_card.left = new FormAttachment(50, 0);
+ fd_btn_card.right = new FormAttachment(60, 0);
+ fd_btn_card.top = new FormAttachment(45, 0);
+ fd_btn_card.bottom = new FormAttachment(55, 0);
+ btn_card.setLayoutData(fd_btn_card);
+ btn_card.addSelectionListener(new LocalSelectionListener());
+
+ this.pack();
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.components.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ this.layout(true, true);
+ }
+
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
new file mode 100644
index 00000000..44b2574b
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
@@ -0,0 +1,293 @@
+/*
+ * 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 org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+
+import at.asit.pdfover.gui.workflow.StateMachineImpl;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ *
+ *
+ */
+public class DataSourceSelectComposite extends StateComposite {
+
+ /**
+ *
+ */
+ private final class FileBrowseDialog implements SelectionListener {
+ /**
+ *
+ */
+ public FileBrowseDialog() {
+ // Nothing to do here
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(DataSourceSelectComposite.this.getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] {"*.pdf"});
+ dialog.setFilterNames(new String[] {"PDF Dateien"});
+ String fileName = dialog.open();
+ File file = null;
+ if (fileName != null) {
+ file = new File(fileName);
+ if(file.exists()) {
+ DataSourceSelectComposite.this.setSelected(file);
+ }
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do here
+ }
+ }
+
+ /**
+ * SFL4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(DataSourceSelectComposite.class);
+
+ /**
+ * Set this value through the setter method!!
+ */
+ private File selected = null;
+
+ /**
+ * Sets the selected file and calls update to the workflow
+ * @param selected
+ */
+ protected void setSelected(File selected) {
+ this.selected = selected;
+ this.state.updateStateMachine();
+ }
+
+ /**
+ * Gets the selected file
+ *
+ * @return the selected file
+ */
+ public File getSelected() {
+ return this.selected;
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public DataSourceSelectComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+
+
+ this.setLayout(new FormLayout());
+
+ Color back = new Color(Display.getCurrent(), 77, 190, 250);
+
+ this.drop_area = new Composite(this, SWT.RESIZE | SWT.BORDER_DASH);
+ FormData fd_drop_area = new FormData();
+ fd_drop_area.left = new FormAttachment(0, 0);
+ fd_drop_area.right = new FormAttachment(100, 0);
+ fd_drop_area.top = new FormAttachment(0, 0);
+ fd_drop_area.bottom = new FormAttachment(100, 0);
+ this.drop_area.setLayoutData(fd_drop_area);
+ this.drop_area.setLayout(new FormLayout());
+ this.drop_area.setBackground(back);
+
+ DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_DEFAULT
+ | DND.DROP_COPY);
+ final FileTransfer fileTransfer = FileTransfer.getInstance();
+ Transfer[] types = new Transfer[] { fileTransfer };
+ dnd_target.setTransfer(types);
+
+ dnd_target.addDropListener(new DropTargetListener() {
+
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drop(DropTargetEvent event) {
+ if (fileTransfer.isSupportedType(event.currentDataType)){
+ String[] files = (String[])event.data;
+ if(files.length > 0) {
+ // Only taking first file ...
+ File file = new File(files[0]);
+ if(!file.exists())
+ {
+ log.error("File: " + files[0] + " doesnot exists!");
+ return;
+ }
+ DataSourceSelectComposite.this.setSelected(file);
+ }
+ }
+ }
+
+ @Override
+ public void dragOver(DropTargetEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void dragOperationChanged(DropTargetEvent event) {
+ if (event.detail == DND.DROP_DEFAULT) {
+ if ((event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
+ }
+
+ @Override
+ public void dragLeave(DropTargetEvent event) {
+ // No need to do anything here...
+ }
+
+ @Override
+ public void dragEnter(DropTargetEvent event) {
+ if (event.detail == DND.DROP_DEFAULT) {
+ if ((event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
+ // Only drop one item!
+ if(event.dataTypes.length > 1) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ // will accept text but prefer to have files dropped
+ for (int i = 0; i < event.dataTypes.length; i++) {
+ if (fileTransfer.isSupportedType(event.dataTypes[i])) {
+ event.currentDataType = event.dataTypes[i];
+ // files should only be copied
+ if (event.detail != DND.DROP_COPY) {
+ event.detail = DND.DROP_NONE;
+ }
+ break;
+ }
+ }
+ }
+ });
+
+ final Label lbl_drag = new Label(this.drop_area, SWT.NONE | SWT.RESIZE);
+ FormData fd_lbl_drag = new FormData();
+ fd_lbl_drag.left = new FormAttachment(5, 5);
+ fd_lbl_drag.right = new FormAttachment(100, -5);
+ fd_lbl_drag.top = new FormAttachment(5, 5);
+ fd_lbl_drag.bottom = new FormAttachment(55, -5);
+ lbl_drag.setLayoutData(fd_lbl_drag);
+ FontData[] fD = lbl_drag.getFont().getFontData();
+ fD[0].setHeight(18);
+ lbl_drag.setFont(new Font(Display.getCurrent(), fD[0]));
+ lbl_drag.setText("Drag and Drop");
+ lbl_drag.setAlignment(SWT.CENTER);
+ lbl_drag.setBackground(back);
+
+ Button btn_open = new Button(this.drop_area, SWT.NATIVE | SWT.RESIZE);
+ btn_open.setText("Choose file ...");
+ Point size = btn_open.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ FormData fd_btn_open = new FormData();
+ fd_btn_open.left = new FormAttachment(100, size.x * -1 - 10);
+ fd_btn_open.right = new FormAttachment(100, -5);
+ fd_btn_open.top = new FormAttachment(100, size.y * -1 - 10);
+ fd_btn_open.bottom = new FormAttachment(100, -5);
+ btn_open.setLayoutData(fd_btn_open);
+ btn_open.setBackground(back);
+ btn_open.addSelectionListener(new FileBrowseDialog());
+ this.drop_area.pack();
+
+ /*
+ * Button btn = new Button(this, SWT.NATIVE); btn.setBounds(50, 20, 100,
+ * 50); btn.setText("Click Me"); btn.addSelectionListener(new
+ * SelectionListener() {
+ *
+ * @Override public void widgetSelected(SelectionEvent arg0) {
+ * DataSourceSelectComposite.this.setPress(true);
+ * DataSourceSelectComposite.this.workflow.update(); }
+ *
+ * @Override public void widgetDefaultSelected(SelectionEvent arg0) { //
+ * TODO Auto-generated method stub
+ *
+ * } });
+ */
+ }
+
+ private boolean press = false;
+
+ private Composite drop_area;
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /**
+ * @return the press
+ */
+ public boolean isPress() {
+ return this.press;
+ }
+
+ /**
+ * @param press
+ * the press to set
+ */
+ public void setPress(boolean press) {
+ this.press = press;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.components.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ this.layout(true, true);
+ this.drop_area.layout(true, true);
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
new file mode 100644
index 00000000..d641af62
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
@@ -0,0 +1,117 @@
+/*
+ * 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.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.states.State;
+import at.asit.pdfover.signator.SignaturePosition;
+
+/**
+ *
+ *
+ */
+public class PositioningComposite extends StateComposite {
+
+ /**
+ * Selection listener when position was fixed
+ */
+ private final class PositionSelectedListener implements SelectionListener {
+
+ /**
+ * Default constructor
+ */
+ public PositionSelectedListener() {
+ // Nothing to do
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // TODO: FIX to get real position
+ PositioningComposite.this.setPosition(new SignaturePosition()); // Setting auto position for testing
+ PositioningComposite.this.state.updateStateMachine();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do
+ }
+ }
+
+ /**
+ * SFL4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(PositioningComposite.class);
+
+ private SignaturePosition position = null;
+
+ /**
+ * Gets the Position
+ * @return
+ */
+ public SignaturePosition getPosition() {
+ return this.position;
+ }
+
+ /**
+ * Sets the position
+ * @param position
+ */
+ public void setPosition(SignaturePosition position) {
+ this.position = position;
+ }
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ */
+ public PositioningComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+
+
+ Label test = new Label(this, SWT.NATIVE);
+ test.setBounds(10, 20, 100, 30);
+ test.setText("POSITIONING ---- TODO!!");
+
+ Button btn_position = new Button(this, SWT.NATIVE | SWT.RESIZE);
+ btn_position.setBounds(10, 50, 100, 30);
+ btn_position.setText("FAKE Position");
+ btn_position.addSelectionListener(new PositionSelectedListener());
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.components.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ this.layout(true, true);
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
new file mode 100644
index 00000000..0b21e3aa
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * Composite interface for workflow state gui implementations
+ */
+public abstract class StateComposite extends Composite {
+
+ protected State state;
+
+ /**
+ * The base class for state composites
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public StateComposite(Composite parent, int style, State state) {
+ super(parent, style);
+ this.state = state;
+ }
+
+ /**
+ * Performs layout for all children in composite
+ * (SWT layout(...) only layouts children no grandchildren!)
+ */
+ public abstract void doLayout();
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java
new file mode 100644
index 00000000..4101e924
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java
@@ -0,0 +1,72 @@
+/*
+ * 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 org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormAttachment;
+
+import at.asit.pdfover.gui.workflow.StateMachineImpl;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ *
+ */
+public class WaitingComposite extends StateComposite {
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(WaitingComposite.class);
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public WaitingComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE);
+ FormData fd_progressBar = new FormData();
+ fd_progressBar.top = new FormAttachment(50, -15);
+ fd_progressBar.bottom = new FormAttachment(50, +15);
+ fd_progressBar.left = new FormAttachment(50, -100);
+ fd_progressBar.right = new FormAttachment(50, +100);
+ progressBar.setLayoutData(fd_progressBar);
+ }
+
+ @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() {
+ // Nothing to do here
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
index 4e7955fd..ff31ad0d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java
@@ -17,6 +17,8 @@ package at.asit.pdfover.gui.workflow;
import org.eclipse.swt.widgets.Composite;
+import at.asit.pdfover.gui.workflow.states.State;
+
/**
*
@@ -32,9 +34,10 @@ public interface GUIProvider {
* Create a new Composite
* @param compositeClass The class of the Composite to create
* @param style the SWT style
+ * @param state the State this Composite belongs to
* @return the new Composite
*/
- public <T> T createComposite(Class<T> compositeClass, int style);
+ public <T> T createComposite(Class<T> compositeClass, int style, State state);
/**
* Display the composite as top most in main window
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java
index 1298bda8..c98d9895 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java
@@ -69,7 +69,7 @@ public interface StateMachine {
* Update state machine from other thread
* Calls the next state within the main thread
*/
- public void InvokeUpdate();
+ public void invokeUpdate();
/**
* Exit state machine execution
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
index bb292c74..38c3d55d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
@@ -16,21 +16,17 @@
package at.asit.pdfover.gui.workflow;
//Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.lang.reflect.Constructor;
+
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindow;
-import at.asit.pdfover.gui.workflow.states.BKUSelectionState;
-import at.asit.pdfover.gui.workflow.states.OpenState;
-import at.asit.pdfover.gui.workflow.states.PositioningState;
import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState;
import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs;
/**
* Workflow holds logical state of signing process and updates the current
@@ -72,37 +68,8 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
*/
@Override
public void jumpToState(State state) {
- if (this.status.getCurrentState() != state && state != null) {
- this.status.setCurrentState(state);
-
- // TODO rewrite when Config is done ...
- if (state instanceof PositioningState) {
- // User jumps to positioning state !
- // restore possible default for bku selection / forget BKU
- // selection
- this.getStatus().setBKU(
- this.getConfigProvider().getDefaultBKU());
- // forget position
- this.getStatus().setSignaturePosition(null);
- } else if (state instanceof BKUSelectionState) {
- // User jumps to bku selection state !
- // forget bku selection
- this.getStatus().setBKU(BKUs.NONE);
- } else if (state instanceof OpenState) {
- // User jumps to data source selection state !
- // forget bku selection / restore possible default for bku
- // selection
- this.getStatus().setBKU(
- this.getConfigProvider().getDefaultBKU());
- // forget position / restore possible default for position
- this.getStatus().setSignaturePosition(
- this.getConfigProvider().getDefaultSignaturePosition());
- // forget data source selection
- this.getStatus().setDocument(null);
- }
-
- this.update();
- }
+ this.status.setCurrentState(state);
+ this.update();
}
/**
@@ -116,7 +83,7 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
current.run();
if (this.mainWindow != null
&& !this.mainWindow.getShell().isDisposed()) {
- log.debug("Allowing MainWindow to update its state for "
+ log.debug("Allowing MainWindow to update its state for " //$NON-NLS-1$
+ current);
current.updateMainWindowBehavior();
this.mainWindow.applyBehavior();
@@ -126,8 +93,8 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
if (next == current) {
break;
}
- log.debug("Changing state from: "
- + current + " to "
+ log.debug("Changing state from: " //$NON-NLS-1$
+ + current + " to " //$NON-NLS-1$
+ next.toString());
this.status.setCurrentState(next);
}
@@ -143,7 +110,7 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
* Invoke Update in UI (Main) Thread
*/
@Override
- public void InvokeUpdate() {
+ public void invokeUpdate() {
if (this.display != null) {
this.display.asyncExec(new Runnable() {
@@ -223,12 +190,12 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
}
@Override
- public <T> T createComposite(Class<T> compositeClass, int style) {
+ public <T> T createComposite(Class<T> compositeClass, int style, State state) {
T composite = null;
try {
Constructor<T> constructor = compositeClass.getDeclaredConstructor(
- Composite.class, int.class, BKUSelectionState.class);
- composite = constructor.newInstance(getComposite(), style, this);
+ Composite.class, int.class, State.class);
+ composite = constructor.newInstance(getComposite(), style, state);
} catch (Exception e) {
log.error(
"Could not create Composite for Class "
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
index 9af0b034..e0a7b0d4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
@@ -73,4 +73,10 @@ public interface Status {
* @return the main window behavior
*/
public MainWindowBehavior getBehavior();
+
+ /**
+ * Gets the previous State
+ * @return the previous State
+ */
+ public State getPreviousState();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
index 9bc4bfec..c8d74161 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
@@ -44,8 +44,11 @@ public class StatusImpl implements Status {
private State currentState = null;
+ private State previousState = null;
+
private MainWindowBehavior behavior;
+
/**
* Constructor
*/
@@ -59,14 +62,33 @@ public class StatusImpl implements Status {
}
/**
- * Sets the current state
- * @param currentState
+ * Changes the current state
+ * @param currentState the current State
*/
public void setCurrentState(State currentState) {
+ if (this.previousState == this.currentState)
+ log.error("Changing to same state? " + this.currentState);
+
+ if (this.previousState != null && this.previousState != currentState)
+ {
+ //Reference to previous state will be lost - perform cleanup
+ log.debug("Cleaning up " + this.previousState);
+ this.previousState.cleanUp();
+ }
+
+ this.previousState = this.currentState;
this.currentState = currentState;
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.Status#getPreviousState()
+ */
+ @Override
+ public State getPreviousState() {
+ return this.previousState;
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.Status#setDocument(java.io.File)
*/
@Override
@@ -119,6 +141,6 @@ public class StatusImpl implements Status {
*/
@Override
public MainWindowBehavior getBehavior() {
- return behavior;
+ return this.behavior;
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java
index 86bd50c9..fe79c460 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java
@@ -23,7 +23,9 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.composites.BKUSelectionComposite;
+import at.asit.pdfover.gui.workflow.ConfigProvider;
import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.Status;
/**
* Decides which BKU to use (preconfigured or let user choose)
@@ -76,23 +78,38 @@ public class BKUSelectionState extends State {
@Override
public void run() {
-
- if(this.stateMachine.getStatus().getBKU() == BKUs.NONE) {
+ Status status = this.stateMachine.getStatus();
+ if (!(status.getPreviousState() instanceof BKUSelectionState))
+ {
+ ConfigProvider config = this.stateMachine.getConfigProvider();
+ status.setBKU(config.getDefaultBKU());
+ }
+
+ if(status.getBKU() == BKUs.NONE) {
BKUSelectionComposite selection = this
.getSelectionComposite();
this.stateMachine.getGUIProvider().display(selection);
selection.layout();
- this.stateMachine.getStatus().setBKU(selection.getSelected());
+ status.setBKU(selection.getSelected());
- if(this.stateMachine.getStatus().getBKU() == BKUs.NONE) {
+ if(status.getBKU() == BKUs.NONE) {
return;
}
}
this.setNextState(new PrepareSigningState(this.stateMachine));
}
-
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ if (this.selectionComposite != null)
+ this.selectionComposite.dispose();
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index 2d3a31ec..795090e7 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -50,6 +50,14 @@ public class LocalBKUState extends State {
this.setNextState(new SigningState(this.stateMachine));
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ // No composite - no cleanup necessary
+ }
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index c160a524..3e1eb21a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -52,6 +52,14 @@ public class MobileBKUState extends State {
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ // No composite - no cleanup necessary
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
index ee90a69b..1d2b94a8 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
@@ -23,7 +23,9 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.composites.DataSourceSelectComposite;
+import at.asit.pdfover.gui.workflow.ConfigProvider;
import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.Status;
/**
* Selects the data source for the signature process.
@@ -47,8 +49,10 @@ public class OpenState extends State {
private DataSourceSelectComposite getSelectionComposite() {
if (this.selectionComposite == null) {
- this.selectionComposite = new DataSourceSelectComposite(
- this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this);
+ this.selectionComposite =
+ this.stateMachine.getGUIProvider().createComposite(DataSourceSelectComposite.class, SWT.RESIZE, this);
+ //this.selectionComposite = new DataSourceSelectComposite(
+ // this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this);
}
return this.selectionComposite;
@@ -56,26 +60,44 @@ public class OpenState extends State {
@Override
public void run() {
+ Status status = this.stateMachine.getStatus();
+ if (!(status.getPreviousState() instanceof PrepareConfigurationState) &&
+ !(status.getPreviousState() instanceof OpenState))
+ {
+ ConfigProvider config = this.stateMachine.getConfigProvider();
+ status.setBKU(config.getDefaultBKU());
+ status.setDocument(null);
+ status.setSignaturePosition(config.getDefaultSignaturePosition());
+ }
- if (this.stateMachine.getStatus().getDocument() == null) {
+ if (status.getDocument() == null) {
DataSourceSelectComposite selection = this
.getSelectionComposite();
this.stateMachine.getGUIProvider().display(selection);
selection.layout();
- this.stateMachine.getStatus().setDocument(selection.getSelected());
+ status.setDocument(selection.getSelected());
- if (this.stateMachine.getStatus().getDocument() == null) {
+ if (status.getDocument() == null) {
// Not selected yet
return;
}
}
- log.debug("Got Datasource: " + this.stateMachine.getStatus().getDocument().getAbsolutePath());
+ log.debug("Got Datasource: " + this.stateMachine.getStatus().getDocument().getAbsolutePath()); //$NON-NLS-1$
this.setNextState(new PositioningState(this.stateMachine));
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ if (this.selectionComposite != null)
+ this.selectionComposite.dispose();
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
index 8a04dd3f..7c16d559 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
@@ -47,7 +47,15 @@ public class OutputState extends State {
this.stateMachine.exit();
}
-
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ // TODO
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
index c7c92a89..2809bd25 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
@@ -23,7 +23,9 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.composites.PositioningComposite;
+import at.asit.pdfover.gui.workflow.ConfigProvider;
import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.Status;
/**
* Decides where to position the signature block
@@ -57,15 +59,22 @@ public class PositioningState extends State {
@Override
public void run() {
-
- if(this.stateMachine.getStatus().getSignaturePosition() == null) {
+ Status status = this.stateMachine.getStatus();
+ if (!(status.getPreviousState() instanceof PositioningState) &&
+ !(status.getPreviousState() instanceof OpenState))
+ {
+ status.setSignaturePosition(null);
+ }
+
+
+ if(status.getSignaturePosition() == null) {
PositioningComposite position = this.getPositioningComosite();
this.stateMachine.getGUIProvider().display(position);
- this.stateMachine.getStatus().setSignaturePosition(position.getPosition());
+ status.setSignaturePosition(position.getPosition());
- if(this.stateMachine.getStatus().getSignaturePosition() == null) {
+ if(status.getSignaturePosition() == null) {
return;
}
}
@@ -73,6 +82,15 @@ public class PositioningState extends State {
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ if (this.positionComposite != null)
+ this.positionComposite.dispose();
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index 4fa9e362..2a71890d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -59,6 +59,14 @@ public class PrepareConfigurationState extends State {
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ // No composite - no cleanup necessary
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
@Override
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 061869c1..186bf447 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
@@ -25,6 +25,8 @@ import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.composites.WaitingComposite;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs;
+import at.asit.pdfover.signator.SignatureParameter;
+import at.asit.pdfover.signator.Signer;
/**
* User waiting state, wait for PDF Signator library to prepare document for signing.
@@ -61,24 +63,52 @@ public class PrepareSigningState extends State {
// TODO Auto-generated catch block
e.printStackTrace();
}
- this.workflow.InvokeUpdate();
+ this.workflow.invokeUpdate();
}
}
+ private final class PrepareDocumentThread implements Runnable {
+
+ private PrepareSigningState state;
+
+ /**
+ * Default constructor
+ * @param state
+ */
+ public PrepareDocumentThread(PrepareSigningState state) {
+ this.state = state;
+ }
+
+ @Override
+ public void run() {
+ try {
+
+
+ } catch (Exception e) {
+ log.error("PrepareDocumentThread: ", e);
+ }
+ finally {
+ this.state.stateMachine.invokeUpdate();
+ }
+ }
+ }
+
/**
* SFL4J Logger instance
**/
private static final Logger log = LoggerFactory.getLogger(PrepareSigningState.class);
- private WaitingComposite selectionComposite = null;
+ private SignatureParameter signatureParameter;
+
+ private WaitingComposite waitingComposite = null;
private WaitingComposite getSelectionComposite() {
- if (this.selectionComposite == null) {
- this.selectionComposite = new WaitingComposite(
+ if (this.waitingComposite == null) {
+ this.waitingComposite = new WaitingComposite(
this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this);
}
- return this.selectionComposite;
+ return this.waitingComposite;
}
private boolean run = false;
@@ -87,11 +117,17 @@ public class PrepareSigningState extends State {
public void run() {
// TODO SHOW BACKGROUND ACTIVITY ....
WaitingComposite waiting = this.getSelectionComposite();
-
+
this.stateMachine.getGUIProvider().display(waiting);
+ Signer signer = this.stateMachine.getPDFSigner().getPDFSigner();
+
+ if(signatureParameter == null) {
+// signatureParameter =
+ }
+
if(!this.run) {
- Thread t = new Thread(new DebugSleeperThread(this.stateMachine));
+ Thread t = new Thread(new PrepareDocumentThread(this));
this.run = true;
t.start();
return;
@@ -108,7 +144,16 @@ public class PrepareSigningState extends State {
this.setNextState(new BKUSelectionState(this.stateMachine));
}
}
-
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ if (this.waitingComposite != null)
+ this.waitingComposite.dispose();
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
index 3447fc4c..6b453d33 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
@@ -45,7 +45,15 @@ public class SigningState extends State {
this.setNextState(new OutputState(this.stateMachine));
}
-
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ // No composite - no cleanup necessary
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java
index 8b9a3ebb..95c7c5bd 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java
@@ -19,7 +19,6 @@ package at.asit.pdfover.gui.workflow.states;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.workflow.StateMachine;
/**
@@ -71,6 +70,11 @@ public abstract class State {
public abstract void run();
/**
+ * Perform status cleanup
+ */
+ public abstract void cleanUp();
+
+ /**
* Update the state machine
*/
public void updateStateMachine()