diff options
Diffstat (limited to 'source/com/c2kernel/lifecycle/gui/model')
4 files changed, 230 insertions, 0 deletions
diff --git a/source/com/c2kernel/lifecycle/gui/model/WfDefGraphPanel.java b/source/com/c2kernel/lifecycle/gui/model/WfDefGraphPanel.java new file mode 100755 index 0000000..973fcbf --- /dev/null +++ b/source/com/c2kernel/lifecycle/gui/model/WfDefGraphPanel.java @@ -0,0 +1,58 @@ +/*Created on 21 nov. 2003 */
+package com.c2kernel.lifecycle.gui.model;
+
+import java.awt.Graphics2D;
+
+import com.c2kernel.graph.model.DirectedEdge;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.view.DirectedEdgeRenderer;
+import com.c2kernel.graph.view.GraphPanel;
+import com.c2kernel.graph.view.VertexRenderer;
+import com.c2kernel.lifecycle.NextDef;
+
+/** @author XSeb74*/
+public class WfDefGraphPanel extends GraphPanel
+{
+ public WfDefGraphPanel(DirectedEdgeRenderer d,VertexRenderer v)
+ {
+ super(d,v);
+ }
+ // Draws the highlight of the specified edge
+ protected void drawEdgeHighlight(Graphics2D g2d, DirectedEdge edge)
+ {
+ GraphPoint originPoint = edge.getOriginPoint();
+ GraphPoint terminusPoint = edge.getTerminusPoint();
+ GraphPoint midPoint = new GraphPoint();
+
+ if ("Straight".equals(((NextDef)edge).getProperties().get("Type")) || ((NextDef)edge).getProperties().get("Type") == null)
+ {
+ midPoint.x = originPoint.x + (terminusPoint.x - originPoint.x) / 2;
+ midPoint.y = originPoint.y + (terminusPoint.y - originPoint.y) / 2;
+ }
+ else if (("Broken +".equals(((NextDef)edge).getProperties().get("Type"))))
+ {
+ midPoint.x = (originPoint.x + terminusPoint.x) / 2;
+ midPoint.y = (originPoint.y + terminusPoint.y) / 2;
+ }
+ else if (("Broken -".equals(((NextDef)edge).getProperties().get("Type"))))
+ {
+ boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
+ midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
+ midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.y;
+ }
+ else if (("Broken |".equals(((NextDef)edge).getProperties().get("Type"))))
+ {
+ boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
+ midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
+ midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
+ }
+ int minX = midPoint.x - 10;
+ int minY = midPoint.y - 10;
+ int maxX = midPoint.x + 10;
+ int maxY = midPoint.y + 10;
+ g2d.drawLine(minX, minY, maxX, minY);
+ g2d.drawLine(maxX, minY, maxX, maxY);
+ g2d.drawLine(maxX, maxY, minX, maxY);
+ g2d.drawLine(minX, maxY, minX, minY);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/gui/model/WfEdgeDefFactory.java b/source/com/c2kernel/lifecycle/gui/model/WfEdgeDefFactory.java new file mode 100755 index 0000000..d6fd41c --- /dev/null +++ b/source/com/c2kernel/lifecycle/gui/model/WfEdgeDefFactory.java @@ -0,0 +1,29 @@ +package com.c2kernel.lifecycle.gui.model;
+import com.c2kernel.graph.model.DirectedEdge;
+import com.c2kernel.graph.model.EdgeFactory;
+import com.c2kernel.graph.model.GraphModelManager;
+import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
+import com.c2kernel.graph.model.Vertex;
+import com.c2kernel.lifecycle.NextDef;
+import com.c2kernel.lifecycle.WfVertexDef;
+public class WfEdgeDefFactory implements EdgeFactory
+{
+ public void create(
+ GraphModelManager graphModelManager,
+ Vertex origin,
+ Vertex terminus,
+ TypeNameAndConstructionInfo typeNameAndConstructionInfo)
+ {
+ if (validCreation(graphModelManager, origin, terminus))
+ {
+ NextDef nextDef = new NextDef((WfVertexDef) origin, (WfVertexDef) terminus);
+ graphModelManager.getModel().addEdgeAndCreateId(nextDef, origin, terminus);
+ }
+ }
+ private boolean validCreation(GraphModelManager graphModelManager, Vertex origin, Vertex terminus)
+ {
+ DirectedEdge[] connectingEdgesAToB = graphModelManager.getModel().getConnectingEdges(origin.getID(), terminus.getID());
+ DirectedEdge[] connectingEdgesBToA = graphModelManager.getModel().getConnectingEdges(terminus.getID(), origin.getID());
+ return (origin != terminus) && (connectingEdgesAToB.length == 0) && (connectingEdgesBToA.length == 0);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java new file mode 100755 index 0000000..0cb60e7 --- /dev/null +++ b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java @@ -0,0 +1,93 @@ +package com.c2kernel.lifecycle.gui.model;
+import java.awt.Point;
+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;
+ 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 mhm = new HashMap();
+ 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.getImageResource("graph/newvertex_large.png").getImage(),
+ this,
+ mhm);
+ a.setVisible(true);
+ }
+ else
+ mCompositeActivityDef.newChild("", vertexTypeId, location);
+ }
+ }
+ 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.getImageResource("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);
+ }
+ }
+ public void setCreationContext(Object newContext)
+ {
+ if (newContext != null && newContext instanceof CompositeActivityDef)
+ mCompositeActivityDef = (CompositeActivityDef) newContext;
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/gui/model/WfVertexDefOutlineCreator.java b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefOutlineCreator.java new file mode 100755 index 0000000..3727f35 --- /dev/null +++ b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefOutlineCreator.java @@ -0,0 +1,50 @@ +package com.c2kernel.lifecycle.gui.model;
+
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.model.Vertex;
+import com.c2kernel.graph.model.VertexOutlineCreator;
+import com.c2kernel.lifecycle.ActivitySlotDef;
+
+public class WfVertexDefOutlineCreator implements VertexOutlineCreator
+{
+ private final int mActivityWidth = 130;
+ private final int mActivityHeight = 60;
+ private final int mSplitJoinWidth = 60;
+ private final int mSplitJoinHeight = 25;
+
+ public void setOutline(Vertex vertex)
+ {
+ GraphPoint centrePoint = vertex.getCentrePoint();
+ GraphPoint[] outlinePoints = new GraphPoint[ 4 ];
+ int vertexWidth = 0;
+ int vertexHeight = 0;
+
+
+ if ( vertex instanceof ActivitySlotDef )
+ {
+ vertexWidth = mActivityWidth;
+ vertexHeight = mActivityHeight;
+ }
+ else
+ {
+ vertexWidth = mSplitJoinWidth;
+ vertexHeight = mSplitJoinHeight;
+ }
+
+ outlinePoints[ 0 ] = new GraphPoint();
+ outlinePoints[ 0 ].x = centrePoint.x - vertexWidth / 2;
+ outlinePoints[ 0 ].y = centrePoint.y - vertexHeight / 2;
+ outlinePoints[ 1 ] = new GraphPoint();
+ outlinePoints[ 1 ].x = centrePoint.x + vertexWidth / 2;
+ outlinePoints[ 1 ].y = centrePoint.y - vertexHeight / 2;
+ outlinePoints[ 2 ] = new GraphPoint();
+ outlinePoints[ 2 ].x = centrePoint.x + vertexWidth / 2;
+ outlinePoints[ 2 ].y = centrePoint.y + vertexHeight / 2;
+ outlinePoints[ 3 ] = new GraphPoint();
+ outlinePoints[ 3 ].x = centrePoint.x - vertexWidth / 2;
+ outlinePoints[ 3 ].y = centrePoint.y + vertexHeight / 2;
+
+ vertex.setOutlinePoints( outlinePoints );
+ }
+}
+
|
