summaryrefslogtreecommitdiffstats
authorAntoine Toulme2010-08-13 18:08:08 (EDT)
committer Antoine Toulme2010-08-13 18:08:08 (EDT)
commit3f7933364e05dad1556cfae44c736585067ef90e (patch) (side-by-side diff)
tree97e32c0304cb4e10c5d966f9a43058e0c85e2470
parentb15a9c658110e59056eebf7b610fd2568339ce54 (diff)
downloadbpmnmodeler-3f7933364e05dad1556cfae44c736585067ef90e.zip
bpmnmodeler-3f7933364e05dad1556cfae44c736585067ef90e.tar.gz
bpmnmodeler-3f7933364e05dad1556cfae44c736585067ef90e.tar.bz2
Enhancement to make lanes more flexible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/figures/BpmnShapesDefaultSizes.java3
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/BpmnDiagramXYLayoutEditPolicy.java406
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/PoolPoolCompartmentXYLayoutEditPolicy.java227
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizableLaneEditPolicy.java58
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizablePoolEditPolicy.java15
-rw-r--r--org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/tools/PoolResizeTracker.java113
-rw-r--r--org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/edit/parts/LaneEditPart.java6
7 files changed, 455 insertions, 373 deletions
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/figures/BpmnShapesDefaultSizes.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/figures/BpmnShapesDefaultSizes.java
index ed79034..53c38b5 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/figures/BpmnShapesDefaultSizes.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/figures/BpmnShapesDefaultSizes.java
@@ -28,6 +28,7 @@ import org.eclipse.stp.bpmn.Activity;
import org.eclipse.stp.bpmn.ActivityType;
import org.eclipse.stp.bpmn.commands.ElementTypeEx;
import org.eclipse.stp.bpmn.diagram.edit.parts.ActivityEditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.SubProcessEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.SubProcessSubProcessBodyCompartmentEditPart;
@@ -155,7 +156,7 @@ public class BpmnShapesDefaultSizes {
// TODO
}
if (BpmnElementTypes.Lane_2007.getId().equals(elementTypeId)) {
- // not implemented.
+ return LaneEditPart.DEFAULT_SIZE.getCopy();
}
return DEFAULT_SIZE;
}
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/BpmnDiagramXYLayoutEditPolicy.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/BpmnDiagramXYLayoutEditPolicy.java
index 6650234..dbebe25 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/BpmnDiagramXYLayoutEditPolicy.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/BpmnDiagramXYLayoutEditPolicy.java
@@ -41,6 +41,8 @@ import org.eclipse.stp.bpmn.BpmnDiagram;
import org.eclipse.stp.bpmn.diagram.BpmnDiagramMessages;
import org.eclipse.stp.bpmn.diagram.edit.parts.DataObject2EditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.Group2EditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneNameEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolPoolCompartmentEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.TextAnnotation2EditPart;
@@ -48,239 +50,223 @@ import org.eclipse.stp.bpmn.diagram.part.BpmnVisualIDRegistry;
import org.eclipse.stp.bpmn.diagram.providers.BpmnElementTypes;
/**
- * Policy to enforce layout constraints on pools:
- * no overlapping
- * hopefully some space between children:
- * as we cannot touch the pool before it is created, we move the pool below its
- * location.
+ * Policy to enforce layout constraints on pools: no overlapping hopefully some
+ * space between children: as we cannot touch the pool before it is created, we
+ * move the pool below its location.
+ *
* @author <a href="mailto:atoulme@intalio.com">Antoine Toulm&eacute;</a>
* @author <a href="http://www.intalio.com">&copy; Intalio, Inc.</a>
*/
public class BpmnDiagramXYLayoutEditPolicy extends XYLayoutEditPolicy {
- /** TODO: replace this by taking into account the page guides */
- // 15 january 2007: set the offset from 10 to 16, seems better.
+ /** TODO: replace this by taking into account the page guides */
+ // 15 january 2007: set the offset from 10 to 16, seems better.
public static final int DEFAULT_POOL_X_COORD = 16;
-
-
- @Override
- protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
- // don't bother this edit policy if your calls are not
- // about a part, and if there is neither move nor resize planned.
- if (request.getEditParts() == null || request.getEditParts().isEmpty()) {
- return null;
- }
- if ((request.getMoveDelta() == null ||
- request.getMoveDelta().equals(new Point(0, 0))) &&
- (request.getSizeDelta() == null ||
- request.getSizeDelta().equals(new Dimension(0, 0)))) {
- return null;
- }
- // let's skip groups, they do not resize the pool.
+
+ @Override
+ protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
+ // don't bother this edit policy if your calls are not
+ // about a part, and if there is neither move nor resize planned.
+ if (request.getEditParts() == null || request.getEditParts().isEmpty()) {
+ return null;
+ }
+ if ((request.getMoveDelta() == null || request.getMoveDelta().equals(new Point(0, 0)))
+ && (request.getSizeDelta() == null || request.getSizeDelta().equals(new Dimension(0, 0)))) {
+ return null;
+ }
+ // let's skip groups, they do not resize the pool.
boolean onlyContainsArtifacts = true;
for (Object o : request.getEditParts()) {
- onlyContainsArtifacts = onlyContainsArtifacts &&
- (o instanceof IGraphicalEditPart &&
- ((IGraphicalEditPart) o).resolveSemanticElement() instanceof Artifact);
+ onlyContainsArtifacts = onlyContainsArtifacts
+ && (o instanceof IGraphicalEditPart && ((IGraphicalEditPart) o).resolveSemanticElement() instanceof Artifact);
}
if (onlyContainsArtifacts) {
return super.getResizeChildrenCommand(request);
}
- //calculate maxWidth
- int maxWidth = /*PoolEditPart.POOL_WIDTH*/ 200;
- // put child parts in a map, referenced by their bounds
- // if changes apply to their bounds, record them in the bounds used as key
- Map<Rectangle, IGraphicalEditPart> toSortBounds =
- new LinkedHashMap<Rectangle, IGraphicalEditPart>();
-
- ZoomManager zoom = ((DiagramRootEditPart) getHost().getRoot()).getZoomManager();
- for (Object child : getHost().getChildren()) {
- IGraphicalEditPart childPart = (IGraphicalEditPart) child;
- if (!(child instanceof PoolEditPart)) {
- continue;
- }
- Rectangle rect = childPart.getFigure().getBounds().getCopy();
-
- if (request.getEditParts() != null &&
- request.getEditParts().contains(child)) {
-
- if (request.getSizeDelta() != null) {
- rect.width += request.getSizeDelta().width/zoom.getZoom();
- rect.height += request.getSizeDelta().height/zoom.getZoom();
- }
- if (request.getMoveDelta() != null) {
- rect.y += request.getMoveDelta().y/zoom.getZoom();
- rect.x += request.getMoveDelta().x/zoom.getZoom();
- }
- }
- maxWidth = maxWidth < rect.width ? rect.width : maxWidth;
- //make sure that there is no edit parts using the same coordinates
+ // calculate maxWidth
+ int maxWidth = /* PoolEditPart.POOL_WIDTH */200;
+ // put child parts in a map, referenced by their bounds
+ // if changes apply to their bounds, record them in the bounds used as
+ // key
+ Map<Rectangle, IGraphicalEditPart> toSortBounds = new LinkedHashMap<Rectangle, IGraphicalEditPart>();
+
+ ZoomManager zoom = ((DiagramRootEditPart) getHost().getRoot()).getZoomManager();
+ for (Object child : getHost().getChildren()) {
+ IGraphicalEditPart childPart = (IGraphicalEditPart) child;
+ if (!(child instanceof PoolEditPart)) {
+ continue;
+ }
+ Rectangle rect = childPart.getFigure().getBounds().getCopy();
+
+ if (request.getEditParts() != null && request.getEditParts().contains(child)) {
+
+ if (request.getSizeDelta() != null) {
+ rect.width += request.getSizeDelta().width / zoom.getZoom();
+ rect.height += request.getSizeDelta().height / zoom.getZoom();
+ }
+ if (request.getMoveDelta() != null) {
+ rect.y += request.getMoveDelta().y / zoom.getZoom();
+ rect.x += request.getMoveDelta().x / zoom.getZoom();
+ }
+ }
+ maxWidth = maxWidth < rect.width ? rect.width : maxWidth;
+ // make sure that there is no edit parts using the same coordinates
// thus forbidding each other to move.
while (toSortBounds.keySet().contains(rect)) {
rect.y += 1;
}
- toSortBounds.put(rect, childPart);
- }
-
- // sort the new bounds by y
- List<Rectangle> keys = new LinkedList<Rectangle>
- (toSortBounds.keySet());
- Collections.sort(keys, new Comparator<Rectangle>() {
+ toSortBounds.put(rect, childPart);
+ }
+
+ // sort the new bounds by y
+ List<Rectangle> keys = new LinkedList<Rectangle>(toSortBounds.keySet());
+ Collections.sort(keys, new Comparator<Rectangle>() {
+
+ public int compare(Rectangle o1, Rectangle o2) {
+ if (o1.y <= o2.y) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ });
+
+ int y = 0;
+
+ // now create a chain of command,
+ // placing pools according to their y position,
+ // but not letting them choose it.
+ CompoundCommand command = new CompoundCommand(BpmnDiagramMessages.BpmnDiagramXYLayoutEditPolicy_command_name);
+ for (Rectangle key : keys) {
+ IGraphicalEditPart part = toSortBounds.get(key);
+
+ // keep the y coordinate of the pool if more than the mininum space
+ // between pools.
+ y = key.y < y + DEFAULT_POOL_X_COORD ? y + DEFAULT_POOL_X_COORD : key.y;
+ key.y = y;
+ if (part instanceof PoolEditPart) {
+ key.x = DEFAULT_POOL_X_COORD;
+ key.width = maxWidth;
+ }
+
+ Command co = createChangeConstraintCommand(part, key);
+ command.add(co);
+
+ if (request.getEditParts().contains(part) && request.getSizeDelta().height != 0) {
+ PoolPoolCompartmentEditPart compartment = (PoolPoolCompartmentEditPart) part.getChildBySemanticHint(BpmnVisualIDRegistry
+ .getType(PoolPoolCompartmentEditPart.VISUAL_ID));
+ if (compartment != null) {
+ ChangeBoundsRequest laneUpdateRequest = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE_CHILDREN);
+ laneUpdateRequest.setEditParts(part);
+ laneUpdateRequest.setMoveDelta(request.getMoveDelta().getCopy());
+ laneUpdateRequest.setSizeDelta(request.getSizeDelta().getCopy());
+ command.add(compartment.getCommand(laneUpdateRequest));
+ }
+ }
+ y += key.height;
- public int compare(Rectangle o1, Rectangle o2) {
- if (o1.y <= o2.y) {
- return -1;
- } else {
- return 1;
- }
- }});
-
- int y = 0;
-
-
- // now create a chain of command,
- // placing pools according to their y position,
- // but not letting them choose it.
- CompoundCommand command = new CompoundCommand(BpmnDiagramMessages.BpmnDiagramXYLayoutEditPolicy_command_name);
- for (Rectangle key : keys) {
- IGraphicalEditPart part = toSortBounds.get(key);
-
- // keep the y coordinate of the pool if more than the mininum space between pools.
- y = key.y < y + DEFAULT_POOL_X_COORD ?
- y + DEFAULT_POOL_X_COORD : key.y;
- key.y = y;
- if (part instanceof PoolEditPart) {
- key.x = DEFAULT_POOL_X_COORD;
- key.width = maxWidth;
- }
-
- Command co = createChangeConstraintCommand(part, key);
- command.add(co);
-
- if (request.getEditParts().contains(part) && request.getSizeDelta().height != 0) {
- PoolPoolCompartmentEditPart compartment =
- (PoolPoolCompartmentEditPart) part.getChildBySemanticHint(
- BpmnVisualIDRegistry.getType(
- PoolPoolCompartmentEditPart.VISUAL_ID));
- if (compartment != null) {
- ChangeBoundsRequest laneUpdateRequest = new ChangeBoundsRequest(
- RequestConstants.REQ_RESIZE_CHILDREN);
- laneUpdateRequest.setEditParts(part);
- laneUpdateRequest.setMoveDelta(request.getMoveDelta().getCopy());
- laneUpdateRequest.setSizeDelta(request.getSizeDelta().getCopy());
- command.add(compartment.getCommand(laneUpdateRequest));
- }
- }
- y += key.height;
-
- // if the pool is resized in the northern direction, shapes should be moved south as an opposite
- // so that the user thinks he is resizing the pool by adding space at the top.
- if (request.getSizeDelta().height == -request.getMoveDelta().y && (request.getSizeDelta().height != 0)) {
- if (request.getEditParts() != null && request.getEditParts().contains(part)) {
- final IGraphicalEditPart comp = part.getChildBySemanticHint(BpmnVisualIDRegistry.getType(
- PoolPoolCompartmentEditPart.VISUAL_ID));
- if (comp != null) { // if comp is null this wasn't a pool in the first place
- ChangeBoundsRequest move = new ChangeBoundsRequest(org.eclipse.gef.RequestConstants.REQ_MOVE_CHILDREN);
+ // if the pool is resized in the northern direction, shapes should
+ // be moved south as an opposite
+ // so that the user thinks he is resizing the pool by adding space
+ // at the top.
+ if (request.getSizeDelta().height == -request.getMoveDelta().y && (request.getSizeDelta().height != 0)) {
+ if (request.getEditParts() != null && request.getEditParts().contains(part)) {
+ final IGraphicalEditPart comp = part.getChildBySemanticHint(BpmnVisualIDRegistry.getType(PoolPoolCompartmentEditPart.VISUAL_ID));
+ if (comp != null) { // if comp is null this wasn't a pool in
+ // the first place
+ ChangeBoundsRequest move = new ChangeBoundsRequest(org.eclipse.gef.RequestConstants.REQ_MOVE_CHILDREN);
move.setMoveDelta(new Point(0, request.getSizeDelta().height));
- //move.setConstrainedMove(true);//does nothing.
- move.setEditParts(comp.getChildren());
+ // move.setConstrainedMove(true);//does nothing.
+ move.setEditParts(comp.getChildren());
Command c = comp.getCommand(move);
if (c != null && c.canExecute()) {
command.add(c);
}
- //the code below is bug EDGE-2179
-// int ymove = (int) (request.getSizeDelta().height/zoom.getZoom());
-// for (Object child : comp.getChildren()) {
-// IGraphicalEditPart ep = (IGraphicalEditPart) child;
-// Rectangle rect = ep.getFigure().getBounds().getCopy();
-// rect.y += ymove;
-// command.add(createChangeConstraintCommand(ep, rect));
-// }
- }
- }
- }
- }
- return command;
- }
-
- @Override
- protected Object getConstraintFor(CreateRequest request) {
- Object constraint = super.getConstraintFor(request);
- if (request == null || request.getNewObject() == null ||
- ((List) request.getNewObject()).isEmpty() ||
- ((List) request.getNewObject()).get(0) == null ||
- ((ViewDescriptor) ((List) request.getNewObject()).get(0)).
- getElementAdapter() == null ||
- ((List) request.getNewObject()).get(0) == null) {
- return constraint;
- }
- IElementType type = (IElementType)
- ((ViewDescriptor) ((List) request.getNewObject()).get(0)).getElementAdapter().getAdapter(IElementType.class);
-
-
- //recalculate maxWidth
- int maxWidth = 200;
- if (((BpmnDiagram) ((IGraphicalEditPart) getHost()).resolveSemanticElement()).
- getPools().isEmpty()) {
- maxWidth = PoolEditPart.POOL_WIDTH;
- }
-
+ // the code below is bug EDGE-2179
+ // int ymove = (int)
+ // (request.getSizeDelta().height/zoom.getZoom());
+ // for (Object child : comp.getChildren()) {
+ // IGraphicalEditPart ep = (IGraphicalEditPart) child;
+ // Rectangle rect =
+ // ep.getFigure().getBounds().getCopy();
+ // rect.y += ymove;
+ // command.add(createChangeConstraintCommand(ep, rect));
+ // }
+ }
+ }
+ }
+ }
+ return command;
+ }
+
+ @Override
+ protected Object getConstraintFor(CreateRequest request) {
+ Object constraint = super.getConstraintFor(request);
+ if (request == null || request.getNewObject() == null || ((List) request.getNewObject()).isEmpty()
+ || ((List) request.getNewObject()).get(0) == null
+ || ((ViewDescriptor) ((List) request.getNewObject()).get(0)).getElementAdapter() == null
+ || ((List) request.getNewObject()).get(0) == null) {
+ return constraint;
+ }
+ IElementType type = (IElementType) ((ViewDescriptor) ((List) request.getNewObject()).get(0)).getElementAdapter().getAdapter(
+ IElementType.class);
+
+ // recalculate maxWidth
+ int maxWidth = 200;
+ if (((BpmnDiagram) ((IGraphicalEditPart) getHost()).resolveSemanticElement()).getPools().isEmpty()) {
+ maxWidth = PoolEditPart.POOL_WIDTH;
+ }
+
+ for (Object child : getHost().getChildren()) {
+ IGraphicalEditPart childPart = (IGraphicalEditPart) child;
+ Rectangle rect = childPart.getFigure().getBounds().getCopy();
+ maxWidth = maxWidth < rect.width ? rect.width : maxWidth;
+ }
+
+ if (type == BpmnElementTypes.Pool_1001) {
+ ((Rectangle) constraint).x = DEFAULT_POOL_X_COORD;
+ ((Rectangle) constraint).width = maxWidth;
+ ((Rectangle) constraint).height = PoolEditPart.POOL_HEIGHT;
+ return constraint;
+ }
+ return constraint;
+ }
- for (Object child : getHost().getChildren()) {
- IGraphicalEditPart childPart = (IGraphicalEditPart) child;
- Rectangle rect = childPart.getFigure().getBounds().getCopy();
+ @Override
+ protected Command getCreateCommand(CreateRequest request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ String type = ((ViewAndElementDescriptor) ((List) ((CreateViewAndElementRequest) request).getViewDescriptors()).iterator().next())
+ .getSemanticHint();
+ if (BpmnVisualIDRegistry.getType(Group2EditPart.VISUAL_ID).equals(type)
+ || BpmnVisualIDRegistry.getType(DataObject2EditPart.VISUAL_ID).equals(type)
+ || BpmnVisualIDRegistry.getType(TextAnnotation2EditPart.VISUAL_ID).equals(type)) {
+ return super.getCreateCommand(request);
+ }
+ }
+ CompoundCommand co = new CompoundCommand();
+ co.add(super.getCreateCommand(request));
+ ChangeBoundsRequest req = new ChangeBoundsRequest();
+ req.setType(RequestConstants.REQ_RESIZE_CHILDREN);
+ // find if there is a pool below.
+ Rectangle addedThing = ((Rectangle) getConstraintFor(request));
+ List children = ((IGraphicalEditPart) getHost()).getChildren();
+ List<IGraphicalEditPart> parts = new LinkedList<IGraphicalEditPart>();
- maxWidth = maxWidth < rect.width ? rect.width : maxWidth;
- }
-
- if (type == BpmnElementTypes.Pool_1001) {
- ((Rectangle) constraint).x = DEFAULT_POOL_X_COORD;
- ((Rectangle) constraint).width = maxWidth;
- ((Rectangle) constraint).height = PoolEditPart.POOL_HEIGHT;
- return constraint;
- }
- return constraint;
- }
-
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- if (request instanceof CreateViewAndElementRequest) {
- String type = ((ViewAndElementDescriptor)
- ((List) ((CreateViewAndElementRequest) request).getViewDescriptors()).iterator().next()).getSemanticHint();
- if (BpmnVisualIDRegistry.getType(Group2EditPart.VISUAL_ID).equals(type) ||
- BpmnVisualIDRegistry.getType(DataObject2EditPart.VISUAL_ID).equals(type) ||
- BpmnVisualIDRegistry.getType(TextAnnotation2EditPart.VISUAL_ID).equals(type)) {
- return super.getCreateCommand(request);
- }
- }
- CompoundCommand co = new CompoundCommand();
- co.add(super.getCreateCommand(request));
- ChangeBoundsRequest req = new ChangeBoundsRequest();
- req.setType(RequestConstants.REQ_RESIZE_CHILDREN);
- // find if there is a pool below.
- Rectangle addedThing = ((Rectangle) getConstraintFor(request));
- List children = ((IGraphicalEditPart) getHost()).getChildren();
- List<IGraphicalEditPart> parts = new LinkedList<IGraphicalEditPart>();
-
- Point location = request.getLocation().getCopy();
+ Point location = request.getLocation().getCopy();
getHostFigure().translateToRelative(location);
- for (Object child : children) {
- Rectangle rect = ((IGraphicalEditPart) child).getFigure().getBounds();
- if (rect.y > (location.y)) { // added 5
- parts.add((IGraphicalEditPart) child);
- }
- }
- if (!parts.isEmpty()) {
- req.setEditParts(parts);
- req.setConstrainedMove(true);
-
- req.setMoveDelta(new Point(
- addedThing.x,
- ((Rectangle) getConstraintFor(request)).height +
- DEFAULT_POOL_X_COORD));
- co.add(getResizeChildrenCommand(req));
- }
- return co;
- }
+ for (Object child : children) {
+ Rectangle rect = ((IGraphicalEditPart) child).getFigure().getBounds();
+ if (rect.y > (location.y)) { // added 5
+ parts.add((IGraphicalEditPart) child);
+ }
+ }
+ if (!parts.isEmpty()) {
+ req.setEditParts(parts);
+ req.setConstrainedMove(true);
+
+ req.setMoveDelta(new Point(addedThing.x, ((Rectangle) getConstraintFor(request)).height + DEFAULT_POOL_X_COORD));
+ co.add(getResizeChildrenCommand(req));
+ }
+ return co;
+ }
}
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/PoolPoolCompartmentXYLayoutEditPolicy.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/PoolPoolCompartmentXYLayoutEditPolicy.java
index 1a77fd4..2f465a4 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/PoolPoolCompartmentXYLayoutEditPolicy.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/PoolPoolCompartmentXYLayoutEditPolicy.java
@@ -65,6 +65,7 @@ import org.eclipse.stp.bpmn.diagram.BpmnDiagramMessages;
import org.eclipse.stp.bpmn.diagram.edit.parts.Group2EditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.GroupEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneNameEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.MessagingEdgeNameEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolPoolCompartmentEditPart;
@@ -328,6 +329,23 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
}
}
+ // added:
+ // the pool cannot be smaller than the minimum size of its lanes:
+
+ Rectangle dimLanes = new Rectangle();
+ for (Object child : getHost().getChildren()) {
+ if (child instanceof LaneEditPart) {
+ IGraphicalEditPart part = (IGraphicalEditPart) child;
+ LaneNameEditPart namePart = (LaneNameEditPart) part.getChildBySemanticHint(Integer.toString(LaneNameEditPart.VISUAL_ID));
+ if (namePart != null) {
+ dimLanes.width += namePart.getFigure().getSize().width;
+ dimLanes.height += namePart.getFigure().getSize().height;
+ }
+ }
+ }
+ dim.width = Math.max(dim.width, dimLanes.width);
+ dim.height = Math.max(dim.height, dimLanes.height);
+
// now calculate the delta.
dim.width = (int) (dim.width - initialdim.width + INSETS.getWidth());
dim.height = (int) (dim.height - initialdim.height + INSETS.getHeight());
@@ -397,6 +415,27 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
}
}
+ if (request != null && request.getSizeDelta().height == 0) {
+ // now we need to change the bounds of the lanes since they may have moved on the y axis.
+ // lanes are ordered through their y coordinate. We use that.
+ Rectangle previous = null;
+ int height = 0;
+ for (Rectangle rect : orderedLaneBounds) {
+ if (previous != null) {
+ rect.y = previous.y + previous.height;
+ } else {
+ rect.y = 0;
+ }
+ previous = rect;
+ height += rect.height;
+ }
+ // take the remaining room.
+ if (previous != null && height < getHostFigure().getBounds().height) {
+ previous.height += getHostFigure().getBounds().height - height;
+ }
+ }
+
+
}
/**
@@ -476,105 +515,70 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
return;
}
} else if (request != null) {
-
- //decide if the resize is happening at the bottom of a lane or at the top
- if (request.getMoveDelta().y != 0 &&
- request.getSizeDelta().height == -request.getMoveDelta().y) {
- //it is the resize of the top of a lane
- LinkedList<Rectangle> rects = new LinkedList<Rectangle>(set);
- Rectangle prevLast = null;//rects.removeLast();
- boolean foundTheFirst = false;
- int beforeChangeTopY = -1;
- int beforeChangeBottomY = -1;
- while (!rects.isEmpty()) {
- Rectangle last = rects.removeLast();
- if (prevLast != null) {
- if (prevLast.y != last.y + last.height) {
- beforeChangeTopY = last.y;
- beforeChangeBottomY = last.y + last.height;
- last.height = prevLast.y - last.y;
- if (last.height <= 48) {
- last.height = 48;
- int prevBottomY = prevLast.y + prevLast.height;
- prevLast.y = last.y + last.height;
- prevLast.height = prevBottomY - prevLast.y;
- }
-
- //the following is dumb: 2 editparts are actually updated.
- //not one.
- /*
- if (true) {
- //found the first lane.
- //it is the lane being resized.
- //let's compute the the coeff of the resize.
- //then let's move all the shapes inside the lane
- //to keep them inside the lane
- foundTheFirst = true;
- for (EditPart child : (List<EditPart>)getHost().getChildren()) {
- if (child instanceof ShapeEditPart && !(child instanceof LaneEditPart)) {
- ShapeEditPart se = (ShapeEditPart)child;
- Point topLeft = se.getFigure().getBounds().getTopLeft();
- System.err.println(beforeChangeBottomY + " > " + topLeft.y + " >= " + beforeChangeTopY);
- if (topLeft.y >= beforeChangeTopY &&
- topLeft.y < beforeChangeBottomY) {
- System.err.println("got one");
- Rectangle newB =
- se.getFigure().getBounds().getCopy();
-
- int beforeLaneHeight = beforeChangeBottomY - beforeChangeTopY;
- int afterLaneHeight = last.height;
- double coeff = 1.0*afterLaneHeight/beforeLaneHeight;
-
- int diffChildToBottom = -beforeChangeBottomY + topLeft.y;
- double newDiff = diffChildToBottom * coeff;
-
- newB.y = topLeft.y + (int)Math.round(newDiff);
- Command c = createChangeConstraintCommand(se, newB);
- cc.add(c);
- }
- }
+ if (request.getSizeDelta().height == 0) {
+ // moving a lane around. We can take the lane and change its position.
+ } else {
+ //decide if the resize is happening at the bottom of a lane or at the top
+ if (request.getMoveDelta().y != 0 &&
+ request.getSizeDelta().height == -request.getMoveDelta().y) {
+ //it is the resize of the top of a lane
+ LinkedList<Rectangle> rects = new LinkedList<Rectangle>(set);
+ Rectangle prevLast = null;//rects.removeLast();
+ boolean foundTheFirst = false;
+ int beforeChangeTopY = -1;
+ int beforeChangeBottomY = -1;
+ while (!rects.isEmpty()) {
+ Rectangle last = rects.removeLast();
+ if (prevLast != null) {
+ if (prevLast.y != last.y + last.height) {
+ beforeChangeTopY = last.y;
+ beforeChangeBottomY = last.y + last.height;
+ last.height = prevLast.y - last.y;
+ if (last.height <= 48) {
+ last.height = 48;
+ int prevBottomY = prevLast.y + prevLast.height;
+ prevLast.y = last.y + last.height;
+ prevLast.height = prevBottomY - prevLast.y;
}
-
- }*/
-
+ }
}
+ prevLast = last;
}
- prevLast = last;
- }
- } else {
- //resize happening at the bottom.
-
- // prevent lanes overlapping
- Rectangle firstBounds = null;
- for (Rectangle secondBounds : set) {
- if ((firstBounds != null &&
- firstBounds.y + firstBounds.height != secondBounds.y) ||
- secondBounds.y != INSETS.top){
- // int yDelta = firstBounds != null ?
- // firstBounds.y + firstBounds.height - secondBounds.y :
- // INSETS.top - secondBounds.y;
- int heightDelta = -secondBounds.y;
- if (firstBounds == null) {
- secondBounds.setLocation(0, INSETS.top);
- } else {
- secondBounds.setLocation(0, firstBounds.y + firstBounds.height);
+ } else {
+ //resize happening at the bottom.
+
+ // prevent lanes overlapping
+ Rectangle firstBounds = null;
+ for (Rectangle secondBounds : set) {
+ if ((firstBounds != null &&
+ firstBounds.y + firstBounds.height != secondBounds.y) ||
+ secondBounds.y != INSETS.top){
+ // int yDelta = firstBounds != null ?
+ // firstBounds.y + firstBounds.height - secondBounds.y :
+ // INSETS.top - secondBounds.y;
+ int heightDelta = -secondBounds.y;
+ if (firstBounds == null) {
+ secondBounds.setLocation(0, INSETS.top);
+ } else {
+ secondBounds.setLocation(0, firstBounds.y + firstBounds.height);
+ }
+ heightDelta += secondBounds.y;
+ //reduce the height of the lane to accomodate the change:
+ secondBounds.setSize(secondBounds.width, secondBounds.height - heightDelta);
}
- heightDelta += secondBounds.y;
- //reduce the height of the lane to accomodate the change:
- secondBounds.setSize(secondBounds.width, secondBounds.height - heightDelta);
+ firstBounds = secondBounds;
}
- firstBounds = secondBounds;
- }
- //make sure the last entry actually fills the rest of the room:
- //make sure the last one is updated to be at the border of the pool:
- Point bottomLane = firstBounds.getBottom();
- Point bottomPool = getHostFigure().getBounds().getBottom();
-
- if (bottomLane.y != bottomPool.y - INSETS.bottom) {
- firstBounds.setSize(firstBounds.width, firstBounds.height
- + bottomPool.y - bottomLane.y - INSETS.bottom);
+ //make sure the last entry actually fills the rest of the room:
+ //make sure the last one is updated to be at the border of the pool:
+ Point bottomLane = firstBounds.getBottom();
+ Point bottomPool = getHostFigure().getBounds().getBottom();
+
+ if (bottomLane.y != bottomPool.y - INSETS.bottom) {
+ firstBounds.setSize(firstBounds.width, firstBounds.height
+ + bottomPool.y - bottomLane.y - INSETS.bottom);
+ }
+
}
-
}
}
@@ -668,6 +672,7 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
fillMapAndSet(map, set, null, null);
Map<ViewDescriptor, Rectangle> descriptorsMap = new HashMap<ViewDescriptor, Rectangle>();
Set<Rectangle> insertedRectangles = null;
+ CompoundCommand compoundCommand = new CompoundCommand();
while (iter.hasNext()) {
CreateViewRequest.ViewDescriptor viewDescriptor = (CreateViewRequest.ViewDescriptor) iter
.next();
@@ -682,27 +687,33 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
Point location = req.getLocation().getCopy();
getHostFigure().translateToRelative(location);
int ind = 0;
+ boolean addHeight = false;
for (Rectangle otherLane : set) {
// System.err.println(otherLane.y + " compared " + location.y
// + " upper " + otherLane.y + otherLane.height);
if (otherLane.y < location.y && otherLane.y + otherLane.height >= location.y) {
//ok we got the lane
- otherLane.height = otherLane.height / 2;
- rect.height = otherLane.height;
+// otherLane.height = otherLane.height / 2;
+ rect.height = LaneEditPart.DEFAULT_SIZE.getCopy().height;
//see if we insert it before or after the lane
//where the creation request is made.
//if in the lower half we insert it after.
//if in the top half we insert it before.
- if (otherLane.y + otherLane.height >= location.y) {
+ if (otherLane.height/2 >= location.y - otherLane.y) { // to revisit, this is not accurate. FIXME
rect.y = otherLane.y;
// add +2 to make sure a command will be issued.
otherLane.y += rect.height + 2;
} else {
- rect.y = otherLane.y + rect.height + 2;
+ rect.y = otherLane.y + otherLane.height + 2;
}
- break;
+ addHeight = true;
+ continue;
+ }
+ if (!addHeight) {
+ ind++;
+ } else {
+ otherLane.y += rect.height +2;
}
- ind++;
}
if (insertedRectangles == null) {
@@ -719,7 +730,21 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
- PoolPoolCompartmentEditPart.INSETS.top
- PoolPoolCompartmentEditPart.INSETS.bottom;
}
- insertedRectangles.add(rect);
+ insertedRectangles.add(rect);
+ // add a command to resize the pool:
+ ChangeBoundsRequest poolResizeRequest = new ChangeBoundsRequest(REQ_RESIZE_CHILDREN);
+ poolResizeRequest.setEditParts(getHost().getParent());
+
+ poolResizeRequest.setMoveDelta(new Point(0, 0));
+ // we increase the pool by the height needed to see all the lanes:
+ int height = 0;
+ for (Rectangle r : set) {
+ height += r.height;
+ }
+ height += rect.height;
+ poolResizeRequest.setSizeDelta(new Dimension(0, height - getHostFigure().getBounds().height + PoolPoolCompartmentEditPart.INSETS.top + PoolPoolCompartmentEditPart.INSETS.bottom));
+ poolResizeRequest.setResizeDirection(PositionConstants.SOUTH);
+ compoundCommand.add(getHost().getParent().getParent().getCommand(poolResizeRequest));
}
descriptorsMap.put(viewDescriptor, rect);
}
@@ -728,7 +753,7 @@ public class PoolPoolCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
set.addAll(insertedRectangles);
}
- CompoundCommand compoundCommand = new CompoundCommand();
+
doLayout(null, map, set, compoundCommand, insertedRectangles);
if (compoundCommand.canExecute()) {
cc.compose(new CommandProxy(compoundCommand));
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizableLaneEditPolicy.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizableLaneEditPolicy.java
index 17737e4..fcad2d4 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizableLaneEditPolicy.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizableLaneEditPolicy.java
@@ -22,8 +22,12 @@ import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
@@ -38,6 +42,8 @@ import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.handles.AbstractHandle;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.handles.ResizableHandleKit;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.tools.ResizeTracker;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
@@ -47,6 +53,7 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.stp.bpmn.Activity;
import org.eclipse.stp.bpmn.Lane;
import org.eclipse.stp.bpmn.diagram.BpmnDiagramMessages;
@@ -55,6 +62,7 @@ import org.eclipse.stp.bpmn.diagram.edit.parts.ActivityEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolPoolCompartmentEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.SubProcessEditPart;
+import org.eclipse.swt.SWT;
/**
* Resize edit policy for lanes: only the bottom lane and if it is not
@@ -204,8 +212,8 @@ public class ResizableLaneEditPolicy extends ResizableShapeEditPolicyEx {
protected Command getMoveCommand(ChangeBoundsRequest request) {
ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
req.setEditParts(request.getEditParts());
- req.setMoveDelta(new Point(0,req.getMoveDelta().y));
- req.setSizeDelta(new Dimension(0,req.getSizeDelta().height));
+ req.setMoveDelta(new Point(0,request.getMoveDelta().y));
+ req.setSizeDelta(new Dimension(0,request.getSizeDelta().height));
req.setLocation(request.getLocation());
req.setExtendedData(request.getExtendedData());
req.setResizeDirection(PositionConstants.NORTH_SOUTH);
@@ -272,5 +280,51 @@ public class ResizableLaneEditPolicy extends ResizableShapeEditPolicyEx {
});
}
}
+
+ /**
+ * Only allow for creating handles on north and south of the shape.
+ */
+ @Override
+ protected List createSelectionHandles() {
+ List<Handle> list = new ArrayList<Handle>();
+ ResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(),
+ list);
+ ((MoveHandle) list.get(0)).setBorder(new LaneResizeHandleBorder());
+ GraphicalEditPart part = (GraphicalEditPart) getHost();
+ list.add(createHandle(part, PositionConstants.SOUTH));
+ list.add(createHandle(part, PositionConstants.NORTH));
+
+ return list;
+ }
+
+ /**
+ * A lean resize handle border to show it is possible to resize on south and north only.
+ * @author Antoine Toulme
+ *
+ */
+ private class LaneResizeHandleBorder extends LineBorder {
+
+ public LaneResizeHandleBorder() {
+ super(1);
+ setStyle(SWT.LINE_SOLID);
+ }
+ /**
+ * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets)
+ */
+ public void paint(IFigure figure, Graphics graphics, Insets insets) {
+ tempRect.setBounds(getPaintRectangle(figure, new Insets(1, 0, 1, 0)));
+ if (getWidth() % 2 == 1) {
+ tempRect.width--;
+ tempRect.height--;
+ }
+ tempRect.shrink(getWidth() / 2, getWidth() / 2);
+ graphics.setLineWidth(getWidth());
+ graphics.setLineStyle(getStyle());
+ if (getColor() != null)
+ graphics.setForegroundColor(getColor());
+ graphics.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight());
+ graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight());
+ }
+ }
}
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizablePoolEditPolicy.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizablePoolEditPolicy.java
index c230269..d5dbc4a 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizablePoolEditPolicy.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/ResizablePoolEditPolicy.java
@@ -34,6 +34,8 @@ import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneNameEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolPoolCompartmentEditPart;
import org.eclipse.stp.bpmn.tools.PoolResizeTracker;
@@ -194,8 +196,17 @@ public class ResizablePoolEditPolicy extends ResizableShapeEditPolicyEx {
// now take in account the shapes in the pool
Dimension maxRoomOfChildren = new Dimension(0, 0);
+ Dimension minRoomOfLanes = new Dimension(0, 0);
for (Object ep : poolCompartment.getChildren()) {
if (ep instanceof IGraphicalEditPart) {
+ if (ep instanceof LaneEditPart) {
+ IGraphicalEditPart part = (IGraphicalEditPart) ep;
+ LaneNameEditPart namePart = (LaneNameEditPart) part.getChildBySemanticHint(Integer.toString(LaneNameEditPart.VISUAL_ID));
+ if (namePart != null) {
+ minRoomOfLanes.width += namePart.getFigure().getSize().width;
+ minRoomOfLanes.height += namePart.getFigure().getSize().height +10;//+10 as 10 pixels are gobbled up by the delimitation
+ }
+ } else {
// we use the figure as width and lengths may be
// not initialized on the views objects
IFigure figure = ((IGraphicalEditPart) ep).getFigure();
@@ -204,8 +215,11 @@ public class ResizablePoolEditPolicy extends ResizableShapeEditPolicyEx {
bounds.height, maxRoomOfChildren.height);
maxRoomOfChildren.width = Math.max(bounds.x +
bounds.width, maxRoomOfChildren.width);
+ }
}
}
+ maxRoomOfChildren.width = Math.max(minRoomOfLanes.width, maxRoomOfChildren.width);
+ maxRoomOfChildren.height = Math.max(minRoomOfLanes.height, maxRoomOfChildren.height);
maxRoomOfChildren.expand(PoolPoolCompartmentEditPart.INSETS.
getWidth(), PoolPoolCompartmentEditPart.INSETS.getHeight() + 2);
@@ -216,7 +230,6 @@ public class ResizablePoolEditPolicy extends ResizableShapeEditPolicyEx {
}
}
-
return result;
}
}
diff --git a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/tools/PoolResizeTracker.java b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/tools/PoolResizeTracker.java
index 7a0d6f4..d7f3a72 100644
--- a/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/tools/PoolResizeTracker.java
+++ b/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/tools/PoolResizeTracker.java
@@ -35,6 +35,7 @@ import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.LaneEditPart;
+import org.eclipse.stp.bpmn.diagram.edit.parts.LaneNameEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolEditPart;
import org.eclipse.stp.bpmn.diagram.edit.parts.PoolPoolCompartmentEditPart;
import org.eclipse.swt.SWT;
@@ -67,13 +68,13 @@ public class PoolResizeTracker extends ActivityResizeTracker {
protected void updateSourceRequest() {
ChangeBoundsRequest request = (ChangeBoundsRequest) getSourceRequest();
Dimension dragDelta = getDragMoveDelta();
-
+
Point location = new Point(getLocation());
Point moveDelta = new Point(0, 0);
Dimension resizeDelta = new Dimension(0, 0);
int direction = getResizeDirection();
List parts = getOperationSet();
-
+
request.setConstrainedResize(false);
request.setCenteredResize(getCurrentInput().isModKeyDown(SWT.MOD1));
@@ -85,18 +86,15 @@ public class PoolResizeTracker extends ActivityResizeTracker {
// When the length of a pool is modified, all pools, are modified to
// have the same length.
//
-
+
List<PoolEditPart> siblings = collectPoolEditParts(parts);
-
- if (siblings != null
- && ((direction == PositionConstants.EAST)
- || (direction == PositionConstants.WEST)
-// || (direction == PositionConstants.NORTH_EAST)
-// || (direction == PositionConstants.NORTH_WEST)
-// || (direction == PositionConstants.SOUTH_EAST)
-// || (direction == PositionConstants.SOUTH_WEST)
- )) {
+ if (siblings != null && ((direction == PositionConstants.EAST) || (direction == PositionConstants.WEST)
+ // || (direction == PositionConstants.NORTH_EAST)
+ // || (direction == PositionConstants.NORTH_WEST)
+ // || (direction == PositionConstants.SOUTH_EAST)
+ // || (direction == PositionConstants.SOUTH_WEST)
+ )) {
for (PoolEditPart s : siblings) {
if (!parts.contains(s)) {
parts.add(s);
@@ -110,15 +108,14 @@ public class PoolResizeTracker extends ActivityResizeTracker {
Dimension figureSize = owner.getFigure().getSize();
RootEditPart rootEditPart = owner.getRoot();
if (rootEditPart instanceof ScalableFreeformRootEditPart) {
- //compute the zoom
- ScalableFreeformRootEditPart rootSc =
- (ScalableFreeformRootEditPart) rootEditPart;
+ // compute the zoom
+ ScalableFreeformRootEditPart rootSc = (ScalableFreeformRootEditPart) rootEditPart;
double zoom = rootSc.getZoomManager().getZoom();
minSize.scale(zoom);
siblingsMinSize.scale(zoom);
figureSize.scale(zoom);
- //compute the scroll.
- Point pt = ((Viewport)rootSc.getFigure()).getViewLocation();
+ // compute the scroll.
+ Point pt = ((Viewport) rootSc.getFigure()).getViewLocation();
figureSize.performTranslate(-pt.x, -pt.y);
minSize.performTranslate(-pt.x, -pt.y);
siblingsMinSize.performTranslate(-pt.x, -pt.y);
@@ -128,8 +125,7 @@ public class PoolResizeTracker extends ActivityResizeTracker {
// prevents children shapes from clipping
if (getCurrentInput().isControlKeyDown()) {
if (minSize.height > (figureSize.height - 2 * dragDelta.height)) {
- dragDelta.height =
- (figureSize.height - minSize.height) / 2;
+ dragDelta.height = (figureSize.height - minSize.height) / 2;
}
resizeDelta.height -= dragDelta.height;
} else if (minSize.height > (figureSize.height - dragDelta.height)) {
@@ -141,13 +137,12 @@ public class PoolResizeTracker extends ActivityResizeTracker {
if (((direction & PositionConstants.SOUTH) != 0) && (parts.size() < 2)) {
if (getCurrentInput().isControlKeyDown()) {
if (minSize.height > (figureSize.height + 2 * dragDelta.height)) {
- dragDelta.height =
- -(figureSize.height - minSize.height) / 2;
+ dragDelta.height = -(figureSize.height - minSize.height) / 2;
}
moveDelta.y -= dragDelta.height;
resizeDelta.height += dragDelta.height;
} else if (minSize.height > (figureSize.height + dragDelta.height)) {
- dragDelta.height = -(figureSize.height - minSize.height);
+ dragDelta.height = -(figureSize.height - minSize.height);
}
resizeDelta.height += dragDelta.height;
}
@@ -177,31 +172,28 @@ public class PoolResizeTracker extends ActivityResizeTracker {
rect.resize(resizeDelta);
PrecisionRectangle result = new PrecisionRectangle();
- snapToHelper.snapRectangle(request, request.getResizeDirection(),
- rect, result);
+ snapToHelper.snapRectangle(request, request.getResizeDirection(), rect, result);
if (request.isCenteredResize()) {
if (result.preciseX != 0.0)
result.preciseWidth += -result.preciseX;
else if (result.preciseWidth != 0.0) {
result.preciseX = -result.preciseWidth;
-// result.preciseWidth *= 2.0;
+ // result.preciseWidth *= 2.0;
}
if (result.preciseY != 0.0)
result.preciseHeight += -result.preciseY;
else if (result.preciseHeight != 0.0) {
result.preciseY = -result.preciseHeight;
-// result.preciseHeight *= 2.0;
+ // result.preciseHeight *= 2.0;
}
result.updateInts();
}
moveDelta.x = 16 - getSourceRectangle().x;
-
+
PrecisionPoint preciseMove = new PrecisionPoint(moveDelta.x, result.y + moveDelta.y);
- PrecisionDimension preciseResize = new PrecisionDimension(
- result.width + resizeDelta.width, result.height
- + resizeDelta.height);
+ PrecisionDimension preciseResize = new PrecisionDimension(result.width + resizeDelta.width, result.height + resizeDelta.height);
request.setMoveDelta(preciseMove);
request.setSizeDelta(preciseResize);
@@ -209,20 +201,21 @@ public class PoolResizeTracker extends ActivityResizeTracker {
}
/**
- * If it finds amongst the selected edit parts a pool.
- * collects all its sibling pools. Otherwise returns null
+ * If it finds amongst the selected edit parts a pool. collects all its
+ * sibling pools. Otherwise returns null
+ *
* @param selectedParts
* @return
*/
private List<PoolEditPart> collectPoolEditParts(List selectedParts) {
-
+
for (Object part : selectedParts) {
if (part instanceof PoolEditPart) {
List<PoolEditPart> res = new ArrayList<PoolEditPart>();
- PoolEditPart p = (PoolEditPart)part;
+ PoolEditPart p = (PoolEditPart) part;
for (Object child : p.getParent().getChildren()) {
if (child instanceof PoolEditPart) {
- res.add((PoolEditPart)child);
+ res.add((PoolEditPart) child);
}
}
return res;
@@ -246,45 +239,49 @@ public class PoolResizeTracker extends ActivityResizeTracker {
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof PoolEditPart) {
PoolEditPart pool = (PoolEditPart) parts.get(i);
- IGraphicalEditPart poolCompartment = pool
- .getChildBySemanticHint(Integer
- .toString(PoolPoolCompartmentEditPart.VISUAL_ID));
+ IGraphicalEditPart poolCompartment = pool.getChildBySemanticHint(Integer.toString(PoolPoolCompartmentEditPart.VISUAL_ID));
int nameWidth = poolCompartment.getFigure().getBounds().x + 1;
-
+
// now take in account the shapes in the pool
Point minChildLocation = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
Dimension maxRoomOfChildren = new Dimension(0, 0);
+ Dimension minRoomOfLanes = new Dimension(0, 0);
for (Object ep : poolCompartment.getChildren()) {
- if (ep instanceof IGraphicalEditPart && !(ep instanceof LaneEditPart)) {
- // we use the figure as width and lengths may be
- // not initialized on the views objects
- IFigure figure = ((IGraphicalEditPart) ep).getFigure();
- Rectangle bounds = figure.getBounds();
- maxRoomOfChildren.height = Math.max(bounds.y +
- bounds.height, maxRoomOfChildren.height);
- maxRoomOfChildren.width = Math.max(bounds.x +
- bounds.width, maxRoomOfChildren.width);
- minChildLocation.x = Math.min(bounds.x, minChildLocation.x);
- minChildLocation.y = Math.min(bounds.y, minChildLocation.y);
- }
+ if (ep instanceof IGraphicalEditPart) {
+ if (ep instanceof LaneEditPart) {
+ IGraphicalEditPart part = (IGraphicalEditPart) ep;
+ LaneNameEditPart namePart = (LaneNameEditPart) part.getChildBySemanticHint(Integer.toString(LaneNameEditPart.VISUAL_ID));
+ minRoomOfLanes.width += namePart.getFigure().getPreferredSize().width;
+ minRoomOfLanes.height += namePart.getFigure().getPreferredSize().height +10; //+10 as 10 pixels are gobbled up by the delimitation
+ } else {
+ // we use the figure as width and lengths may be
+ // not initialized on the views objects
+ IFigure figure = ((IGraphicalEditPart) ep).getFigure();
+ Rectangle bounds = figure.getBounds();
+ maxRoomOfChildren.height = Math.max(bounds.y + bounds.height, maxRoomOfChildren.height);
+ maxRoomOfChildren.width = Math.max(bounds.x + bounds.width, maxRoomOfChildren.width);
+ minChildLocation.x = Math.min(bounds.x, minChildLocation.x);
+ minChildLocation.y = Math.min(bounds.y, minChildLocation.y);
+ }
+ }
}
- maxRoomOfChildren.expand(PoolPoolCompartmentEditPart.INSETS.
- getWidth(), PoolPoolCompartmentEditPart.INSETS.getHeight() + 2);
+ maxRoomOfChildren.width = Math.max(minRoomOfLanes.width, maxRoomOfChildren.width);
+ maxRoomOfChildren.height = Math.max(minRoomOfLanes.height, maxRoomOfChildren.height);
+ maxRoomOfChildren.expand(PoolPoolCompartmentEditPart.INSETS.getWidth(), PoolPoolCompartmentEditPart.INSETS.getHeight() + 2);
minChildLocation.x -= PoolPoolCompartmentEditPart.INSETS.getWidth();
minChildLocation.y -= PoolPoolCompartmentEditPart.INSETS.getHeight() + 2;
if (!north) {
- result.height = Math.max(maxRoomOfChildren.height, result.height);
- result.width = Math.max(maxRoomOfChildren.width + nameWidth,
- result.width);
+ result.height = Math.max(maxRoomOfChildren.height, result.height);
+ result.width = Math.max(maxRoomOfChildren.width + nameWidth, result.width);
} else {
result.height = Math.max(poolCompartment.getFigure().getBounds().height - minChildLocation.y, result.height);
result.width = Math.max(poolCompartment.getFigure().getBounds().width - minChildLocation.x, result.width);
}
-
+
}
}
return result;
}
-
+
}
diff --git a/org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/edit/parts/LaneEditPart.java b/org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/edit/parts/LaneEditPart.java
index 8c1c3bc..eb265a1 100644
--- a/org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/edit/parts/LaneEditPart.java
+++ b/org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/edit/parts/LaneEditPart.java
@@ -13,6 +13,7 @@ package org.eclipse.stp.bpmn.diagram.edit.parts;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
@@ -45,6 +46,11 @@ public class LaneEditPart extends ShapeNodeEditPart {
public static final int VISUAL_ID = 2007;
/**
+ * The default size of the lane.
+ */
+ public static final Dimension DEFAULT_SIZE = new Dimension(50, 60);
+
+ /**
* @generated
*/
protected IFigure contentPane;