Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2014-10-14 07:15:39 +0000
committerMickael ADAM2014-10-14 15:50:38 +0000
commitd532bac9fd32e9f2778f01a9cf5c010003f9537b (patch)
tree458adcb497a426d27fba9f800bd1cf92172c7371 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence
parentbb7807ff7375acee6f549dab705a241c5bb2be27 (diff)
downloadorg.eclipse.papyrus-d532bac9fd32e9f2778f01a9cf5c010003f9537b.tar.gz
org.eclipse.papyrus-d532bac9fd32e9f2778f01a9cf5c010003f9537b.tar.xz
org.eclipse.papyrus-d532bac9fd32e9f2778f01a9cf5c010003f9537b.zip
445794: [All Diagram] Label Alignment/Justification is lost when the
name is edited instead of the diagram is closed -Create PapyrusLinkLabelDragPolicy -Fix the bug to fix the bug I changed xtend to permit the override of createEditPolicy for LinkLabelEditPart. Code will be generated in the next commit Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=445794 Change-Id: Ic66d9d844543f1e66318e190dd8bd91ca6190a7b Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java151
1 files changed, 85 insertions, 66 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java
index 33b40b6cd65..6cbef7657e5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java
@@ -1,66 +1,85 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * 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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This policy provides the selection handles, feedback and move command for
- * external node label.
- * The expected behavior is to provide an external label that can freely move and with a link feedback
- * towards its parent figure during the move.
- */
-public class ExternalLabelPrimaryDragRoleEditPolicy extends NonResizableLabelEditPolicy {
-
- @Override
- protected List<?> createSelectionHandles() {
- MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
- mh.setBorder(null);
- return Collections.singletonList(mh);
- }
-
- @Override
- protected Command getMoveCommand(ChangeBoundsRequest request) {
- LabelEditPart editPart = (LabelEditPart) getHost();
- // FeedBack - Port + Delta
- Rectangle updatedRect = new Rectangle();
- PrecisionRectangle initialRect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- updatedRect = initialRect.getTranslated(getHostFigure().getParent().getBounds().getLocation().getNegated());
- updatedRect = updatedRect.getTranslated(request.getMoveDelta());
- // translate the feedback figure
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- getHostFigure().translateToRelative(rect);
- ICommand moveCommand = new SetBoundsCommand(editPart.getEditingDomain(), DiagramUIMessages.MoveLabelCommand_Label_Location, new EObjectAdapter((View) editPart.getModel()), updatedRect);
- return new ICommandProxy(moveCommand);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * 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:
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+
+/**
+ * This policy provides the selection handles, feedback and move command for
+ * external node label.
+ * The expected behavior is to provide an external label that can freely move and with a link feedback
+ * towards its parent figure during the move.
+ */
+public class ExternalLabelPrimaryDragRoleEditPolicy extends NonResizableLabelEditPolicy {
+
+ @Override
+ protected List<?> createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+
+ @Override
+ protected Command getMoveCommand(ChangeBoundsRequest request) {
+ LabelEditPart editPart = (LabelEditPart) getHost();
+ // FeedBack - Port + Delta
+ Rectangle updatedRect = new Rectangle();
+ PrecisionRectangle initialRect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
+ updatedRect = initialRect.getTranslated(getHostFigure().getParent().getBounds().getLocation().getNegated());
+ updatedRect = updatedRect.getTranslated(request.getMoveDelta());
+ // translate the feedback figure
+ PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
+ getHostFigure().translateToAbsolute(rect);
+ rect.translate(request.getMoveDelta());
+ rect.resize(request.getSizeDelta());
+ getHostFigure().translateToRelative(rect);
+
+ // translate according to the text alignments
+ if (editPart instanceof PapyrusLabelEditPart) {
+ switch (((PapyrusLabelEditPart) editPart).getTextAlignment()) {
+ case PositionConstants.LEFT:
+ break;
+ case PositionConstants.CENTER:
+ updatedRect.translate(getHostFigure().getBounds().width / 2, 0);
+ break;
+ case PositionConstants.RIGHT:
+ updatedRect.translate(getHostFigure().getBounds().width, 0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ ICommand moveCommand = new SetBoundsCommand(editPart.getEditingDomain(), DiagramUIMessages.MoveLabelCommand_Label_Location, new EObjectAdapter((View) editPart.getModel()), updatedRect);
+ return new ICommandProxy(moveCommand);
+ }
+}

Back to the top