summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:52:08 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:52:08 +0000
commit5810f90913735936ef580fd78861b7b31835a6f4 (patch)
tree1e8e8b7bda1af04b01d90f1efdcbaaec53d499d6 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow
parent1d5ef84de6c39fbe6831402bd4095d7fe41b57d2 (diff)
downloadpdf-over-5810f90913735936ef580fd78861b7b31835a6f4.tar.gz
pdf-over-5810f90913735936ef580fd78861b7b31835a6f4.tar.bz2
pdf-over-5810f90913735936ef580fd78861b7b31835a6f4.zip
+ Main Window Template
+ Some GUI Stuff git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@16 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java79
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java54
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java33
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java9
9 files changed, 200 insertions, 23 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java
index 9688a747..83fca283 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java
@@ -21,25 +21,32 @@ import org.slf4j.LoggerFactory;
import java.util.Properties;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import at.asit.pdfover.gui.components.MainWindow;
import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState;
/**
- * Workflow holds logical state of signing process and updates the current logical state
+ * Workflow holds logical state of signing process and updates the current
+ * logical state
*/
public class Workflow {
-
+
/**
* SFL4J Logger instance
**/
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(Workflow.class);
-
+
/**
* Default constructor
+ *
* @param cmdLineArgs
*/
public Workflow(String[] cmdLineArgs) {
@@ -99,50 +106,82 @@ public class Workflow {
*/
public void update() {
WorkflowState next = null;
- do {
+ while (this.state != null) {
this.state.update(this);
next = this.state.nextState();
- } while (next != null);
+ if (next == this.state) {
+ break;
+ }
+ //this.state.hideGUI();
+ this.state = next;
+ }
+ if (this.state != null) {
+ this.setCurrentStateMessage(this.state.toString());
+ } else {
+ this.setCurrentStateMessage("");
+ }
}
private Display display = null;
-
+
private Shell shell = null;
-
+
private Composite container = null;
+
+ private MainWindow mainWindow = null;
+
+ private final StackLayout stack = new StackLayout();
+
+ /**
+ * Helper method for developing
+ * @param value
+ */
+ public void setCurrentStateMessage(String value) {
+ if(this.mainWindow != null) {
+ this.mainWindow.setStatus(value);
+ }
+ }
+ /**
+ * Used by active workflow state to show its own gui component
+ * @param ctrl
+ */
+ public void setTopControl(final Control ctrl) {
+ this.mainWindow.setTopControl(ctrl);
+ }
+
private void createMainWindow() {
- //TODO: Instantiate Main Window Class
this.display = Display.getDefault();
- this.shell = new Shell();
- this.shell.setSize(608, 340);
- this.shell.setText("PDFOver 4.0!! :)");
- this.container = new Composite(this.shell, SWT.NONE);
- this.container.setBounds(20, 44, 572, 257);
+ this.mainWindow = new MainWindow();
+
+ this.mainWindow.open();
+
+ this.shell = this.mainWindow.getShell();
+
+ this.container = this.mainWindow.getContainer();
this.shell.open();
this.shell.layout();
}
-
+
/**
* Gets the Shell for drawing the ui
*
* @return Composite
*/
public Composite getComposite() {
- // TODO: implement
// Main window will be build on first call
// returns SWT Composite container for states to draw their GUI
-
- if(this.container == null) {
+
+ if (this.container == null) {
this.createMainWindow();
}
-
- if(this.container == null) {
+
+ if (this.container == null) {
// TODO throw Exception...
}
-
+
return this.container;
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java
index b5bb9e23..ed0c1fc2 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java
@@ -33,6 +33,13 @@ public abstract class WorkflowState {
private WorkflowState _next = null;
/**
+ * Default Workflow State constructor
+ */
+ public WorkflowState() {
+ this._next = this;
+ }
+
+ /**
* Gets the next logical state or null if this their is no state transition
* @return the next state (or null)
*/
@@ -53,4 +60,9 @@ public abstract class WorkflowState {
* @param workflow
*/
public abstract void update(Workflow workflow);
+
+ /**
+ * Hide the GUI components created in the state
+ */
+ public abstract void hideGUI();
}
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 e92128ac..07d63d09 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
@@ -38,4 +38,13 @@ public class BKUSelectionState extends WorkflowState {
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java
index 1458958f..223ba17d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java
@@ -16,8 +16,14 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.components.DataSourceSelectComposite;
import at.asit.pdfover.gui.workflow.Workflow;
import at.asit.pdfover.gui.workflow.WorkflowState;
@@ -32,10 +38,56 @@ public class DataSourceSelectionState extends WorkflowState {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(DataSourceSelectionState.class);
+ private DataSourceSelectComposite selectionComposite = null;
+
+ private DataSourceSelectComposite getSelectionComposite(Workflow workflow) {
+ if(this.selectionComposite == null) {
+ this.selectionComposite = new DataSourceSelectComposite(workflow.getComposite(), SWT.RESIZE, workflow);
+ }
+
+ return this.selectionComposite;
+ }
+
@Override
public void update(Workflow workflow) {
- // TODO Auto-generated method stub
+ DataSourceSelectComposite selection = this.getSelectionComposite(workflow);
+
+ workflow.setTopControl(selection);
+ selection.layout();
+ if(selection.isPress()) {
+ this.setNextState(new PositioningState());
+ } else {
+ this.setNextState(this);
+ }
+ }
+
+ private void recursiveHide(Control ctrl) {
+ if(ctrl instanceof Composite) {
+ Composite comp = (Composite)ctrl;
+ Control[] childs = comp.getChildren();
+ for(int i = 0; i < childs.length; i++) {
+ this.recursiveHide(childs[i]);
+ }
+ }
+ ctrl.setVisible(false);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ /*if(this.selectionComposite != null) {
+ Shell shell = this.selectionComposite.getShell();
+ Composite comp = this.selectionComposite.getParent();
+ recursiveHide(this.selectionComposite);
+ this.selectionComposite.layout();
+ //this.selectionComposite.setVisible(false);
+ comp.layout();
+ //shell.pack(true);
+ shell.layout(true);
+ }*/
}
}
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 162fb051..44d9a55f 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
@@ -38,4 +38,13 @@ public class OutputState extends WorkflowState {
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ // TODO Auto-generated method stub
+
+ }
+
}
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 1d21aeca..b028cecc 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
@@ -16,8 +16,12 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.components.DataSourceSelectComposite;
+import at.asit.pdfover.gui.components.PositioningComposite;
import at.asit.pdfover.gui.workflow.Workflow;
import at.asit.pdfover.gui.workflow.WorkflowState;
@@ -30,12 +34,37 @@ public class PositioningState extends WorkflowState {
* SFL4J Logger instance
**/
@SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(PositioningState.class);
-
+ private static final Logger log = LoggerFactory
+ .getLogger(PositioningState.class);
+
+ private PositioningComposite positionComposite = null;
+
+ private PositioningComposite getPositioningComosite(Workflow workflow) {
+ if (this.positionComposite == null) {
+ this.positionComposite = new PositioningComposite(
+ workflow.getComposite(), SWT.NONE, workflow);
+ }
+
+ return this.positionComposite;
+ }
+
@Override
public void update(Workflow workflow) {
// TODO Auto-generated method stub
+ PositioningComposite position = this.getPositioningComosite(workflow);
+ workflow.setTopControl(position);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ // TODO Auto-generated method stub
+
}
}
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 3cde0e19..b90f38db 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
@@ -36,7 +36,16 @@ public class PrepareConfigurationState extends WorkflowState {
@Override
public void update(Workflow workflow) {
+ this.setNextState(new DataSourceSelectionState());
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
// TODO Auto-generated method stub
+
}
}
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 8f627dbf..a18dc389 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
@@ -38,4 +38,13 @@ public class PrepareSigningState extends WorkflowState {
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ // TODO Auto-generated method stub
+
+ }
+
}
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 2e052552..2305c1c6 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
@@ -38,4 +38,13 @@ public class SigningState extends WorkflowState {
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.WorkflowState#hideGUI()
+ */
+ @Override
+ public void hideGUI() {
+ // TODO Auto-generated method stub
+
+ }
+
}