01: package com.opensymphony.workflow.designer.views;
02:
03: import java.awt.event.MouseEvent;
04:
05: import com.opensymphony.workflow.designer.*;
06: import com.opensymphony.workflow.loader.ResultDescriptor;
07: import org.jgraph.graph.*;
08:
09: /**
10: * @author Hani Suleiman
11: * Date: Dec 2, 2003 Time: 2:22:44 PM
12: */
13: public class CustomEdgeView extends EdgeView {
14: public CustomEdgeView(Object obj) {
15: super (obj);
16: GraphConstants.setOpaque(this .attributes, true);
17: }
18:
19: /**
20: * Returns a cell handle for the view.
21: */
22: public CellHandle getHandle(GraphContext context) {
23: return new CustomEdgeHandle(this , context);
24: }
25:
26: public void setTarget(CellView targetView) {
27: super .setTarget(targetView);
28: if (targetView == null || targetView.getParentView() == null)
29: return;
30: if (targetView == source) {
31: ((ResultEdge) cell).setAutoroute();
32: }
33: WorkflowCell cell = (WorkflowCell) targetView.getParentView()
34: .getCell();
35: ResultDescriptor d = ((ResultEdge) getCell()).getDescriptor();
36: if (cell instanceof StepCell) {
37: d.setStep(cell.getId());
38: } else if (cell instanceof JoinCell) {
39: d.setJoin(cell.getId());
40: } else if (cell instanceof SplitCell) {
41: d.setSplit(cell.getId());
42: }
43: }
44:
45: public class CustomEdgeHandle extends EdgeHandle {
46:
47: CustomEdgeHandle(EdgeView edge, GraphContext ctx) {
48: super (edge, ctx);
49: }
50:
51: /**
52: * Returning true signifies a mouse event adds a new point to an edge.
53: */
54: public boolean isAddPointEvent(MouseEvent event) {
55: return event.isShiftDown();
56: }
57:
58: /**
59: * Returning true signifies a mouse event removes a given point.
60: */
61: public boolean isRemovePointEvent(MouseEvent event) {
62: return event.isShiftDown();
63: }
64: }
65: }
|