Skip to content
Snippets Groups Projects
Commit 129c74a5 authored by Klaus Becker's avatar Klaus Becker
Browse files

done, but for components the ports of components should also be moved...

done, but for components the ports of components should also be moved therewith it makes sense and looks ok
refs 400
parent 7d4d808c
No related branches found
No related tags found
No related merge requests found
......@@ -17,17 +17,14 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editpart.command;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.changeAllConnectionPoints;
import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.editpart.ConnectionEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.editpart.FreeConnectorEditPartBase;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* A command to move the elements and free connectors within a diagram.
......@@ -36,7 +33,7 @@ import org.fortiss.tooling.base.ui.editpart.FreeConnectorEditPartBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 54B9F493565F91469FF3EE1CF7BBD74C
* @ConQAT.Rating YELLOW Hash: B6F68F3F16FCCB14CEA9010FAF6E9253
*/
public class MoveWithinDiagramCommand extends ChangeBoundsRequestCommandBase {
......@@ -49,7 +46,9 @@ public class MoveWithinDiagramCommand extends ChangeBoundsRequestCommandBase {
@SuppressWarnings("unchecked")
@Override
public void execute() {
bendpointGroupMove(request.getEditParts());
LayoutDataUtils.bendpointGroupMove(request.getEditParts(),
request.getMoveDelta().x, request.getMoveDelta().y);
for (EditPart editpart : (List<EditPart>) getRequest().getEditParts()) {
if (editpart instanceof ElementEditPartBase) {
ElementEditPartBase<? extends ILayoutedModelElement> elementEditPart = (ElementEditPartBase<? extends ILayoutedModelElement>) editpart;
......@@ -62,37 +61,4 @@ public class MoveWithinDiagramCommand extends ChangeBoundsRequestCommandBase {
}
}
}
/** Move bend points along with a group of selected elements */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void bendpointGroupMove(List<EditPart> parts) {
// TODO (FH): https://af3.fortiss.org/issues/376
// This has to be reworked to delegate to diagram configuration
for (EditPart part : parts) {
// cover also sticky connectors
if (part.getChildren().size() > 0) {
bendpointGroupMove(part.getChildren());
}
// filter non connective edit parts
if (!(part instanceof ConnectorEditPartBase)) {
break;
}
ConnectorEditPartBase connector = (ConnectorEditPartBase) part;
for (ConnectionEditPartBase connection : (List<ConnectionEditPartBase>) connector
.getSourceConnections()) {
// IF two states where selected, OR IF the 'connection' is a
// self-transition, THEN move also the bendpoints of the
// connections between these states.
if ((connection.getTarget().getSelected() != EditPart.SELECTED_NONE)
|| (connection.getTarget().getParent().getSelected() != EditPart.SELECTED_NONE)) {
changeAllConnectionPoints(
(ILayoutedModelElement) connection.getModel(),
request.getMoveDelta().x, request.getMoveDelta().y);
}
}
}
}
}
......@@ -25,6 +25,7 @@ import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.editpart.FreeConnectorEditPartBase;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* Base implementation of {@link IDiagramLayoutConfiguration}. It provides the
......@@ -34,7 +35,7 @@ import org.fortiss.tooling.base.ui.editpart.FreeConnectorEditPartBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3029D5370491A9EE8B79A8080CBF7CC5
* @ConQAT.Rating YELLOW Hash: 3FC45A524204AC8017B6BD0DD6C39F53
*/
public abstract class DiagramLayoutConfigurationBase implements
IDiagramLayoutConfiguration {
......@@ -64,6 +65,13 @@ public abstract class DiagramLayoutConfigurationBase implements
int minHeight = getMinimalElementSize().height;
moveAndResizeNode(editPart.getModel(), dx, dy, dw, dh, minWidth,
minHeight);
// if an element was resized, move the bendpoints of
// self-transitions/self-channels
if (dx == 0 && dy == 0) {
LayoutDataUtils.bendpointGroupResize(editPart.getModel(),
request.getEditParts(), dw, dh);
}
}
/** {@inheritDoc} */
......
......@@ -17,8 +17,11 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import java.util.List;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gef.EditPart;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.layout.LayoutKeyConstants;
import org.fortiss.tooling.base.model.layout.Angle;
......@@ -30,6 +33,9 @@ import org.fortiss.tooling.base.model.layout.Offset;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.base.model.layout.Points;
import org.fortiss.tooling.base.ui.editpart.ConnectionEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.utils.AngleUtils;
import org.fortiss.tooling.base.utils.DimensionUtils;
import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
......@@ -50,7 +56,7 @@ import org.fortiss.tooling.base.utils.PointsUtils;
* @author hummel
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: DC17063D1F5AA00AD9D32A1CB6637542
* @ConQAT.Rating YELLOW Hash: 3B5CA0DFFEFF93D1CA616DF968FB6B38
*/
public class LayoutDataUtils {
......@@ -267,13 +273,15 @@ public class LayoutDataUtils {
int dx, int dy) {
Points pts = getConnectionPoints(lobject);
Points newPoints = LayoutModelElementFactory.createPoints(null);
for (Point p : pts.getPointsList()) {
Point np = LayoutModelElementFactory.createPoint(p.getX() + dx,
p.getY() + dy, null);
newPoints.getPointsList().add(np);
if (pts != null) {
for (Point p : pts.getPointsList()) {
Point np = LayoutModelElementFactory.createPoint(p.getX() + dx,
p.getY() + dy, null);
newPoints.getPointsList().add(np);
}
PointsUtils.setPoints(lobject,
LayoutKeyConstants.CONNECTION_POINTS, newPoints);
}
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
newPoints);
}
/**
......@@ -288,4 +296,101 @@ public class LayoutDataUtils {
pts);
}
/** Move bend points along with a group of selected elements */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void bendpointGroupMove(List<EditPart> parts, int deltaX,
int deltaY) {
// TODO (FH): https://af3.fortiss.org/issues/376
// This has to be reworked to delegate to diagram configuration
for (EditPart part : parts) {
// cover also sticky connectors
if (part.getChildren().size() > 0) {
bendpointGroupMove(part.getChildren(), deltaX, deltaY);
}
// filter non connective edit parts
if (!(part instanceof ConnectorEditPartBase)) {
break;
}
ConnectorEditPartBase connector = (ConnectorEditPartBase) part;
for (ConnectionEditPartBase connection : (List<ConnectionEditPartBase>) connector
.getSourceConnections()) {
// IF two states where selected, OR IF the 'connection' is a
// self-transition, THEN move also the bendpoints of the
// connections between these states.
if ((connection.getTarget().getSelected() != EditPart.SELECTED_NONE)
|| (connection.getTarget().getParent().getSelected() != EditPart.SELECTED_NONE)) {
changeAllConnectionPoints(connection.getModel(), deltaX,
deltaY);
}
}
}
}
/** Move bend points of self-connections, if theirs parent is resized */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void bendpointGroupResize(ILayoutedModelElement layouted,
List<EditPart> parts, int deltaWidth, int deltaHeight) {
if (parts.size() == 1 && parts.get(0) instanceof ElementEditPartBase) {
ElementEditPartBase element = (ElementEditPartBase) parts.get(0);
Point partPos = PointUtils.getPosition(layouted, "pos");
Dimension partDim = DimensionUtils.getDimension(layouted, "dim");
for (ConnectorEditPartBase connector : (List<ConnectorEditPartBase>) element
.getChildren()) {
for (ConnectionEditPartBase connection : (List<ConnectionEditPartBase>) connector
.getSourceConnections()) {
// IF it is a self-transition/self-channel, THEN move also
// the bendpoints of the connections/channels.
if ((connection.getTarget().getParent().getSelected() != EditPart.SELECTED_NONE)
&& (connection.getSource().getParent()
.getSelected() != EditPart.SELECTED_NONE)) {
// get list of all bendpoints of the connections
Points points = getConnectionPoints(connection
.getModel());
for (int index = 0; index < points.getPointsLength(); index++) {
Point p = points.getPoints(index);
// left from EditPart
if (p.getX() < partPos.getX()) {
changeConnectionPoint(connection.getModel(),
index, p.getX(), p.getY() + deltaHeight
/ 2);
}
// above EditPart
else if (p.getY() < partPos.getY()) {
changeConnectionPoint(connection.getModel(),
index, p.getX() + deltaWidth / 2,
p.getY());
}
// right from EditPart
else if (p.getX() > partPos.getX()
+ partDim.getWidth() - deltaWidth) {
changeConnectionPoint(connection.getModel(),
index, p.getX() + deltaWidth, p.getY()
+ deltaHeight / 2);
}
// below EditPart
else if (p.getY() > partPos.getY()
+ partDim.getHeight() - deltaHeight) {
changeConnectionPoint(connection.getModel(),
index, p.getX() + deltaWidth / 2,
p.getY() + deltaHeight);
} else {
// nothing
}
}
}
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment