Author: koen.aers(a)jboss.com
Date: 2010-11-30 11:02:52 -0500 (Tue, 30 Nov 2010)
New Revision: 27027
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/providers/Bpmn2ViewProvider.java
Log:
serialize/deserialize waypoints
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/providers/Bpmn2ViewProvider.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/providers/Bpmn2ViewProvider.java 2010-11-30
15:52:47 UTC (rev 27026)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/providers/Bpmn2ViewProvider.java 2010-11-30
16:02:52 UTC (rev 27027)
@@ -1913,8 +1913,6 @@
points.add(new RelativeBendpoint());
bendpoints.setPoints(points);
edge.setBendpoints(bendpoints);
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
ViewUtil.insertChildView(containerView, edge, index, persisted);
edge.setType(Bpmn2VisualIDRegistry
.getType(SequenceFlowEditPart.VISUAL_ID));
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java 2010-11-30
15:52:47 UTC (rev 27026)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java 2010-11-30
16:02:52 UTC (rev 27027)
@@ -10,6 +10,7 @@
import org.eclipse.dd.di.DiagramElement;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.gmf.runtime.notation.impl.RelativeBendpointsImpl;
@@ -33,9 +34,8 @@
if (object instanceof RelativeBendpoint) {
RelativeBendpoint relativeBendPoint = (RelativeBendpoint)object;
Point absoluteBendpoint = DcFactory.eINSTANCE.createPoint();
- BPMNEdge bpmnEdge = ((BpmnEdgeImpl)edge).getBPMNEdge();
- DiagramElement source = bpmnEdge.getSourceElement();
- if (source != null && source instanceof BPMNShape) {
+ BPMNShape source = getEdgeSource();
+ if (source != null) {
Bounds sourceBounds = ((BPMNShape)source).getBounds();
absoluteBendpoint.setX(sourceBounds.getX() + relativeBendPoint.getSourceX());
absoluteBendpoint.setY(sourceBounds.getY() + relativeBendPoint.getSourceY());
@@ -48,4 +48,11 @@
super.setPoints(newPoints);
}
+ private BPMNShape getEdgeSource() {
+ if (edge == null) return null;
+ View source = edge.getSource();
+ if (!(source instanceof BpmnShapeImpl)) return null;
+ return ((BpmnShapeImpl)source).getBPMNShape();
+ }
+
}
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java 2010-11-30
15:52:47 UTC (rev 27026)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java 2010-11-30
16:02:52 UTC (rev 27027)
@@ -1,9 +1,12 @@
package org.jboss.tools.bpmn2.gmf.notation;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.di.BPMNEdge;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.dd.dc.Point;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EObject;
@@ -50,14 +53,7 @@
}
super.setBendpoints(bendpoints);
}
-
- @Override
- public void setSource(View newSource) {
- super.setSource(newSource);
- // force refresh of the points list
- ((BpmnBendpointsImpl)getBendpoints()).setPoints(((BpmnBendpointsImpl)getBendpoints()).getPoints());
- }
-
+
public void initialize(Diagram parentView) {
initializeElement();
initializeBendpoints();
@@ -67,10 +63,25 @@
}
private void initializeBendpoints() {
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
+ RelativeBendpoints bendpoints =
BpmnNotationFactory.INSTANCE.createRelativeBendpoints();
+ List<Point> waypoints = getBPMNEdge().getWaypoint();
+ ArrayList<RelativeBendpoint> points = new
ArrayList<RelativeBendpoint>(waypoints.size());
+ for (Point waypoint : waypoints) {
+ float sourceX = 0, sourceY = 0, targetX = 0, targetY = 0;
+ View source = getSource();
+ if (source instanceof BpmnShapeImpl) {
+ Bounds bounds = ((BpmnShapeImpl)source).getBPMNShape().getBounds();
+ sourceX = waypoint.getX() - bounds.getX();
+ sourceY = waypoint.getY() - bounds.getY();
+ }
+ View target = getTarget();
+ if (target instanceof BpmnShapeImpl) {
+ Bounds bounds = ((BpmnShapeImpl)target).getBPMNShape().getBounds();
+ targetX = waypoint.getX() - bounds.getX();
+ targetY = waypoint.getY() - bounds.getY();
+ }
+ points.add(new RelativeBendpoint((int)sourceX, (int)sourceY, (int)targetX,
(int)targetY));
+ }
bendpoints.setPoints(points);
setBendpoints(bendpoints);
Show replies by date