From 5793f0dc194ae3519de7a12808d99aa2a555cd73 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 18:50:35 +0000 Subject: StateMachine Proposal git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@10 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../java/at/asit/pdfover/gui/DeveloperMain.java | 18 +++ .../src/main/java/at/asit/pdfover/gui/Main.java | 13 ++ .../at/asit/pdfover/gui/workflow/Workflow.java | 150 +++++++++++++++++++++ .../asit/pdfover/gui/workflow/WorkflowState.java | 32 +++++ .../gui/workflow/states/BKUSelectionState.java | 15 +++ .../workflow/states/DataSourceSelectionState.java | 15 +++ .../pdfover/gui/workflow/states/OutputState.java | 15 +++ .../gui/workflow/states/PositioningState.java | 15 +++ .../workflow/states/PrepareConfigurationState.java | 14 ++ .../gui/workflow/states/PrepareSigningState.java | 15 +++ .../pdfover/gui/workflow/states/SigningState.java | 15 +++ pdf-over/pdf-gui/src/model/PDFOverGUI.ucd | 123 +++++++++++++++++ 12 files changed, 440 insertions(+) create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/Main.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java create mode 100644 pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java create mode 100644 pdf-over/pdf-gui/src/model/PDFOverGUI.ucd diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java new file mode 100644 index 00000000..1093f0fd --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java @@ -0,0 +1,18 @@ +package at.asit.pdfover.gui; + +import at.asit.pdfover.gui.workflow.Workflow; + +public class DeveloperMain { + + /** + * Developer Main Entry point... + * @param args + */ + public static void main(String[] args) { + Workflow flow = new Workflow(); + flow.SetCmdArgs(args); + + flow.Start(); + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/Main.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/Main.java new file mode 100644 index 00000000..2eb27630 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/Main.java @@ -0,0 +1,13 @@ +package at.asit.pdfover.gui; + +public class Main { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java new file mode 100644 index 00000000..14dbbcae --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java @@ -0,0 +1,150 @@ +package at.asit.pdfover.gui.workflow; + +import java.util.Properties; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class Workflow { + /** + * @uml.property name="state" + * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" + * inverse="workflow1:at.asit.pdfover.gui.workflow.WorkflowState" + */ + private WorkflowState state = new at.asit.pdfover.gui.workflow.states.PrepareConfigurationState(); + + /** + * Getter of the property state + * + * @return Returns the state. + * @uml.property name="state" + */ + public WorkflowState getState() { + return state; + } + + private String[] CmdArgs = new String[] {}; + + /** + * Sets the Cmd Arguments + * + * @param args + */ + public void SetCmdArgs(String[] args) { + this.CmdArgs = args; + } + + /** + * Gets the Cmd Arguments + * + * @return + */ + public String[] GetCmdArgs() { + return this.CmdArgs; + } + + private Properties persistent_state = new Properties(); + + /** + * Gets the Persistent State + * + * @return + */ + public Properties GetPersistentState() { + return this.persistent_state; + } + + /** + * Update Workflow logic and let state machine do its job... + */ + public void Update() { + WorkflowState next = null; + do { + this.state.Update(this); + next = this.state.NextState(); + } while (next != null); + } + + private Display display = null; + + private Shell shell = null; + + private Composite container = null; + + private void CreateMainWindow() { + //TODO: Instanciate Main Window Class + this.display = Display.getDefault(); + shell = new Shell(); + shell.setSize(608, 340); + shell.setText("PDFOver 4.0!! :)"); + + container = new Composite(shell, SWT.NONE); + container.setBounds(20, 44, 572, 257); + + shell.open(); + shell.layout(); + } + + /** + * Gets the Shell for drawing the ui + * + * @return + */ + 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) { + this.CreateMainWindow(); + } + + if(this.container == null) { + // TODO throw Exception... + } + + return this.container; + } + + /** + * Only returns a shell if one was already created ... + * + * @return + */ + private Shell NonCreatingGetShell() { + return this.shell; + } + + /** + * Only returns a shell if one was already created ... + * + * @return + */ + private Display NonCreatingGetDisplay() { + return this.display; + } + + /** + * Workflow main entrance point + */ + public void Start() { + // Call update to start processing ... + this.Update(); + + // if a user interaction is required we have a shell ... + Shell shell = this.NonCreatingGetShell(); + Display display = this.NonCreatingGetDisplay(); + + if (shell != null && display != null) { + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + display.dispose(); + } + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java new file mode 100644 index 00000000..5a4f1776 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java @@ -0,0 +1,32 @@ +package at.asit.pdfover.gui.workflow; + +/** + * Base state class + * @author afitzek + */ +public abstract class WorkflowState { + + private WorkflowState _next = null; + + /** + * Gets the next logical state or null if this their is no state transition + * @return + */ + public WorkflowState NextState() { + return this._next; + } + + /** + * Sets the next logical state + * @param state + */ + protected void SetNextState(WorkflowState state) { + this._next = state; + } + + /** + * Perform main logic for this state + * @param workflow + */ + public abstract void Update(Workflow workflow); +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java new file mode 100644 index 00000000..7c249ef2 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class BKUSelectionState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java new file mode 100644 index 00000000..a6c92ba3 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class DataSourceSelectionState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java new file mode 100644 index 00000000..d984ea7f --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class OutputState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java new file mode 100644 index 00000000..54ed8b31 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class PositioningState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java new file mode 100644 index 00000000..65abeea1 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -0,0 +1,14 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class PrepareConfigurationState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java new file mode 100644 index 00000000..5dc96ade --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class PrepareSigningState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java new file mode 100644 index 00000000..4753de48 --- /dev/null +++ b/pdf-over/pdf-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -0,0 +1,15 @@ +package at.asit.pdfover.gui.workflow.states; + +import at.asit.pdfover.gui.workflow.Workflow; +import at.asit.pdfover.gui.workflow.WorkflowState; + + +public class SigningState extends WorkflowState { + + @Override + public void Update(Workflow workflow) { + // TODO Auto-generated method stub + + } + +} diff --git a/pdf-over/pdf-gui/src/model/PDFOverGUI.ucd b/pdf-over/pdf-gui/src/model/PDFOverGUI.ucd new file mode 100644 index 00000000..4895ff45 --- /dev/null +++ b/pdf-over/pdf-gui/src/model/PDFOverGUI.ucd @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3