diff options
author | atischenko | 2015-09-23 18:36:23 +0000 |
---|---|---|
committer | Vincent Lorenzo | 2015-10-01 15:22:14 +0000 |
commit | be1d02c97e1faa068cdd39169295025c5cc24e06 (patch) | |
tree | d1ddf73f6e892b58853e41dd25f9317190634b17 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org | |
parent | a55703677cf48d653502b97b9870c7ff2cea49f8 (diff) | |
download | org.eclipse.papyrus-be1d02c97e1faa068cdd39169295025c5cc24e06.tar.gz org.eclipse.papyrus-be1d02c97e1faa068cdd39169295025c5cc24e06.tar.xz org.eclipse.papyrus-be1d02c97e1faa068cdd39169295025c5cc24e06.zip |
Add correction for link's labels
Change-Id: I22c45ad5ad1d29929a8f5d857835fc24fb4fc497
Signed-off-by: atischenko <tischenko@montages.com>
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org')
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java | 24 | ||||
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstantsEx.java (renamed from plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstants.java) | 5 | ||||
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/PapyrusLabelLocator.java | 28 |
3 files changed, 45 insertions, 12 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java index 276f346f8a9..4d847b271ee 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java @@ -39,6 +39,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; import org.eclipse.gmf.runtime.diagram.ui.internal.figures.ResizableLabelLocator; import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities; +import org.eclipse.gmf.runtime.notation.NamedStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.StringValueStyle; import org.eclipse.gmf.runtime.notation.View; @@ -52,7 +53,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.LabelPrimarySelecti import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.RefreshTextAlignmentEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel; import org.eclipse.papyrus.infra.gmfdiag.common.locator.IPapyrusBorderItemLocator; -import org.eclipse.papyrus.infra.gmfdiag.common.locator.LabelViewConstants; +import org.eclipse.papyrus.infra.gmfdiag.common.locator.LabelViewConstantsEx; import org.eclipse.papyrus.infra.gmfdiag.common.locator.PapyrusLabelLocator; import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; import org.eclipse.papyrus.infra.gmfdiag.common.utils.NamedStyleProperties; @@ -472,19 +473,28 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name } public Point getReferencePoint() { + NamedStyle style = getNotationView().getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), PapyrusLabelLocator.IS_UPDATED_POSITION); + Boolean updated = style == null ? false : (Boolean) style.eGet(NotationPackage.eINSTANCE.getBooleanValueStyle_BooleanValue()); + return updated ? getUpdatedRefencePoint() : getBaseReferencePoint(); + } + + public Point getBaseReferencePoint() { + return super.getReferencePoint(); + } + + public Point getUpdatedRefencePoint() { if (getParent() instanceof AbstractConnectionEditPart) { switch (getKeyPoint()) { case ConnectionLocator.TARGET: - return calculateRefPoint(LabelViewConstants.SOURCE_LOCATION); + return calculateRefPoint(LabelViewConstantsEx.SOURCE_LOCATION); case ConnectionLocator.SOURCE: - return calculateRefPoint(LabelViewConstants.TARGET_LOCATION); + return calculateRefPoint(LabelViewConstantsEx.TARGET_LOCATION); case ConnectionLocator.MIDDLE: - return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION); + return calculateRefPoint(LabelViewConstantsEx.MIDDLE_LOCATION); default: - return calculateRefPoint(LabelViewConstants.MIDDLE_LOCATION); + return calculateRefPoint(LabelViewConstantsEx.MIDDLE_LOCATION); } - } - + } return ((AbstractGraphicalEditPart)getParent()).getFigure().getBounds().getTopLeft(); } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstants.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstantsEx.java index ccd72dbe08b..fa4eff3c1f0 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstants.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/LabelViewConstantsEx.java @@ -13,12 +13,11 @@ package org.eclipse.papyrus.infra.gmfdiag.common.locator; - -public interface LabelViewConstants { +public interface LabelViewConstantsEx { public static final int SOURCE_LOCATION = 0; public static final int TARGET_LOCATION = 100; public static final int MIDDLE_LOCATION = 50; -}
\ No newline at end of file +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/PapyrusLabelLocator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/PapyrusLabelLocator.java index f28a4070811..8fa312772f9 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/PapyrusLabelLocator.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/locator/PapyrusLabelLocator.java @@ -23,7 +23,10 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants; import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities; +import org.eclipse.gmf.runtime.notation.NamedStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusLabelHelper; @@ -55,6 +58,8 @@ public class PapyrusLabelLocator extends AbstractLocator { /** The view. */ private View view; + public static final String IS_UPDATED_POSITION = "IS_UPDATED_POSITION"; + /** * Constructor to create a an instance of <code>LabelLocator</code> which locates an IFigure offset relative to a calculated reference point. * @@ -115,6 +120,19 @@ public class PapyrusLabelLocator extends AbstractLocator { } } + private int getUpdatedLocation() { + switch (getAlignment()) { + case ConnectionLocator.SOURCE: + return LabelViewConstantsEx.TARGET_LOCATION; + case ConnectionLocator.TARGET: + return LabelViewConstantsEx.SOURCE_LOCATION; + case ConnectionLocator.MIDDLE: + return LabelViewConstantsEx.MIDDLE_LOCATION; + default: + return LabelViewConstantsEx.MIDDLE_LOCATION; + } + } + /** * getter for the offset point. * @@ -147,13 +165,19 @@ public class PapyrusLabelLocator extends AbstractLocator { @Override public Point getReferencePoint() { if (parent instanceof Connection) { - PointList ptList = ((Connection) parent).getPoints(); - return PointListUtilities.calculatePointRelativeToLine(ptList, 0, getLocation(), true); + NamedStyle style = view.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), IS_UPDATED_POSITION); + Boolean updated = style == null ? false : (Boolean) style.eGet(NotationPackage.eINSTANCE.getBooleanValueStyle_BooleanValue()); + return getConnectionReferancePoint(updated); } else { return parent.getBounds().getLocation(); } } + public Point getConnectionReferancePoint(boolean updated) { + PointList ptList = ((Connection) parent).getPoints(); + return PointListUtilities.calculatePointRelativeToLine(ptList, 0, updated ? getUpdatedLocation() : getLocation(), true); + } + /** * Gets the size. * |