diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
| commit | b086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch) | |
| tree | 8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java | |
| parent | 22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff) | |
Initial Maven Conversion
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java b/src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java new file mode 100644 index 0000000..132fdcf --- /dev/null +++ b/src/main/java/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java @@ -0,0 +1,97 @@ +package com.c2kernel.lifecycle.gui.model;
+import java.awt.Point;
+import java.io.Serializable;
+import java.util.HashMap;
+
+import javax.swing.JOptionPane;
+
+import com.c2kernel.graph.model.GraphModelManager;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
+import com.c2kernel.graph.model.VertexFactory;
+import com.c2kernel.lifecycle.ActivityDef;
+import com.c2kernel.lifecycle.CompositeActivityDef;
+import com.c2kernel.lifecycle.chooser.ActivityChooser;
+import com.c2kernel.lifecycle.chooser.WorkflowDialogue;
+import com.c2kernel.utils.Language;
+import com.c2kernel.utils.LocalObjectLoader;
+import com.c2kernel.utils.Logger;
+import com.c2kernel.utils.Resource;
+public class WfVertexDefFactory implements VertexFactory, WorkflowDialogue
+{
+ protected CompositeActivityDef mCompositeActivityDef = null;
+ @Override
+ public void create(GraphModelManager graphModelManager, Point location, TypeNameAndConstructionInfo typeNameAndConstructionInfo)
+ {
+ String vertexTypeId = null;
+ if (mCompositeActivityDef != null && typeNameAndConstructionInfo.mInfo instanceof String)
+ {
+ vertexTypeId = (String) typeNameAndConstructionInfo.mInfo;
+ if (vertexTypeId.equals("Atomic") || vertexTypeId.equals("Composite"))
+ {
+ // ask for a name
+ HashMap<String, Serializable> mhm = new HashMap<String, Serializable>();
+ mhm.put("P1", vertexTypeId);
+ mhm.put("P2", location);
+ //************************************************
+ ActivityChooser a =
+ new ActivityChooser(
+ Language.translate("Please enter a Type for the new activityDef"),
+ Language.translate("New " + vertexTypeId + " Activity"),
+ Resource.findImage("graph/newvertex_large.png").getImage(),
+ this,
+ mhm);
+ a.setVisible(true);
+ }
+ else
+ mCompositeActivityDef.newChild("", vertexTypeId, location);
+ }
+ }
+ @Override
+ public void loadThisWorkflow(String newName, HashMap<?, ?> hashMap)
+ {
+ String vertexTypeId = (String) hashMap.get("P1");
+ Point location = (Point) hashMap.get("P2");
+ if (newName == null || newName.equals(""))
+ return;
+ Logger.debug(5, newName);
+ ActivityDef act = (ActivityDef) mCompositeActivityDef.search(mCompositeActivityDef.getID() + "/" + newName);
+ if (act != null)
+ {
+ String unicName = newName;
+ while (unicName == null
+ || unicName == ""
+ || mCompositeActivityDef.search(mCompositeActivityDef.getID() + "/" + unicName) != null)
+ unicName =
+ (String) JOptionPane.showInputDialog(
+ null,
+ Language.translate("Please type a Name"),
+ Language.translate("New " + vertexTypeId + " Activity"),
+ JOptionPane.QUESTION_MESSAGE,
+ Resource.findImage("graph/newvertex_large.png"),
+ null,
+ null);
+ act = (ActivityDef) mCompositeActivityDef.search(mCompositeActivityDef.getID() + "/" + newName);
+ mCompositeActivityDef.addExistingActivityDef(unicName, act, new GraphPoint(location.x, location.y));
+ }
+ else
+ {
+ try
+ {
+ act = LocalObjectLoader.getActDef(newName, "last");
+ }
+ catch (Exception ex)
+ {
+ Logger.exceptionDialog(ex);
+ return;
+ }
+ mCompositeActivityDef.newChild(newName, vertexTypeId, location);
+ }
+ }
+ @Override
+ public void setCreationContext(Object newContext)
+ {
+ if (newContext != null && newContext instanceof CompositeActivityDef)
+ mCompositeActivityDef = (CompositeActivityDef) newContext;
+ }
+}
|
