Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2009-09-17 14:22:08 -0400
committerashatalin2009-09-17 14:22:08 -0400
commit04a39408439336dad7a755afd7726e7cf1a39bee (patch)
tree6e0c91aa4040be0f47bc3a12152a5da93e207149
parent096e0a37c1902d4f5c4003dc83aca8b7af8e6b90 (diff)
downloadorg.eclipse.gmf-tooling-04a39408439336dad7a755afd7726e7cf1a39bee.tar.gz
org.eclipse.gmf-tooling-04a39408439336dad7a755afd7726e7cf1a39bee.tar.xz
org.eclipse.gmf-tooling-04a39408439336dad7a755afd7726e7cf1a39bee.zip
[289773] - Support WYSIWYG layout data editing in .gmfgraph WYSIWYG editor
- BorderLayout support was implemented. - Some code prototyping this functionality for GridLayout added.
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/AbstractFigureEditPart.java94
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/SelectStackedElementsAction.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutEditPolicy.java398
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutHelper.java145
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/FigureContainerXYLayoutEditPolicy.java2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridFigure.java132
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutEditPolicy.java280
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutHelper.java598
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/InnerFigureDragDropEditPolicy.java88
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/ResizableEditPolicy.java38
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/DiagramLabelEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse3EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java25
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureDescriptorEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label2EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label3EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/LabelEditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PointEditPart.java3
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon2EditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon3EditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolygonEditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline2EditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline3EditPart.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolylineEditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java25
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle3EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle3EditPart.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java25
-rw-r--r--plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/impl/diagram/editparts/NodeEditPart.xpt46
36 files changed, 1999 insertions, 54 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/AbstractFigureEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/AbstractFigureEditPart.java
index ec5c390a4..407770e2e 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/AbstractFigureEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/AbstractFigureEditPart.java
@@ -21,7 +21,11 @@ import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
+import org.eclipse.gef.EditPartViewer.Conditional;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.gmfgraph.Alignment;
import org.eclipse.gmf.gmfgraph.BasicFont;
import org.eclipse.gmf.gmfgraph.BorderLayout;
@@ -43,9 +47,13 @@ import org.eclipse.gmf.gmfgraph.RealFigure;
import org.eclipse.gmf.gmfgraph.StackLayout;
import org.eclipse.gmf.gmfgraph.XYLayout;
import org.eclipse.gmf.gmfgraph.XYLayoutData;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.swt.SWT;
@@ -142,9 +150,17 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
}
return null;
}
+
+ private static boolean isAppropriateLayoutEditPolicy(Layout layout, EditPolicy editPolicy) {
+ if (layout instanceof BorderLayout) {
+ return editPolicy instanceof BorderLayoutEditPolicy;
+ } else {
+ return editPolicy instanceof FigureContainerXYLayoutEditPolicy;
+ }
+ }
private FontData myCachedFontData;
-
+
private boolean myDragAllowed = true;
public AbstractFigureEditPart(View view) {
@@ -322,7 +338,7 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
protected PointList getPointList(List<Point> template) {
PointList result = new PointList();
for (Point point : template) {
- result.addPoint(new org.eclipse.draw2d.geometry.Point(getMapMode().DPtoLP(point.getX()), getMapMode().DPtoLP(point.getY())));
+ result.addPoint(new org.eclipse.draw2d.geometry.Point(getMapMode().DPtoLP(point.getX()), getMapMode().DPtoLP(point.getY())));
}
return result;
}
@@ -344,13 +360,13 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
getFigure().getParent().setConstraint(getFigure(), layoutConstraint);
}
/*
- * It is important to call handleMajorSemanticChange() here because
- * in case of any changes in LayoutConstraints current EditPart can
- * visually replace any other existing (sibling) EditParts, so we
- * have to re-layout parent Figure.
+ * It is important to call handleMajorSemanticChange() here because in
+ * case of any changes in LayoutConstraints current EditPart can
+ * visually replace any other existing (sibling) EditParts, so we have
+ * to re-layout parent Figure.
*/
if (getParent() instanceof AbstractFigureEditPart) {
- ((AbstractFigureEditPart) getParent()).handleMajorSemanticChange();
+ ((AbstractFigureEditPart) getParent()).handleMajorSemanticChange();
}
}
@@ -362,13 +378,19 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
}
protected void refreshLayoutManager() {
+ if (isActive() && !isAppropriateLayoutEditPolicy(getRealFigure().getLayout(), getEditPolicy(EditPolicy.LAYOUT_ROLE))) {
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ }
if (!hasParentFigure()) {
return;
}
handleMajorSemanticChange();
}
+
+ // Will be generated by GMF for all subclasses
+ protected abstract LayoutEditPolicy createLayoutEditPolicy();
- protected RealFigure getRealFigure() {
+ public RealFigure getRealFigure() {
View view = getNotationView();
if (view != null && view.getElement() instanceof RealFigure) {
return (RealFigure) view.getElement();
@@ -380,8 +402,8 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
* Using this custom implementation instead of calling super.setFont()
* because we have to support unsetting font operation (setFont(null)).
*
- * TODO: getNodeFigure used here instead of getPrimaryShape() - better
- * use getPrimaryShape().
+ * TODO: getNodeFigure used here instead of getPrimaryShape() - better use
+ * getPrimaryShape().
*/
protected void refreshFont() {
Font modelFont = getRealFigure().getFont();
@@ -414,17 +436,61 @@ public abstract class AbstractFigureEditPart extends ShapeNodeEditPart {
getNodeFigure().repaint();
}
}
-
+
@Override
public DragTracker getDragTracker(Request request) {
if (myDragAllowed) {
- return super.getDragTracker(request);
+ return new DragEditPartsTrackerEx(this) {
+
+ @Override
+ protected Conditional getTargetingConditional() {
+ return new TargetingConditional((ChangeBoundsRequest) getTargetRequest(), getSourceEditPart());
+ }
+
+ };
}
return null;
}
-
+
public void setDragAllowed(boolean dragAllowed) {
myDragAllowed = dragAllowed;
}
-
+
+ private static class TargetingConditional implements Conditional {
+
+ ChangeBoundsRequest myRequest;
+
+ private EditPart mySourceEditPart;
+
+ public TargetingConditional(ChangeBoundsRequest targetRequest, EditPart sourceEditpart) {
+ mySourceEditPart = sourceEditpart;
+ myRequest = new ChangeBoundsRequest(RequestConstants.REQ_CLONE);
+ myRequest.setLocation(targetRequest.getLocation().getCopy());
+ myRequest.setMoveDelta(targetRequest.getMoveDelta().getCopy());
+ myRequest.setSizeDelta(targetRequest.getSizeDelta().getCopy());
+ myRequest.setResizeDirection(targetRequest.getResizeDirection());
+ }
+
+ public boolean evaluate(EditPart editPart) {
+ myRequest.setType(getRequestType(editPart));
+ return editPart.getTargetEditPart(myRequest) != null;
+ }
+
+ private Object getRequestType(EditPart editPart) {
+ return isMove(editPart) ? RequestConstants.REQ_MOVE : RequestConstants.REQ_DROP;
+ }
+
+ private boolean isMove(EditPart editPart) {
+ EditPart part = mySourceEditPart;
+ while (part != editPart && part != null) {
+ if (part.getParent() == editPart && part.getSelected() != EditPart.SELECTED_NONE) {
+ return true;
+ }
+ part = part.getParent();
+ }
+ return false;
+ }
+
+ }
+
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/SelectStackedElementsAction.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/SelectStackedElementsAction.java
index 59893a768..1c1c9c922 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/SelectStackedElementsAction.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/parts/SelectStackedElementsAction.java
@@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
+// TODO: is it used?
public class SelectStackedElementsAction extends Action implements IMenuCreator, MenuListener, IObjectActionDelegate {
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutEditPolicy.java
new file mode 100644
index 000000000..94be311ef
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutEditPolicy.java
@@ -0,0 +1,398 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import java.util.Collections;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.gmf.gmfgraph.Alignment;
+import org.eclipse.gmf.gmfgraph.BorderLayoutData;
+import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
+import org.eclipse.gmf.gmfgraph.LayoutData;
+import org.eclipse.gmf.gmfgraph.RealFigure;
+import org.eclipse.gmf.graphdef.editor.edit.parts.AbstractFigureEditPart;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+public class BorderLayoutEditPolicy extends ConstrainedLayoutEditPolicy {
+
+ private static final Color FEEDBACK_COLOR = ColorConstants.lightBlue;
+
+ private RoundedRectangle myFeedbackFigure;
+
+ private BorderLayoutHelper myFeedbackBoundsHelper;
+
+ @Override
+ protected void showLayoutTargetFeedback(Request request) {
+ if (RequestConstants.REQ_CREATE.equals(request.getType()) || RequestConstants.REQ_MOVE.equals(request.getType())) {
+ DropRequest dropRequest = (DropRequest) request;
+ IFigure figure = getLayoutContainer();
+ Point where = dropRequest.getLocation().getCopy();
+ figure.translateToRelative(where);
+ figure.translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+
+ if (myFeedbackBoundsHelper == null) {
+ myFeedbackBoundsHelper = new BorderLayoutHelper((AbstractFigureEditPart) getHost());
+ }
+ Rectangle feedbackBounds = myFeedbackBoundsHelper.getFeedbackBounds(where);
+ figure.translateToParent(feedbackBounds);
+ figure.translateToAbsolute(feedbackBounds);
+ getFeedbackLayer().translateToRelative(feedbackBounds);
+
+ if (myFeedbackFigure == null) {
+ myFeedbackFigure = new RoundedRectangle();
+ myFeedbackFigure.setFill(false);
+ myFeedbackFigure.setOutline(true);
+ myFeedbackFigure.setForegroundColor(FEEDBACK_COLOR);
+ myFeedbackFigure.setLineWidth(2);
+ myFeedbackFigure.setAntialias(SWT.ON);
+ myFeedbackFigure.setBounds(feedbackBounds);
+ getFeedbackLayer().add(myFeedbackFigure);
+ } else {
+ myFeedbackFigure.setBounds(feedbackBounds);
+ }
+ }
+ }
+
+ @Override
+ public void eraseTargetFeedback(Request request) {
+ /**
+ * RequestConstants.REQ_DROP can be used here together with
+ * RequestConstants.REQ_MOVE due to the current
+ * DragEditPartsTrackerEx.handleDragInProgress() implementation.
+ *
+ * Currently .handleDragInProgress() calls:
+ *
+ * 1. updateTargetRequest() setting targetRequest type to
+ * getCommandName() (RequestConstants.REQ_MOVE)
+ *
+ * 2. updateTargetUnderMouse(), showTargetFeedback(),
+ * showSourceFeedback() using current target request with the type set
+ * on step 1.
+ *
+ * 3. setCurrentCommand(getCommand()); where (in addSourceCommands())
+ * request type will be set to RequestConstants.REQ_DROP
+ *
+ * So, showTargetFeedback(), showSourceFeedback() methods should be able
+ * to react on RequestConstants.REQ_MOVE. In the same time
+ * eraseTargetFeedback() should be sensitive to
+ * RequestConstants.REQ_MOVE (if it was called from
+ * updateTargetUnderMouse() then EditPart was exited) and
+ * RequestConstants.REQ_DROP (if it was called from handleButtonUp())
+ *
+ * See code for more details.
+ */
+ if (RequestConstants.REQ_CREATE.equals(request.getType()) || RequestConstants.REQ_MOVE.equals(request.getType()) || RequestConstants.REQ_DROP.equals(request.getType())) {
+ if (myFeedbackFigure != null) {
+ getFeedbackLayer().remove(myFeedbackFigure);
+ myFeedbackFigure = null;
+ }
+ myFeedbackBoundsHelper = null;
+ } else {
+ super.eraseTargetFeedback(request);
+ }
+ }
+
+ @Override
+ protected void showSizeOnDropFeedback(CreateRequest request) {
+ Point p = new Point(request.getLocation().getCopy());
+ IFigure feedback = getSizeOnDropFeedback(request);
+ feedback.translateToRelative(p);
+ Dimension size = request.getSize().getCopy();
+ feedback.translateToRelative(size);
+ feedback.setBounds(new Rectangle(p, size).expand(getCreationFeedbackOffset(request)));
+ }
+
+ @Override
+ protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) {
+ if (RequestConstants.REQ_MOVE_CHILDREN.equals(request.getType())) {
+ Point where = request.getLocation().getCopy();
+ getLayoutContainer().translateToRelative(where);
+ getLayoutContainer().translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+ Rectangle feedbackBounds = new BorderLayoutHelper((AbstractFigureEditPart) getHost()).getFeedbackBounds(where);
+ return createChangeConstraintCommand(child, constraint, feedbackBounds);
+ } else if (RequestConstants.REQ_RESIZE_CHILDREN.equals(request.getType())) {
+ return createChangeSizeCommand(child, request);
+ }
+ // should never be here
+ assert false;
+ return null;
+ }
+
+ private Command createChangeSizeCommand(EditPart childEditPart, ChangeBoundsRequest request) {
+ assert childEditPart instanceof AbstractFigureEditPart;
+ AbstractFigureEditPart childFigureEditPart = (AbstractFigureEditPart) childEditPart;
+ final RealFigure realFigure = childFigureEditPart.getRealFigure();
+ if (request.getSizeDelta() == null) {
+ return null;
+ }
+ if (false == realFigure.getLayoutData() instanceof BorderLayoutData) {
+ return null;
+ }
+ final Dimension sizeDelta = request.getSizeDelta().getCopy();
+ getLayoutContainer().translateToRelative(sizeDelta);
+ final BorderLayoutData currentLayoutData = (BorderLayoutData) realFigure.getLayoutData();
+ if (currentLayoutData.getAlignment() == Alignment.CENTER_LITERAL || currentLayoutData.isVertical() ? sizeDelta.height == 0 : sizeDelta.width == 0) {
+ return null;
+ }
+ return new ICommandProxy(new AbstractTransactionalCommand(childFigureEditPart.getEditingDomain(), "Changing preferred size", Collections.singletonList(WorkspaceSynchronizer.getFile(realFigure
+ .eResource()))) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ org.eclipse.gmf.gmfgraph.Dimension preferredSize = realFigure.getPreferredSize();
+ if (preferredSize == null) {
+ preferredSize = GMFGraphFactory.eINSTANCE.createDimension();
+ realFigure.setPreferredSize(preferredSize);
+ }
+ if (currentLayoutData.isVertical()) {
+ preferredSize.setDy(preferredSize.getDy() + sizeDelta.height);
+ } else {
+ preferredSize.setDx(preferredSize.getDx() + sizeDelta.width);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ });
+ }
+
+ @Override
+ protected Command createChangeConstraintCommand(EditPart childEditPart, Object constraint) {
+ return createChangeConstraintCommand(childEditPart, constraint, null);
+ }
+
+ // Extending default createChangeConstraintCommand method with additional
+ // (optional) parameter - feedbackBounds
+ protected Command createChangeConstraintCommand(EditPart childEditPart, Object constraint, final Rectangle feedbackBounds) {
+ assert childEditPart instanceof AbstractFigureEditPart;
+ AbstractFigureEditPart childFigureEditPart = (AbstractFigureEditPart) childEditPart;
+ assert constraint instanceof BorderLayoutData;
+ final BorderLayoutData layoutData = (BorderLayoutData) constraint;
+ if (!isValidChildLayoutData(layoutData)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ final RealFigure realFigure = (RealFigure) childFigureEditPart.getRealFigure();
+ return new ICommandProxy(new AbstractTransactionalCommand(childFigureEditPart.getEditingDomain(), "Changing Border Layout Data", Collections.singletonList(WorkspaceSynchronizer
+ .getFile(realFigure.eResource()))) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ realFigure.setLayoutData(layoutData);
+ if (layoutData.getAlignment() != Alignment.CENTER_LITERAL && feedbackBounds != null) {
+ if (realFigure.getPreferredSize() == null) {
+ realFigure.setPreferredSize(GMFGraphFactory.eINSTANCE.createDimension());
+ }
+ org.eclipse.gmf.gmfgraph.Dimension preferredSize = realFigure.getPreferredSize();
+ if (preferredSize.getDx() == 0) {
+ preferredSize.setDx(feedbackBounds.width);
+ }
+ if (preferredSize.getDy() == 0) {
+ preferredSize.setDy(feedbackBounds.height);
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ });
+ }
+
+ private boolean isValidChildLayoutData(final BorderLayoutData layoutData) {
+ for (Figure childFigure : getRealFigure().getChildren()) {
+ LayoutData childFigureLayoutData = childFigure.getLayoutData();
+ if (childFigureLayoutData instanceof BorderLayoutData) {
+ BorderLayoutData childLayoutData = (BorderLayoutData) childFigureLayoutData;
+ if (layoutData.isVertical() == childLayoutData.isVertical() && layoutData.getAlignment() == childLayoutData.getAlignment()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected Object translateToModelConstraint(Object figureConstraint) {
+ BorderLayoutData data = GMFGraphFactory.eINSTANCE.createBorderLayoutData();
+ if (org.eclipse.draw2d.BorderLayout.BOTTOM == figureConstraint) {
+ data.setVertical(true);
+ data.setAlignment(Alignment.END_LITERAL);
+ } else if (org.eclipse.draw2d.BorderLayout.TOP == figureConstraint) {
+ data.setVertical(true);
+ data.setAlignment(Alignment.BEGINNING_LITERAL);
+ } else if (org.eclipse.draw2d.BorderLayout.LEFT == figureConstraint) {
+ data.setVertical(false);
+ data.setAlignment(Alignment.BEGINNING_LITERAL);
+ } else if (org.eclipse.draw2d.BorderLayout.RIGHT == figureConstraint) {
+ data.setVertical(false);
+ data.setAlignment(Alignment.END_LITERAL);
+ } else {
+ assert org.eclipse.draw2d.BorderLayout.CENTER == figureConstraint;
+ data.setAlignment(Alignment.CENTER_LITERAL);
+ }
+ return data;
+ }
+
+ @Override
+ protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
+ // Using request (mouse) location to determine new constraints instead
+ // of modified child bounds as it was in super. implementation
+ IFigure figure = getLayoutContainer();
+ Point where = request.getLocation().getCopy();
+ figure.translateToRelative(where);
+ figure.translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+ return getConstraintFor(where);
+ }
+
+ @Override
+ protected Object getConstraintFor(Point point) {
+ return new BorderLayoutHelper((AbstractFigureEditPart) getHost()).getConstraintFor(point);
+ }
+
+ @Override
+ protected Object getConstraintFor(Rectangle rect) {
+ return getConstraintFor(rect.getTopLeft());
+ }
+
+ @Override
+ protected Command getCreateCommand(CreateRequest request) {
+ if (false == request instanceof CreateViewRequest) {
+ return null;
+ }
+
+ final CreateViewRequest createViewRequest = (CreateViewRequest) request;
+ if (createViewRequest.getViewDescriptors().size() != 1) {
+ // unable to handle several child elements creation
+ return null;
+ }
+ final ViewDescriptor viewDescriptor = createViewRequest.getViewDescriptors().iterator().next();
+
+ Object modelConstraint = translateToModelConstraint(getConstraintFor(createViewRequest));
+ assert modelConstraint instanceof BorderLayoutData;
+ final BorderLayoutData childLayoutData = (BorderLayoutData) modelConstraint;
+ if (!isValidChildLayoutData(childLayoutData)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ final Dimension requestedSize;
+ if (createViewRequest.getSize() != null) {
+ requestedSize = createViewRequest.getSize().getCopy();
+ getLayoutContainer().translateToRelative(requestedSize);
+ } else {
+ Point where = createViewRequest.getLocation().getCopy();
+ getLayoutContainer().translateToRelative(where);
+ getLayoutContainer().translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+ Rectangle feedbackBounds = new BorderLayoutHelper((AbstractFigureEditPart) getHost()).getFeedbackBounds(where);
+ requestedSize = feedbackBounds.getSize();
+ }
+
+ AbstractFigureEditPart host = (AbstractFigureEditPart) getHost();
+ return new ICommandProxy(new AbstractTransactionalCommand(host.getEditingDomain(), "Setting BorderLayoutData for child figure", Collections.singletonList(WorkspaceSynchronizer.getFile(host
+ .getRealFigure().eResource()))) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IAdaptable elementAdapter = viewDescriptor.getElementAdapter();
+ RealFigure realFigure = (RealFigure) elementAdapter.getAdapter(RealFigure.class);
+ if (realFigure == null) {
+ return CommandResult.newErrorCommandResult("Unable to locate newly created child figure");
+ }
+ realFigure.setLayoutData(childLayoutData);
+ if (childLayoutData.getAlignment() != Alignment.CENTER_LITERAL) {
+ if (realFigure.getPreferredSize() == null) {
+ realFigure.setPreferredSize(GMFGraphFactory.eINSTANCE.createDimension());
+ }
+ org.eclipse.gmf.gmfgraph.Dimension preferredSize = realFigure.getPreferredSize();
+ int requestedWidth;
+ int requestedHeight;
+ if (createViewRequest.getSize() != null) {
+ requestedWidth = requestedSize.width;
+ requestedHeight = requestedSize.height;
+ } else {
+ if (preferredSize.getDx() == 0) {
+ requestedWidth = requestedSize.width;
+ } else {
+ requestedWidth = preferredSize.getDx();
+ }
+ if (preferredSize.getDy() == 0) {
+ requestedHeight = requestedSize.height;
+ } else {
+ requestedHeight = preferredSize.getDy();
+ }
+ }
+ if (preferredSize.getDy() != requestedHeight) {
+ preferredSize.setDy(requestedHeight);
+ }
+ if (preferredSize.getDx() != requestedWidth) {
+ preferredSize.setDx(requestedWidth);
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ });
+ }
+
+ @Override
+ protected EditPolicy createChildEditPolicy(EditPart childEditPart) {
+ assert childEditPart instanceof AbstractFigureEditPart;
+ AbstractFigureEditPart childFigureEditPart = (AbstractFigureEditPart) childEditPart;
+ LayoutData layoutData = childFigureEditPart.getRealFigure().getLayoutData();
+ if (false == layoutData instanceof BorderLayoutData) {
+ return null;
+ }
+ BorderLayoutData borderLayoutData = (BorderLayoutData) layoutData;
+ ResizableEditPolicy result = new ResizableEditPolicy();
+ if (borderLayoutData.getAlignment() == Alignment.CENTER_LITERAL) {
+ result.setResizeDirections(PositionConstants.NONE);
+ } else if (borderLayoutData.getAlignment() == Alignment.BEGINNING_LITERAL) {
+ result.setResizeDirections(borderLayoutData.isVertical() ? PositionConstants.SOUTH : PositionConstants.EAST);
+ } else {
+ // borderLayoutData.getAlignment() == Alignment.END_LITERAL
+ result.setResizeDirections(borderLayoutData.isVertical() ? PositionConstants.NORTH : PositionConstants.WEST);
+ }
+ return result;
+ }
+
+ private RealFigure getRealFigure() {
+ return ((AbstractFigureEditPart) getHost()).getRealFigure();
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutHelper.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutHelper.java
new file mode 100644
index 000000000..92310dd3f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/BorderLayoutHelper.java
@@ -0,0 +1,145 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.gmfgraph.BorderLayout;
+import org.eclipse.gmf.gmfgraph.BorderLayoutData;
+import org.eclipse.gmf.graphdef.editor.edit.parts.AbstractFigureEditPart;
+
+public class BorderLayoutHelper {
+
+ private Rectangle myCenterBounds;
+
+ private Rectangle myLeftBounds;
+
+ private Rectangle myTopBounds;
+
+ private Rectangle myBottomBounds;
+
+ private Rectangle myRightBounds;
+
+ public BorderLayoutHelper(AbstractFigureEditPart host) {
+ this(host.getChildren(), host.getContentPane().getClientArea(), (BorderLayout) host.getRealFigure().getLayout());
+ }
+
+ private BorderLayoutHelper(List<AbstractFigureEditPart> childEditParts, Rectangle clientArea, BorderLayout borderLayout) {
+ // detecting figures associated with top/bottom/... layout
+ // constraints in this container
+ IFigure left = null;
+ IFigure right = null;
+ IFigure top = null;
+ IFigure bottom = null;
+ for (AbstractFigureEditPart childEditPart : childEditParts) {
+ if (childEditPart.getRealFigure().getLayoutData() instanceof BorderLayoutData && childEditPart.getFigure().isVisible()) {
+ BorderLayoutData layoutData = (BorderLayoutData) childEditPart.getRealFigure().getLayoutData();
+ switch (layoutData.getAlignment()) {
+ case BEGINNING_LITERAL:
+ if (layoutData.isVertical()) {
+ top = childEditPart.getFigure();
+ } else {
+ left = childEditPart.getFigure();
+ }
+ break;
+ case END_LITERAL:
+ if (layoutData.isVertical()) {
+ bottom = childEditPart.getFigure();
+ } else {
+ right = childEditPart.getFigure();
+ }
+ break;
+ }
+ }
+ }
+
+ // Calculating preferred size of all visible child figures
+ Rectangle area = clientArea;
+ int vGap = borderLayout.getSpacing().getDy();
+ int hGap = borderLayout.getSpacing().getDx();
+
+ myTopBounds = new Rectangle();
+ Dimension preferredSize = top != null ? top.getPreferredSize(area.width, -1) : new Dimension(0, (int) Math.min(10, 0.3 * clientArea.width));
+ myTopBounds.setLocation(area.x, area.y);
+ myTopBounds.setSize(preferredSize);
+ myTopBounds.width = area.width;
+ area.y += myTopBounds.height + vGap;
+ area.height -= myTopBounds.height + vGap;
+
+ myBottomBounds = new Rectangle();
+ preferredSize = bottom != null ? bottom.getPreferredSize(Math.max(area.width, 0), -1) : new Dimension(0, (int) Math.min(10, 0.3 * clientArea.width));
+ myBottomBounds.setSize(preferredSize);
+ myBottomBounds.width = area.width;
+ myBottomBounds.setLocation(area.x, area.y + area.height - myBottomBounds.height);
+ area.height -= preferredSize.height + vGap;
+
+ myLeftBounds = new Rectangle();
+ preferredSize = left != null ? left.getPreferredSize(-1, Math.max(0, area.height)) : new Dimension((int) Math.min(10, 0.3 * clientArea.height), 0);
+ myLeftBounds.setLocation(area.x, area.y);
+ myLeftBounds.width = preferredSize.width;
+ myLeftBounds.height = Math.max(0, area.height);
+ area.x += preferredSize.width + hGap;
+ area.width -= preferredSize.width + hGap;
+
+ myRightBounds = new Rectangle();
+ preferredSize = right != null ? right.getPreferredSize(-1, Math.max(0, area.height)) : new Dimension((int) Math.min(10, 0.3 * clientArea.height), 0);
+ ;
+ myRightBounds.width = preferredSize.width;
+ myRightBounds.height = Math.max(0, area.height);
+ myRightBounds.setLocation(area.x + area.width - myRightBounds.width, area.y);
+ area.width -= preferredSize.width + hGap;
+
+ if (area.width < 0) {
+ area.width = 0;
+ }
+ if (area.height < 0) {
+ area.height = 0;
+ }
+ myCenterBounds = area;
+ }
+
+ public Integer getConstraintFor(Point point) {
+ if (myBottomBounds.contains(point)) {
+ return org.eclipse.draw2d.BorderLayout.BOTTOM;
+ }
+ if (myTopBounds.contains(point)) {
+ return org.eclipse.draw2d.BorderLayout.TOP;
+ }
+ if (myLeftBounds.contains(point)) {
+ return org.eclipse.draw2d.BorderLayout.LEFT;
+ }
+ if (myRightBounds.contains(point)) {
+ return org.eclipse.draw2d.BorderLayout.RIGHT;
+ }
+ return org.eclipse.draw2d.BorderLayout.CENTER;
+ }
+
+ public Rectangle getFeedbackBounds(Point point) {
+ Integer constraint = getConstraintFor(point);
+ if (constraint == org.eclipse.draw2d.BorderLayout.BOTTOM) {
+ return myBottomBounds.getCopy();
+ } else if (constraint == org.eclipse.draw2d.BorderLayout.TOP) {
+ return myTopBounds.getCopy();
+ } else if (constraint == org.eclipse.draw2d.BorderLayout.LEFT) {
+ return myLeftBounds.getCopy();
+ } else if (constraint == org.eclipse.draw2d.BorderLayout.RIGHT) {
+ return myRightBounds.getCopy();
+ } else {
+ return myCenterBounds.getCopy();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/FigureContainerXYLayoutEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/FigureContainerXYLayoutEditPolicy.java
index aa868eae1..3ab7471c7 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/FigureContainerXYLayoutEditPolicy.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/FigureContainerXYLayoutEditPolicy.java
@@ -46,7 +46,7 @@ public class FigureContainerXYLayoutEditPolicy extends AbstractDomainBasedXYLayo
public FigureContainerXYLayoutEditPolicy(IMapMode mapMode) {
super(mapMode);
}
-
+
@Override
protected ICommand createSetBoundsCommand(TransactionalEditingDomain editingDomain, String label, Resource resource, Rectangle bounds, EObject element) {
if (element instanceof Figure) {
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridFigure.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridFigure.java
new file mode 100644
index 000000000..ba13ceb49
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridFigure.java
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.GridLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class GridFigure extends Shape {
+
+ private static final Rectangle INNER_FIGURE_BOUNDS = new Rectangle();
+
+ private int[] myHeights;
+
+ private int[] myWidths;
+
+ private IFigure[][] myGrid;
+
+ private Color myInnerFigureColor;
+
+ private GridLayout myGridLayout;
+
+ public GridFigure(int[] heights, int[] widths) {
+ myHeights = new int[heights.length - 1];
+ System.arraycopy(heights, 0, myHeights, 0, myHeights.length);
+ myWidths = widths;
+ }
+
+ public GridFigure(IFigure[][] grid, int[] heights, int[] widths, GridLayout gridLayout) {
+ this(heights, widths);
+ myGrid = grid;
+ myGridLayout = gridLayout;
+ }
+
+ public void setInnerFigureBoundsColor(Color color) {
+ myInnerFigureColor = color;
+ }
+
+ @Override
+ protected void fillShape(Graphics graphics) {
+ }
+
+ @Override
+ protected void outlineShape(Graphics graphics) {
+ float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f;
+ int inset1 = (int) Math.floor(lineInset);
+ int inset2 = (int) Math.ceil(lineInset);
+
+ Rectangle r = Rectangle.SINGLETON;
+ r.x = getBounds().x + inset1 + myGridLayout.marginWidth;
+ r.y = getBounds().y + inset1 + myGridLayout.marginHeight;
+ int acc = 0;
+ for (int i = 0; i < myWidths.length; i++) {
+ acc += myWidths[i] + myGridLayout.horizontalSpacing;
+ }
+ r.width = Math.min(acc, getBounds().width - inset1 - inset2);
+ acc = 0;
+ for (int i = 0; i < myHeights.length; i++) {
+ acc += myHeights[i] + myGridLayout.verticalSpacing;
+ }
+ r.height = Math.min(acc, getBounds().height - inset1 - inset2);
+
+ graphics.drawRectangle(r);
+ acc = r.y - myGridLayout.verticalSpacing/2;
+ for (int i = 0; i < myHeights.length - 1; i++) {
+ acc += myHeights[i] + myGridLayout.verticalSpacing;
+ graphics.drawLine(r.x, acc, r.right(), acc);
+ }
+ acc = r.x - myGridLayout.horizontalSpacing/2;
+ for (int i = 0; i < myWidths.length - 1; i++) {
+ acc += myWidths[i] + myGridLayout.horizontalSpacing;
+ graphics.drawLine(acc, r.y, acc, r.bottom());
+ }
+
+ for (int i = 0; i < myHeights.length; i++) {
+ for (int j = 0; j < myWidths.length; ) {
+ if (myGrid[i][j] == null || i > 0 && myGrid[i - 1][j] == myGrid[i][j]) {
+ j++;
+ continue;
+ }
+ int width = 1;
+ while (j + width < myWidths.length && myGrid[i][j] == myGrid[i][j + width]) {
+ width++;
+ }
+ int height = 1;
+ while (j + height < myHeights.length && myGrid[i][j] == myGrid[i + height][j]) {
+ height++;
+ }
+ drawInnerFigureBounds(graphics, r, i, j, width, height);
+ j += width;
+ }
+ }
+ }
+
+ private void drawInnerFigureBounds(Graphics graphics, Rectangle figureBounds, int row, int column, int width, int height) {
+ graphics.pushState();
+ if (myInnerFigureColor != null) {
+ graphics.setForegroundColor(myInnerFigureColor);
+ }
+ INNER_FIGURE_BOUNDS.x = figureBounds.x - myGridLayout.horizontalSpacing/2;
+ for (int k = 0; k < column; k++) {
+ INNER_FIGURE_BOUNDS.x += myWidths[k] + myGridLayout.horizontalSpacing;
+ }
+ INNER_FIGURE_BOUNDS.width = 0;
+ for (int k = column; k < column + width; k++) {
+ INNER_FIGURE_BOUNDS.width += myWidths[k] + myGridLayout.horizontalSpacing;
+ }
+ INNER_FIGURE_BOUNDS.y = figureBounds.y - myGridLayout.verticalSpacing/2;
+ for (int k = 0; k < row; k++) {
+ INNER_FIGURE_BOUNDS.y += myHeights[k] + myGridLayout.verticalSpacing;
+ }
+ INNER_FIGURE_BOUNDS.height = 0;
+ for (int k = row; k < row + height; k++) {
+ INNER_FIGURE_BOUNDS.height += myHeights[k] + myGridLayout.verticalSpacing;
+ }
+ graphics.drawRoundRectangle(INNER_FIGURE_BOUNDS, 10, 10);
+ graphics.popState();
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutEditPolicy.java
new file mode 100644
index 000000000..ea3f59cd8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutEditPolicy.java
@@ -0,0 +1,280 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import java.util.Collections;
+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.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.gmfgraph.RealFigure;
+import org.eclipse.gmf.graphdef.editor.edit.parts.AbstractFigureEditPart;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+public class GridLayoutEditPolicy extends ConstrainedLayoutEditPolicy {
+
+ private static final Color FEEDBACK_COLOR = ColorConstants.lightBlue;
+
+ private static final Color GRID_COLOR = ColorConstants.lightGreen;
+
+ private static final Color INNER_FIGURES_COLOR = ColorConstants.red;
+
+ private RoundedRectangle myFeedbackFigure;
+
+ private GridLayoutHelper myFeedbackBoundsHelper;
+
+ private GridFigure myGridFigure;
+
+ @Override
+ protected void showLayoutTargetFeedback(Request request) {
+ if (/* RequestConstants.REQ_CREATE.equals(request.getType()) || */RequestConstants.REQ_MOVE.equals(request.getType())) {
+// [1]
+ DropRequest dropRequest = (DropRequest) request;
+ IFigure figure = getLayoutContainer();
+ Point where = dropRequest.getLocation().getCopy();
+ figure.translateToRelative(where);
+ figure.translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+
+ if (myFeedbackBoundsHelper == null) {
+ myFeedbackBoundsHelper = new GridLayoutHelper(getAbstractFigureEditPart());
+
+ }
+ if (myGridFigure == null) {
+ myGridFigure = new GridFigure(myFeedbackBoundsHelper.getGrid(), myFeedbackBoundsHelper.getHeights(), myFeedbackBoundsHelper.getWidths(), myFeedbackBoundsHelper.getGridLayout());
+ Rectangle bounds = figure.getBounds().getCopy();
+ figure.translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ myGridFigure.setBounds(bounds);
+ myGridFigure.setForegroundColor(GRID_COLOR);
+ myGridFigure.setInnerFigureBoundsColor(INNER_FIGURES_COLOR);
+ myGridFigure.setLineWidth(2);
+ getFeedbackLayer().add(myGridFigure);
+ }
+ IFigure childFigure = null;
+ if (dropRequest instanceof GroupRequest) {
+ List editParts = ((GroupRequest) dropRequest).getEditParts();
+ assert editParts.size() == 1;
+ childFigure = ((AbstractFigureEditPart) editParts.get(0)).getFigure();
+ }
+ Rectangle feedbackBounds = myFeedbackBoundsHelper.getFeedbackBounds(where, childFigure);
+ if (feedbackBounds == null) {
+ eraseTargetFeedback(request);
+ return;
+ }
+ figure.translateToParent(feedbackBounds);
+ figure.translateToAbsolute(feedbackBounds);
+ getFeedbackLayer().translateToRelative(feedbackBounds);
+
+ if (myFeedbackFigure == null) {
+ myFeedbackFigure = new RoundedRectangle();
+ myFeedbackFigure.setFill(false);
+ myFeedbackFigure.setOutline(true);
+ myFeedbackFigure.setForegroundColor(FEEDBACK_COLOR);
+ myFeedbackFigure.setLineWidth(1);
+ myFeedbackFigure.setAntialias(SWT.ON);
+ myFeedbackFigure.setBounds(feedbackBounds);
+ getFeedbackLayer().add(myFeedbackFigure);
+ } else {
+ myFeedbackFigure.setBounds(feedbackBounds);
+ }
+
+//[2]
+// ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
+// IFigure figure = getLayoutContainer();
+// Point where = changeBoundsRequest.getLocation().getCopy();
+// figure.translateToRelative(where);
+// figure.translateFromParent(where);
+// where.translate(getLayoutOrigin().getNegated());
+//
+// if (changeBoundsRequest.getEditParts().size() != 1) {
+// // capable of moving only one child element at a time
+// return;
+// }
+//
+// final AbstractFigureEditPart childEditPart = (AbstractFigureEditPart) changeBoundsRequest.getEditParts().get(0);
+// final int newChildPosition = new GridLayoutHelper(getAbstractFigureEditPart()).getNewChildPosition(where);
+// getAbstractFigureEditPart().removeChildVisual(childEditPart);
+// getAbstractFigureEditPart().addChildVisual(childEditPart, newChildPosition);
+ }
+ }
+
+ @Override
+ public void eraseTargetFeedback(Request request) {
+ /**
+ * RequestConstants.REQ_DROP can be used here together with
+ * RequestConstants.REQ_MOVE due to the current
+ * DragEditPartsTrackerEx.handleDragInProgress() implementation.
+ *
+ * Currently .handleDragInProgress() calls:
+ *
+ * 1. updateTargetRequest() setting targetRequest type to
+ * getCommandName() (RequestConstants.REQ_MOVE)
+ *
+ * 2. updateTargetUnderMouse(), showTargetFeedback(),
+ * showSourceFeedback() using current target request with the type set
+ * on step 1.
+ *
+ * 3. setCurrentCommand(getCommand()); where (in addSourceCommands())
+ * request type will be set to RequestConstants.REQ_DROP
+ *
+ * So, showTargetFeedback(), showSourceFeedback() methods should be able
+ * to react on RequestConstants.REQ_MOVE. In the same time
+ * eraseTargetFeedback() should be sensitive to
+ * RequestConstants.REQ_MOVE (if it was called from
+ * updateTargetUnderMouse() then EditPart was exited) and
+ * RequestConstants.REQ_DROP (if it was called from handleButtonUp())
+ *
+ * See code for more details.
+ */
+ if (/* RequestConstants.REQ_CREATE.equals(request.getType()) || */RequestConstants.REQ_MOVE.equals(request.getType()) || RequestConstants.REQ_DROP.equals(request.getType())) {
+//[1]
+ if (myFeedbackFigure != null) {
+ getFeedbackLayer().remove(myFeedbackFigure);
+ myFeedbackFigure = null;
+ }
+ if (myGridFigure != null) {
+ getFeedbackLayer().remove(myGridFigure);
+ myGridFigure = null;
+ }
+ myFeedbackBoundsHelper = null;
+
+//[2]
+// getAbstractFigureEditPart().refresh();
+ } else {
+ super.eraseTargetFeedback(request);
+ }
+ }
+
+ /**
+ * With Grid layout move means reorder but not change layout constraints.
+ * Handling it in a different way.
+ */
+ @Override
+ protected Command getMoveChildrenCommand(Request request) {
+ ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
+ IFigure figure = getLayoutContainer();
+ Point where = changeBoundsRequest.getLocation().getCopy();
+ figure.translateToRelative(where);
+ figure.translateFromParent(where);
+ where.translate(getLayoutOrigin().getNegated());
+
+ if (changeBoundsRequest.getEditParts().size() != 1) {
+ // capable of moving only one child element at a time
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ final AbstractFigureEditPart childEditPart = (AbstractFigureEditPart) changeBoundsRequest.getEditParts().get(0);
+ final int newChildPosition = new GridLayoutHelper(getAbstractFigureEditPart()).getNewChildPosition(where);
+ return newChildPosition == -1 ? UnexecutableCommand.INSTANCE : new ICommandProxy(new AbstractTransactionalCommand(childEditPart.getEditingDomain(), "Moving child figure", Collections
+ .singletonList(WorkspaceSynchronizer.getFile(getRealFigure().eResource()))) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ getRealFigure().getChildren().move(newChildPosition, childEditPart.getRealFigure());
+ getAbstractFigureEditPart().getNotationView().persistChildren();
+ getAbstractFigureEditPart().getNotationView().getPersistedChildren().move(newChildPosition, childEditPart.getNotationView());
+ // getAbstractFigureEditPart().getNotationView().getChildren().remove(childEditPart.getNotationView());
+ // getAbstractFigureEditPart().getNotationView().getChildren().add(newChildPosition,
+ // childEditPart.getNotationView());
+ return CommandResult.newOKCommandResult();
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#
+ * createChangeConstraintCommand(org.eclipse.gef.EditPart, java.lang.Object)
+ */
+ @Override
+ protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getConstraintFor
+ * (org.eclipse.draw2d.geometry.Point)
+ */
+ @Override
+ protected Object getConstraintFor(Point point) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getConstraintFor
+ * (org.eclipse.draw2d.geometry.Rectangle)
+ */
+ @Override
+ protected Object getConstraintFor(Rectangle rect) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse
+ * .gef.requests.CreateRequest)
+ */
+ @Override
+ protected Command getCreateCommand(CreateRequest request) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ return new ResizableEditPolicy();
+ }
+
+ private AbstractFigureEditPart getAbstractFigureEditPart() {
+ return (AbstractFigureEditPart) getHost();
+ }
+
+ private RealFigure getRealFigure() {
+ return ((AbstractFigureEditPart) getHost()).getRealFigure();
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutHelper.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutHelper.java
new file mode 100644
index 000000000..701c1708e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/GridLayoutHelper.java
@@ -0,0 +1,598 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import java.util.List;
+
+import org.eclipse.draw2d.GridData;
+import org.eclipse.draw2d.GridLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LayoutManager;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.graphdef.editor.edit.parts.AbstractFigureEditPart;
+import org.eclipse.swt.SWT;
+
+public class GridLayoutHelper {
+
+ private GridLayout myGridLayout;
+
+ private int myColumnCount;
+
+ private int myRowCount;
+
+ private int[] myWidths;
+
+ private int[] myHeights;
+
+ private IFigure[][] myGrid;
+
+ private List<IFigure> myChildren;
+
+ public GridLayoutHelper(AbstractFigureEditPart host) {
+ IFigure contentPane = host.getContentPane();
+ LayoutManager layout = contentPane.getLayoutManager();
+ assert layout instanceof GridLayout;
+ myGridLayout = (GridLayout) layout;
+ myColumnCount = myGridLayout.numColumns;
+ myChildren = contentPane.getChildren();
+ myGrid = buildGrid(contentPane.getChildren());
+ myWidths = getColumnWidths(contentPane.getBounds().width);
+ myHeights = getRowHeights(contentPane.getBounds().height);
+
+ }
+
+ public IFigure[][] getGrid() {
+ return myGrid;
+ }
+
+ public int[] getWidths() {
+ return myWidths;
+ }
+
+ public int[] getHeights() {
+ return myHeights;
+ }
+
+ public GridLayout getGridLayout() {
+ return myGridLayout;
+ }
+
+ public int getNewChildPosition(Point where) {
+ int xIndex = getIndex(myWidths, where.x);
+ int yIndex = getIndex(myHeights, where.y);
+ if (xIndex == myWidths.length || yIndex == myHeights.length) {
+ return myChildren.size() - 1;
+ } else {
+ if (myGrid[yIndex][xIndex] == null) {
+ // do not know what to show in null cells
+ return -1;
+ }
+ return myChildren.indexOf(myGrid[yIndex][xIndex]);
+ }
+ }
+
+ public Rectangle getFeedbackBounds(Point where, IFigure childFigure) {
+ int xIndex = getIndex(myWidths, where.x);
+ int yIndex = getIndex(myHeights, where.y);
+ GridData gridData = (GridData) myGridLayout.getConstraint(childFigure);
+ if (xIndex == myWidths.length || yIndex == myHeights.length) {
+ if (myChildren.size() == 0) {
+ xIndex = 0;
+ yIndex = 0;
+ } else {
+ IFigure lastFigure = myChildren.get(myChildren.size() - 1);
+ int column = myColumnCount - 1;
+ int row = myHeights.length - 1;
+ boolean figureFound = false;
+ for (; !figureFound && row >= 0; ) {
+ column = myColumnCount - 1;
+ for (; !figureFound && column >= 0;) {
+ if (myGrid[row][column] == lastFigure) {
+ figureFound = true;
+ } else {
+ column--;
+ }
+ }
+ if (!figureFound) {
+ row--;
+ }
+ }
+ if (!figureFound) {
+ // should not be here
+ return null;
+ }
+ for (; row > 0 && myGrid[row][column] == myGrid[row - 1][column]; row--) {
+ }
+
+ int hSpan = Math.max(1, Math.min(gridData.horizontalSpan, myColumnCount));
+ while (row < myHeights.length) {
+ while (column < myColumnCount && myGrid[row][column] != null) {
+ column++;
+ }
+ int endCount = column + hSpan;
+ if (endCount <= myColumnCount) {
+ int index = column;
+ while (index < endCount && myGrid[row][index] == null) {
+ index++;
+ }
+ if (index == endCount)
+ break;
+ column = index;
+ }
+ if (column + hSpan >= myColumnCount) {
+ column = 0;
+ row++;
+ }
+ }
+ xIndex = column;
+ yIndex = row;
+ }
+ } else {
+ if (myGrid[yIndex][xIndex] == null) {
+ // do not know what to show in null cells
+ return null;
+ }
+ for (; xIndex > 0 && myGrid[yIndex][xIndex] == myGrid[yIndex][xIndex - 1]; xIndex--) {
+ }
+ for (; yIndex > 0 && myGrid[yIndex][xIndex] == myGrid[yIndex - 1][xIndex]; yIndex--) {
+ }
+ }
+
+ int xPosition = 0;
+ for (int i = 0; i < xIndex; i++) {
+ xPosition += myWidths[i];
+ }
+ int yPosition = 0;
+ for (int i = 0; i < yIndex; i++) {
+ yPosition += myHeights[i];
+ }
+ int width = myWidths[xIndex];
+ int height = myHeights[yIndex];
+ if (childFigure != null) {
+ if (xIndex + gridData.horizontalSpan > myWidths.length) {
+ width = childFigure.getBounds().width;
+ } else {
+ for (int i = xIndex + 1; i < xIndex + gridData.horizontalSpan; i++) {
+ width += myWidths[i];
+ }
+ }
+ if (yIndex + gridData.verticalAlignment > myHeights.length) {
+ height = childFigure.getBounds().height;
+ } else {
+ for (int i = yIndex + 1; i < yIndex + gridData.verticalSpan; i++) {
+ height += myHeights[i];
+ }
+ }
+ }
+
+ return new Rectangle(xPosition, yPosition, width, height);
+ }
+
+ /**
+ * @return index of current coordinate in the array of cell sizes or
+ * cellSizes.length in case we are outside of this array.
+ */
+ private int getIndex(int[] cellSizes, int coordinate) {
+ int position = 0;
+ for (int i = 0; i < cellSizes.length; i++) {
+ if (position <= coordinate && coordinate < cellSizes[i] + position) {
+ return i;
+ }
+ position += cellSizes[i];
+ }
+ return cellSizes.length;
+ }
+
+ private IFigure[][] buildGrid(List children) {
+ myRowCount = 0;
+ int row = 0, column = 0;
+ IFigure[][] grid = new IFigure[4][myColumnCount];
+ for (int i = 0; i < children.size(); i++) {
+ IFigure child = (IFigure) children.get(i);
+ GridData data = (GridData) myGridLayout.getConstraint(child);
+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, myColumnCount));
+ int vSpan = Math.max(1, data.verticalSpan);
+ while (true) {
+ int lastRow = row + vSpan;
+ if (lastRow >= grid.length) {
+ IFigure[][] newGrid = new IFigure[lastRow + 4][myColumnCount];
+ System.arraycopy(grid, 0, newGrid, 0, grid.length);
+ grid = newGrid;
+ }
+ if (grid[row] == null) {
+ grid[row] = new IFigure[myColumnCount];
+ }
+ while (column < myColumnCount && grid[row][column] != null) {
+ column++;
+ }
+ int endCount = column + hSpan;
+ if (endCount <= myColumnCount) {
+ int index = column;
+ while (index < endCount && grid[row][index] == null) {
+ index++;
+ }
+ if (index == endCount)
+ break;
+ column = index;
+ }
+ if (column + hSpan >= myColumnCount) {
+ column = 0;
+ row++;
+ }
+ }
+ for (int j = 0; j < vSpan; j++) {
+ if (grid[row + j] == null) {
+ grid[row + j] = new IFigure[myColumnCount];
+ }
+ for (int k = 0; k < hSpan; k++) {
+ grid[row + j][column + k] = child;
+ }
+ }
+ myRowCount = Math.max(myRowCount, row + vSpan);
+ column += hSpan;
+ }
+ return grid;
+ }
+
+ private int[] getColumnWidths(int width) {
+ int availableWidth = width - myGridLayout.horizontalSpacing * (myColumnCount - 1) - myGridLayout.marginWidth * 2;
+ int expandCount = 0;
+ int[] widths = new int[myColumnCount];
+ int[] minWidths = new int[myColumnCount];
+ boolean[] expandColumn = new boolean[myColumnCount];
+ for (int j = 0; j < myColumnCount; j++) {
+ for (int i = 0; i < myRowCount; i++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, true);
+ if (data != null) {
+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, myColumnCount));
+ if (hSpan == 1) {
+ int cacheWidth = getCacheWidth(myGrid, i, j, data);
+ int w = cacheWidth + data.horizontalIndent;
+ widths[j] = Math.max(widths[j], w);
+ if (data.grabExcessHorizontalSpace) {
+ if (!expandColumn[j])
+ expandCount++;
+ expandColumn[j] = true;
+ }
+ if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) {
+ minWidths[j] = Math.max(minWidths[j], w);
+ }
+ }
+ }
+ }
+ for (int i = 0; i < myRowCount; i++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, false);
+ if (data != null) {
+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, myColumnCount));
+ if (hSpan > 1) {
+ int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0;
+ for (int k = 0; k < hSpan; k++) {
+ spanWidth += widths[j - k];
+ spanMinWidth += minWidths[j - k];
+ if (expandColumn[j - k])
+ spanExpandCount++;
+ }
+ if (data.grabExcessHorizontalSpace && spanExpandCount == 0) {
+ expandCount++;
+ expandColumn[j] = true;
+ }
+ int cacheWidth = getCacheWidth(myGrid, i, j, data);
+ int w = cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * myGridLayout.horizontalSpacing;
+ if (w > 0) {
+ if (spanExpandCount == 0) {
+ widths[j] += w;
+ } else {
+ int delta = w / spanExpandCount;
+ int remainder = w % spanExpandCount, last = -1;
+ for (int k = 0; k < hSpan; k++) {
+ if (expandColumn[j - k]) {
+ widths[last = j - k] += delta;
+ }
+ }
+ if (last > -1)
+ widths[last] += remainder;
+ }
+ }
+ if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) {
+ w = cacheWidth + data.horizontalIndent - spanMinWidth - (hSpan - 1) * myGridLayout.horizontalSpacing;
+ if (w > 0) {
+ if (spanExpandCount == 0) {
+ minWidths[j] += w;
+ } else {
+ int delta = w / spanExpandCount;
+ int remainder = w % spanExpandCount, last = -1;
+ for (int k = 0; k < hSpan; k++) {
+ if (expandColumn[j - k]) {
+ minWidths[last = j - k] += delta;
+ }
+ }
+ if (last > -1)
+ minWidths[last] += remainder;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (myGridLayout.makeColumnsEqualWidth) {
+ int minColumnWidth = 0;
+ int columnWidth = 0;
+ for (int i = 0; i < myColumnCount; i++) {
+ minColumnWidth = Math.max(minColumnWidth, minWidths[i]);
+ columnWidth = Math.max(columnWidth, widths[i]);
+ }
+ columnWidth = width == SWT.DEFAULT || expandCount == 0 ? columnWidth : Math.max(minColumnWidth, availableWidth / myColumnCount);
+ for (int i = 0; i < myColumnCount; i++) {
+ expandColumn[i] = expandCount > 0;
+ widths[i] = columnWidth;
+ }
+ } else {
+ if (width != SWT.DEFAULT && expandCount > 0) {
+ int totalWidth = 0;
+ for (int i = 0; i < myColumnCount; i++) {
+ totalWidth += widths[i];
+ }
+ int count = expandCount;
+ int delta = (availableWidth - totalWidth) / count;
+ int remainder = (availableWidth - totalWidth) % count;
+ int last = -1;
+ while (totalWidth != availableWidth) {
+ for (int j = 0; j < myColumnCount; j++) {
+ if (expandColumn[j]) {
+ if (widths[j] + delta > minWidths[j]) {
+ widths[last = j] = widths[j] + delta;
+ } else {
+ widths[j] = minWidths[j];
+ expandColumn[j] = false;
+ count--;
+ }
+ }
+ }
+ if (last > -1)
+ widths[last] += remainder;
+
+ for (int j = 0; j < myColumnCount; j++) {
+ for (int i = 0; i < myRowCount; i++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, false);
+ if (data != null) {
+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, myColumnCount));
+ if (hSpan > 1) {
+ if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) {
+ int spanWidth = 0, spanExpandCount = 0;
+ for (int k = 0; k < hSpan; k++) {
+ spanWidth += widths[j - k];
+ if (expandColumn[j - k])
+ spanExpandCount++;
+ }
+ int cacheWidth = getCacheWidth(myGrid, i, j, data);
+ int w = cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * myGridLayout.horizontalSpacing;
+ if (w > 0) {
+ if (spanExpandCount == 0) {
+ widths[j] += w;
+ } else {
+ int delta2 = w / spanExpandCount;
+ int remainder2 = w % spanExpandCount, last2 = -1;
+ for (int k = 0; k < hSpan; k++) {
+ if (expandColumn[j - k]) {
+ widths[last2 = j - k] += delta2;
+ }
+ }
+ if (last2 > -1)
+ widths[last2] += remainder2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (count == 0)
+ break;
+ totalWidth = 0;
+ for (int i = 0; i < myColumnCount; i++) {
+ totalWidth += widths[i];
+ }
+ delta = (availableWidth - totalWidth) / count;
+ remainder = (availableWidth - totalWidth) % count;
+ last = -1;
+ }
+ }
+ }
+ return widths;
+ }
+
+ private int[] getRowHeights(int height) {
+ int availableHeight = height - myGridLayout.verticalSpacing * (myRowCount - 1) - myGridLayout.marginHeight * 2;
+ int expandCount = 0;
+ int[] heights = new int[myRowCount];
+ int[] minHeights = new int[myRowCount];
+ boolean[] expandRow = new boolean[myRowCount];
+ for (int i = 0; i < myRowCount; i++) {
+ for (int j = 0; j < myColumnCount; j++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, true);
+ if (data != null) {
+ int vSpan = Math.max(1, Math.min(data.verticalSpan, myRowCount));
+ if (vSpan == 1) {
+ int h = getCacheHeight(myGrid, i, j, data); // +
+ // data.verticalIndent;
+ heights[i] = Math.max(heights[i], h);
+ if (data.grabExcessVerticalSpace) {
+ if (!expandRow[i])
+ expandCount++;
+ expandRow[i] = true;
+ }
+ if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) {
+ minHeights[i] = Math.max(minHeights[i], h);
+ }
+ }
+ }
+ }
+ for (int j = 0; j < myColumnCount; j++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, false);
+ if (data != null) {
+ int vSpan = Math.max(1, Math.min(data.verticalSpan, myRowCount));
+ if (vSpan > 1) {
+ int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0;
+ for (int k = 0; k < vSpan; k++) {
+ spanHeight += heights[i - k];
+ spanMinHeight += minHeights[i - k];
+ if (expandRow[i - k])
+ spanExpandCount++;
+ }
+ if (data.grabExcessVerticalSpace && spanExpandCount == 0) {
+ expandCount++;
+ expandRow[i] = true;
+ }
+ int cacheHeight = getCacheHeight(myGrid, i, j, data);
+ int h = cacheHeight - spanHeight - (vSpan - 1) * myGridLayout.verticalSpacing; // +
+ // data.verticalalIndent
+ if (h > 0) {
+ if (spanExpandCount == 0) {
+ heights[i] += h;
+ } else {
+ int delta = h / spanExpandCount;
+ int remainder = h % spanExpandCount, last = -1;
+ for (int k = 0; k < vSpan; k++) {
+ if (expandRow[i - k]) {
+ heights[last = i - k] += delta;
+ }
+ }
+ if (last > -1)
+ heights[last] += remainder;
+ }
+ }
+ if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) {
+ h = cacheHeight - spanMinHeight - (vSpan - 1) * myGridLayout.verticalSpacing; // +
+ // data.verticalIndent
+ if (h > 0) {
+ if (spanExpandCount == 0) {
+ minHeights[i] += h;
+ } else {
+ int delta = h / spanExpandCount;
+ int remainder = h % spanExpandCount, last = -1;
+ for (int k = 0; k < vSpan; k++) {
+ if (expandRow[i - k]) {
+ minHeights[last = i - k] += delta;
+ }
+ }
+ if (last > -1)
+ minHeights[last] += remainder;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (height != SWT.DEFAULT && expandCount > 0) {
+ int totalHeight = 0;
+ for (int i = 0; i < myRowCount; i++) {
+ totalHeight += heights[i];
+ }
+ int count = expandCount;
+ int delta = (availableHeight - totalHeight) / count;
+ int remainder = (availableHeight - totalHeight) % count;
+ int last = -1;
+ while (totalHeight != availableHeight) {
+ for (int i = 0; i < myRowCount; i++) {
+ if (expandRow[i]) {
+ if (heights[i] + delta > minHeights[i]) {
+ heights[last = i] = heights[i] + delta;
+ } else {
+ heights[i] = minHeights[i];
+ expandRow[i] = false;
+ count--;
+ }
+ }
+ }
+ if (last > -1)
+ heights[last] += remainder;
+
+ for (int i = 0; i < myRowCount; i++) {
+ for (int j = 0; j < myColumnCount; j++) {
+ GridData data = getData(myGrid, i, j, myRowCount, myColumnCount, false);
+ if (data != null) {
+ int vSpan = Math.max(1, Math.min(data.verticalSpan, myRowCount));
+ if (vSpan > 1) {
+ if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) {
+ int spanHeight = 0, spanExpandCount = 0;
+ for (int k = 0; k < vSpan; k++) {
+ spanHeight += heights[i - k];
+ if (expandRow[i - k])
+ spanExpandCount++;
+ }
+ int cacheHeight = getCacheHeight(myGrid, i, j, data);
+ int h = cacheHeight - spanHeight - (vSpan - 1) * myGridLayout.verticalSpacing; // +
+ // data.verticalIndent
+ if (h > 0) {
+ if (spanExpandCount == 0) {
+ heights[i] += h;
+ } else {
+ int delta2 = h / spanExpandCount;
+ int remainder2 = h % spanExpandCount, last2 = -1;
+ for (int k = 0; k < vSpan; k++) {
+ if (expandRow[i - k]) {
+ heights[last2 = i - k] += delta2;
+ }
+ }
+ if (last2 > -1)
+ heights[last2] += remainder2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (count == 0)
+ break;
+ totalHeight = 0;
+ for (int i = 0; i < myRowCount; i++) {
+ totalHeight += heights[i];
+ }
+ delta = (availableHeight - totalHeight) / count;
+ remainder = (availableHeight - totalHeight) % count;
+ last = -1;
+ }
+ }
+ return heights;
+ }
+
+ private GridData getData(IFigure[][] grid, int row, int column, int rowCount, int columnCount, boolean first) {
+ IFigure figure = grid[row][column];
+ if (figure != null) {
+ GridData data = (GridData) myGridLayout.getConstraint(figure);
+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount));
+ int vSpan = Math.max(1, data.verticalSpan);
+ int i = first ? row + vSpan - 1 : row - vSpan + 1;
+ int j = first ? column + hSpan - 1 : column - hSpan + 1;
+ if (0 <= i && i < rowCount) {
+ if (0 <= j && j < columnCount) {
+ if (figure == grid[i][j])
+ return data;
+ }
+ }
+ }
+ return null;
+ }
+
+ private int getCacheHeight(IFigure[][] grid, int row, int column, GridData data) {
+ return grid[row][column].getPreferredSize(data.widthHint, data.heightHint).height;
+ }
+
+ private int getCacheWidth(IFigure[][] grid, int row, int column, GridData data) {
+ return grid[row][column].getPreferredSize(data.widthHint, data.heightHint).width;
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/InnerFigureDragDropEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/InnerFigureDragDropEditPolicy.java
new file mode 100644
index 000000000..bb0a657f2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/InnerFigureDragDropEditPolicy.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.swt.graphics.Color;
+
+public abstract class InnerFigureDragDropEditPolicy extends DragDropEditPolicy {
+
+ private static final Color GRAY = new Color(null, 200, 200, 200);
+
+ private Integer alpha;
+
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (getHost().getParent() != null) {
+ EditPolicy layoutEditPolicy = getHost().getParent().getEditPolicy(EditPolicy.LAYOUT_ROLE);
+ if (layoutEditPolicy instanceof BorderLayoutEditPolicy || layoutEditPolicy instanceof GridLayoutEditPolicy) {
+ if (RequestConstants.REQ_DROP.equals(request.getType()) && !isDeepInFigure((ChangeBoundsRequest) request)) {
+ // Skipping requests if the mouse is close to the figure
+ // border
+ return null;
+ }
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+
+ private boolean isDeepInFigure(ChangeBoundsRequest request) {
+ Point location = request.getLocation().getCopy();
+ getActualFigure().translateToRelative(location);
+
+ Point figureCenter = getActualFigure().getBounds().getCenter();
+ int dx = location.x - figureCenter.x;
+ dx = (int) (Math.signum(dx) * Math.min(0.3 * Math.abs(dx), 10));
+ int dy = location.y - figureCenter.y;
+ dy = (int) (Math.signum(dy) * Math.min(0.3 * Math.abs(dy), 10));
+ // Shifting request location by dr in a direction from center of figure
+ location.translate(dx, dy);
+ return getActualFigure().containsPoint(location);
+ }
+
+ @Override
+ public void showTargetFeedback(Request request) {
+ Command c = getCommand(request);
+ if (c != null && c.canExecute()) {
+ if (revertColor == null) {
+ revertColor = getActualFigure().getBackgroundColor();
+ opacity = getActualFigure().isOpaque();
+ alpha = getActualFigure().getAlpha();
+ getActualFigure().setBackgroundColor(FigureUtilities.mixColors(GRAY, revertColor));
+ getActualFigure().setOpaque(true);
+ getActualFigure().setAlpha(alpha == null ? 128 : alpha / 2);
+ }
+ }
+ }
+
+ @Override
+ public void eraseTargetFeedback(Request request) {
+ if (revertColor != null) {
+ getActualFigure().setBackgroundColor(revertColor);
+ getActualFigure().setOpaque(opacity);
+ getActualFigure().setAlpha(alpha);
+ revertColor = null;
+ }
+ }
+
+ protected abstract Shape getActualFigure();
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/ResizableEditPolicy.java b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/ResizableEditPolicy.java
new file mode 100644
index 000000000..14151dcf5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src-extra/org/eclipse/gmf/graphdef/editor/edit/policies/ResizableEditPolicy.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009 Borland Software Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.editor.edit.policies;
+
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+
+public class ResizableEditPolicy extends org.eclipse.gef.editpolicies.ResizableEditPolicy {
+
+ @Override
+ public void showSourceFeedback(Request request) {
+ if (RequestConstants.REQ_DROP.equals(request.getType())) {
+ showChangeBoundsFeedback((ChangeBoundsRequest) request);
+ } else {
+ super.showSourceFeedback(request);
+ }
+ }
+
+ @Override
+ public void eraseSourceFeedback(Request request) {
+ if (RequestConstants.REQ_DROP.equals(request.getType())) {
+ eraseChangeBoundsFeedback((ChangeBoundsRequest) request);
+ } else {
+ super.eraseSourceFeedback(request);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentEditPart.java
index 970befbb8..01c4b77d6 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/CompartmentEditPart.java
@@ -75,7 +75,6 @@ public class CompartmentEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CompartmentItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionEditPart.java
index 5170faaf7..393b6cfe3 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/ConnectionEditPart.java
@@ -75,7 +75,6 @@ public class ConnectionEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConnectionItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/DiagramLabelEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/DiagramLabelEditPart.java
index 857e98350..3ea99a390 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/DiagramLabelEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/DiagramLabelEditPart.java
@@ -75,7 +75,6 @@ public class DiagramLabelEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DiagramLabelItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
index 0b0595aa0..862c86f03 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse2EditPart.java
@@ -28,10 +28,13 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Ellipse2CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Ellipse2ItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
@@ -85,7 +88,6 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -93,6 +95,15 @@ public class Ellipse2EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse3EditPart.java
index 876e3ffba..427ee85eb 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Ellipse3EditPart.java
@@ -28,10 +28,13 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Ellipse3CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Ellipse3ItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
@@ -85,7 +88,6 @@ public class Ellipse3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -93,6 +95,15 @@ public class Ellipse3EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
index 8b3716e40..c139196a5 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/EllipseEditPart.java
@@ -28,17 +28,20 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.EllipseCanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.EllipseItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
import org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
@@ -81,12 +84,19 @@ public class EllipseEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EllipseItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new InnerFigureDragDropEditPolicy() {
+
+ /**
+ * @generated
+ */
+ protected Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new EllipseCanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -94,6 +104,15 @@ public class EllipseEditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureDescriptorEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureDescriptorEditPart.java
index 3a5379f4e..a93ac3170 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureDescriptorEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureDescriptorEditPart.java
@@ -83,7 +83,6 @@ public class FigureDescriptorEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new FigureDescriptorCanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
index 2f1b89bdd..94b555f65 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/FigureGalleryEditPart.java
@@ -71,7 +71,6 @@ public class FigureGalleryEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new FigureGalleryItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label2EditPart.java
index d8f9610e8..ef99006d4 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label2EditPart.java
@@ -29,7 +29,10 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.gmfgraph.Label;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Label2ItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.part.GMFGraphVisualIDRegistry;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
@@ -81,7 +84,6 @@ public class Label2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Label2ItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -89,6 +91,15 @@ public class Label2EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label3EditPart.java
index 41aebf03d..9668d89c7 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Label3EditPart.java
@@ -29,7 +29,10 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.gmfgraph.Label;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Label3ItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.part.GMFGraphVisualIDRegistry;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
@@ -81,7 +84,6 @@ public class Label3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Label3ItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -89,6 +91,15 @@ public class Label3EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/LabelEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/LabelEditPart.java
index 2b3dcd049..6ffe2fc7b 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/LabelEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/LabelEditPart.java
@@ -29,7 +29,10 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.gmfgraph.Label;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.LabelItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.part.GMFGraphVisualIDRegistry;
import org.eclipse.gmf.graphdef.editor.providers.GMFGraphElementTypes;
@@ -82,7 +85,6 @@ public class LabelEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new LabelItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -90,6 +92,15 @@ public class LabelEditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
index 76139d1f9..f1d857397 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/NodeEditPart.java
@@ -75,7 +75,6 @@ public class NodeEditPart extends ShapeNodeEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new NodeItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PointEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PointEditPart.java
index 02e51487b..06dc6097f 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PointEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PointEditPart.java
@@ -27,6 +27,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.PointItemSemanticEditPolicy;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
@@ -73,7 +75,6 @@ public class PointEditPart extends AbstractPointEditPart {
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PointItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon2EditPart.java
index 1ddcd6be8..41ea8c6b2 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon2EditPart.java
@@ -86,7 +86,6 @@ public class Polygon2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon3EditPart.java
index b4ec20e44..704722f14 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polygon3EditPart.java
@@ -86,7 +86,6 @@ public class Polygon3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolygonEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolygonEditPart.java
index 85bcd300f..6e7ce7232 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolygonEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolygonEditPart.java
@@ -28,6 +28,7 @@ import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.PointContainerXYLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.PolygonCanonicalEditPolicy;
@@ -37,7 +38,6 @@ import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
import org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
@@ -82,12 +82,19 @@ public class PolygonEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PolygonItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new InnerFigureDragDropEditPolicy() {
+
+ /**
+ * @generated
+ */
+ protected Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new PolygonCanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline2EditPart.java
index 35be94b79..51f9b1833 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline2EditPart.java
@@ -86,7 +86,6 @@ public class Polyline2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline3EditPart.java
index 04e735943..4ce9f7f90 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Polyline3EditPart.java
@@ -86,7 +86,6 @@ public class Polyline3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolylineEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolylineEditPart.java
index 49b2df984..e88870e95 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolylineEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/PolylineEditPart.java
@@ -28,6 +28,7 @@ import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.PointContainerXYLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.PolylineCanonicalEditPolicy;
@@ -37,7 +38,6 @@ import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
import org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
@@ -82,12 +82,19 @@ public class PolylineEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PolylineItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new InnerFigureDragDropEditPolicy() {
+
+ /**
+ * @generated
+ */
+ protected Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new PolylineCanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
index 4644228b3..4f93b2302 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle2EditPart.java
@@ -27,8 +27,12 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Rectangle2CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Rectangle2ItemSemanticEditPolicy;
@@ -37,7 +41,6 @@ import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
import org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
@@ -80,12 +83,19 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Rectangle2ItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new InnerFigureDragDropEditPolicy() {
+
+ /**
+ * @generated
+ */
+ protected Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new Rectangle2CanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -93,6 +103,15 @@ public class Rectangle2EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle3EditPart.java
index 7c4d4d1c6..29b0268d2 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/Rectangle3EditPart.java
@@ -27,8 +27,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Rectangle3CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.Rectangle3ItemSemanticEditPolicy;
@@ -84,7 +87,6 @@ public class Rectangle3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -92,6 +94,15 @@ public class Rectangle3EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
index eb39aca67..4a6088a01 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RectangleEditPart.java
@@ -27,8 +27,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RectangleCanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RectangleItemSemanticEditPolicy;
@@ -84,7 +87,6 @@ public class RectangleEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -92,6 +94,15 @@ public class RectangleEditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
index 694c7873a..bea4741e9 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle2EditPart.java
@@ -28,8 +28,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangle2CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangle2ItemSemanticEditPolicy;
@@ -85,7 +88,6 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -93,6 +95,15 @@ public class RoundedRectangle2EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle3EditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle3EditPart.java
index 9c7d209eb..6bd57f663 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle3EditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangle3EditPart.java
@@ -28,8 +28,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangle3CanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangle3ItemSemanticEditPolicy;
@@ -85,7 +88,6 @@ public class RoundedRectangle3EditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -93,6 +95,15 @@ public class RoundedRectangle3EditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
index 6cced8db7..e499bbfec 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
+++ b/plugins/org.eclipse.gmf.graphdef.editor/src/org/eclipse/gmf/graphdef/editor/edit/parts/RoundedRectangleEditPart.java
@@ -28,8 +28,12 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.ChildFigureSelectionEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy;
+import org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.KeyHandlerEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangleCanonicalEditPolicy;
import org.eclipse.gmf.graphdef.editor.edit.policies.RoundedRectangleItemSemanticEditPolicy;
@@ -38,7 +42,6 @@ import org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter;
import org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker;
import org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
@@ -81,12 +84,19 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new RoundedRectangleItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new InnerFigureDragDropEditPolicy() {
+
+ /**
+ * @generated
+ */
+ protected Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new RoundedRectangleCanonicalEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(KeyHandlerEditPolicy.KEY_HANDLER_ROLE, new ChildFigureSelectionEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
@@ -94,6 +104,15 @@ public class RoundedRectangleEditPart extends AbstractFigureEditPart {
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
+ Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case GMFGraphPackage.BORDER_LAYOUT:
+ return new BorderLayoutEditPolicy();
+ case GMFGraphPackage.GRID_LAYOUT:
+ return new GridLayoutEditPolicy();
+ }
+ }
return new FigureContainerXYLayoutEditPolicy(getMapMode());
}
diff --git a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/impl/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/impl/diagram/editparts/NodeEditPart.xpt
index f832c711f..536523b58 100644
--- a/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/impl/diagram/editparts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.editor/templates/aspects/impl/diagram/editparts/NodeEditPart.xpt
@@ -27,19 +27,57 @@
«AROUND createLayoutEditPolicyBody FOR gmfgen::GenNode-»
«IF hasSynchronizers(self)-»
- return new org.eclipse.gmf.graphdef.editor.edit.policies.«EXPAND layoutEditPolicyConstructor»;
+ «IF isPolyline(self)-»
+ return new org.eclipse.gmf.graphdef.editor.edit.policies.PointContainerXYLayoutEditPolicy(getMapMode(), «hasLayoutDataSynchronizers(self)»);
+ «ELSE-»
+ «IF not isPolylinePoint(self)-»
+ org.eclipse.gmf.gmfgraph.Layout layout = getGmfgraphElement().getLayout();
+ if (layout != null) {
+ switch (layout.eClass().getClassifierID()) {
+ case org.eclipse.gmf.gmfgraph.GMFGraphPackage.BORDER_LAYOUT:
+ return new org.eclipse.gmf.graphdef.editor.edit.policies.BorderLayoutEditPolicy();
+ case org.eclipse.gmf.gmfgraph.GMFGraphPackage.GRID_LAYOUT:
+ return new org.eclipse.gmf.graphdef.editor.edit.policies.GridLayoutEditPolicy();
+ }
+ }
+ «ENDIF-»
+ return new org.eclipse.gmf.graphdef.editor.edit.policies.FigureContainerXYLayoutEditPolicy(getMapMode());
+ «ENDIF-»
«ELSE-»
«targetDef.proceed()»
«ENDIF-»
«ENDAROUND»
«AROUND createDefaultEditPoliciesBody FOR gmfgen::GenNode-»
- «targetDef.proceed()-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::installCreationRolePolicy-»
+ super.createDefaultEditPolicies();
+ «EXPAND impl::diagram::editparts::NodeEditPart::installPrimaryDragEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «IF needsGraphicalNodeEditPolicy(self)-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new «getGraphicalNodeEditPolicyQualifiedClassName()»());
+ «ENDIF-»
+ «IF not childNodes->isEmpty()-»
+ «EXPAND installDragDropEditPolicy-»
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
«ENDAROUND»
-«DEFINE layoutEditPolicyConstructor FOR gmfgen::GenNode-»
-«IF isPolyline(self)»PointContainerXYLayoutEditPolicy«ELSE»FigureContainerXYLayoutEditPolicy«ENDIF»(getMapMode()«IF isPolyline(self)», «hasLayoutDataSynchronizers(self)»«ENDIF»)«-»
+«DEFINE installDragDropEditPolicy FOR gmfgen::GenNode-»
+ «IF hasLayoutDataSynchronizers(self)-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.graphdef.editor.edit.policies.InnerFigureDragDropEditPolicy() {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.Shape getActualFigure() {
+ return getPrimaryShape();
+ }
+ });
+ «ELSE-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
+ «ENDIF-»
«ENDDEFINE»
«AROUND createNodePlate FOR gmfgen::GenNode-»

Back to the top