From 94bf81d31e74a209d60f2fd4f1f20448770bf1a0 Mon Sep 17 00:00:00 2001 From: tkellner Date: Tue, 7 Aug 2012 14:52:00 +0000 Subject: Refactoring git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12276 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../java/at/asit/pdfover/gui/DeveloperMain.java | 17 +++ .../src/main/java/at/asit/pdfover/gui/Main.java | 13 ++ .../at/asit/pdfover/gui/workflow/Workflow.java | 156 +++++++++++++++++++++ .../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 ++ 11 files changed, 322 insertions(+) create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java (limited to 'trunk/pdf-over-gui/src/main') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java new file mode 100644 index 00000000..c68a3f90 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java @@ -0,0 +1,17 @@ +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(args); + + flow.Start(); + } + +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java new file mode 100644 index 00000000..2eb27630 --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java new file mode 100644 index 00000000..bc0e290c --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Workflow.java @@ -0,0 +1,156 @@ +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; + +import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState; + +public class Workflow { + public Workflow(String[] cmdLineArgs) { + setCmdLineAargs(cmdLineArgs); + } + + /** + * @uml.property name="state" + * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" + * inverse="workflow1:at.asit.pdfover.gui.workflow.WorkflowState" + */ + private WorkflowState state = new PrepareConfigurationState(); + + /** + * Getter of the property state + * + * @return Returns the state. + * @uml.property name="state" + */ + public WorkflowState getState() { + return this.state; + } + + private String[] cmdLineArgs = new String[] {}; + + /** + * sets the command line arguments + * + * @param cmdLineArgs + */ + private void setCmdLineAargs(String[] cmdLineArgs) { + this.cmdLineArgs = cmdLineArgs; + } + + /** + * Gets the command line arguments + * + * @return the command line arguments + */ + public String[] GetCmdArgs() { + return this.cmdLineArgs; + } + + private Properties persistentState = new Properties(); + + /** + * Gets the persistent state + * + * @return the persistent state + */ + public Properties GetPersistentState() { + return this.persistentState; + } + + /** + * 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: 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.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) { + 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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/WorkflowState.java new file mode 100644 index 00000000..f9d10d08 --- /dev/null +++ b/trunk/pdf-over-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 the next state (or null) + */ + 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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java new file mode 100644 index 00000000..657de4be --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java new file mode 100644 index 00000000..11b8c4ae --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java new file mode 100644 index 00000000..a11364f2 --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java new file mode 100644 index 00000000..c2b31247 --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java new file mode 100644 index 00000000..31d8a604 --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java new file mode 100644 index 00000000..ba6e7dc4 --- /dev/null +++ b/trunk/pdf-over-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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java new file mode 100644 index 00000000..ed54d82f --- /dev/null +++ b/trunk/pdf-over-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 + + } + +} -- cgit v1.2.3