From fcba042613d85123a02972df2f19874ab1eacbab Mon Sep 17 00:00:00 2001 From: Laurent Wouters Date: Tue, 11 Mar 2014 11:26:04 +0100 Subject: Added support for CSS properties controlling the display of connectors' source and target decorations Signed-off-by: Laurent Wouters --- .../common/editpart/ConnectionEditPart.java | 73 +++++++++++++++------- 1 file changed, 50 insertions(+), 23 deletions(-) (limited to 'plugins/infra') diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java index 4b51871b97b..885f38a1683 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/ConnectionEditPart.java @@ -34,6 +34,11 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen */ protected static final String LINE_STYLE = "lineStyle"; + /** + * Supported values of the CSS property lineStyle + */ + protected static final String[] LINE_STYLE_VALUES = { "none", "hidden", "dotted", "dashed", "solid", "double" }; + /** * CSS property for the line dashes' length */ @@ -44,16 +49,33 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen */ protected static final String LINE_DASH_GAP = "lineDashGap"; + /** + * CSS property for the source decoration + */ + protected static final String SOURCE_DECORATION = "sourceDecoration"; + + /** + * CSS property for the target decoration + */ + protected static final String TARGET_DECORATION = "targetDecoration"; + + /** + * Supported values of the CSS property targetDecoration + */ + protected static final String[] DECORATION_VALUES = { "default", "none" }; + /** * Minimum length of dashes for dashed connectors */ protected static final int LINE_DASH_MIN_LENGTH = 2; /** - * Minimum length of the gapas between dashes + * Minimum length of the gaps between dashes */ protected static final int LINE_GAP_MIN_LENGTH = 2; + + public ConnectionEditPart(View view) { super(view); } @@ -69,13 +91,22 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen if(figure instanceof PapyrusEdgeFigure && model instanceof Connector) { Connector connector = (Connector)model; PapyrusEdgeFigure edge = (PapyrusEdgeFigure)figure; + // Reset the style + edge.resetStyle(); + // Re-apply the CSS-defined style if any String lineStyle = extract((StringValueStyle)connector.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), LINE_STYLE)); int lineDashLength = extract((IntValueStyle)connector.getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), LINE_DASH_LENGTH)); int lineDashGap = extract((IntValueStyle)connector.getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), LINE_DASH_GAP)); if(lineStyle != null) { setupLineStyle(edge, lineStyle, connector.getLineWidth(), lineDashLength < LINE_DASH_MIN_LENGTH ? LINE_DASH_MIN_LENGTH : lineDashLength, lineDashGap < LINE_GAP_MIN_LENGTH ? LINE_GAP_MIN_LENGTH : lineDashGap); - } else { - edge.resetStyle(); + } + String decoration = extract((StringValueStyle) connector.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), TARGET_DECORATION)); + if ("none".equals(decoration)) { + edge.setTargetDecoration(null); + } + decoration = extract((StringValueStyle) connector.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), SOURCE_DECORATION)); + if ("none".equals(decoration)) { + edge.setSourceDecoration(null); } } } @@ -123,26 +154,22 @@ public abstract class ConnectionEditPart extends ConnectionNodeEditPart implemen * Length of the gap between dashes */ private void setupLineStyle(PapyrusEdgeFigure edge, String style, int originalWidth, int lineDashLength, int lineDashGap) { - if("none".equals(style)) { - edge.resetStyle(); - } else { - if("hidden".equals(style)) { - edge.setLineStyle(Graphics.LINE_SOLID); - edge.setLineWidth(0); - edge.setVisible(false); - } else if("dotted".equals(style)) { - edge.setLineStyle(Graphics.LINE_DOT); - edge.setLineWidth(originalWidth); - } else if("dashed".equals(style)) { - edge.setLineStyle(Graphics.LINE_CUSTOM); - edge.setLineWidth(originalWidth); - edge.setLineDash(new int[]{ lineDashLength, lineDashGap }); - } else if("solid".equals(style)) { - edge.setLineStyle(Graphics.LINE_SOLID); - edge.setLineWidth(originalWidth); - } else if("double".equals(style)) { - edge.setLineWidth(originalWidth * 2); - } + if ("hidden".equals(style)) { + edge.setLineStyle(Graphics.LINE_SOLID); + edge.setLineWidth(0); + edge.setVisible(false); + } else if ("dotted".equals(style)) { + edge.setLineStyle(Graphics.LINE_DOT); + edge.setLineWidth(originalWidth); + } else if ("dashed".equals(style)) { + edge.setLineStyle(Graphics.LINE_CUSTOM); + edge.setLineWidth(originalWidth); + edge.setLineDash(new int[] { lineDashLength, lineDashGap }); + } else if ("solid".equals(style)) { + edge.setLineStyle(Graphics.LINE_SOLID); + edge.setLineWidth(originalWidth); + } else if ("double".equals(style)) { + edge.setLineWidth(originalWidth * 2); } } -- cgit v1.2.3 From 67c1c74a2e7135df29a40d589b4e715ced905a90 Mon Sep 17 00:00:00 2001 From: Ansgar Radermacher Date: Tue, 11 Mar 2014 13:23:27 +0100 Subject: [Bug 429744] [UML 2.5] Migrate Papyrus to UML 2.5 - Adaptation of MTL files (due to standard profile) --- .../org/eclipse/papyrus/cpp/codegen/StdStereo.java | 4 +- .../cpp/codegen/acceleo/CppClassHeader.emtl | 503 +++++----- .../papyrus/cpp/codegen/acceleo/CppClassHeader.mtl | 2 +- .../acceleo/util/operation/CppOperations.emtl | 1034 ++++++++++---------- .../acceleo/util/operation/CppOperations.mtl | 6 +- .../build.acceleo | 2 +- .../build.acceleo | 2 +- .../build.acceleo | 2 +- .../editors/ui/DirectEditorsContributionItem.java | 14 +- .../TransitionEditorConfigurationContribution.java | 2 +- .../xtext/integration/CompletionProposalUtils.java | 1 + 11 files changed, 789 insertions(+), 783 deletions(-) (limited to 'plugins/infra') diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/StdStereo.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/StdStereo.java index e70c7807870..8012b324027 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/StdStereo.java +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/StdStereo.java @@ -24,10 +24,12 @@ public class StdStereo { /** * In the UML 2.4 plugin, the Standard profile is split into an L2 and an L3 profile + * (in earlier and later plugins, this is not the case) */ public final static String[] namespaces = { "Standard", //$NON-NLS-1$ - "StandardProfileL2" //$NON-NLS-1$ + "StandardProfileL2", //$NON-NLS-1$ + "StandardProfile" //$NON-NLS-1$ }; /** diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.emtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.emtl index 565251db4c4..a82c773b1e5 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.emtl +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.emtl @@ -133,8 +133,8 @@ - - + + @@ -1012,6 +1012,9 @@ + + + @@ -1261,52 +1264,52 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1315,18 +1318,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1335,58 +1338,58 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1395,23 +1398,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1420,18 +1423,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1440,23 +1443,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1465,8 +1468,8 @@
-
-
+
+
@@ -1476,12 +1479,12 @@
-
+
-
+
@@ -1496,7 +1499,7 @@
-
+
@@ -1506,7 +1509,7 @@
-
+
@@ -1515,8 +1518,8 @@
-
-
+
+
@@ -1535,18 +1538,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1555,13 +1558,13 @@
-
-
+
+
-
-
+
+
@@ -1570,33 +1573,33 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1605,13 +1608,13 @@
-
-
+
+
-
-
+
+
@@ -1620,13 +1623,13 @@
-
-
+
+
-
-
+
+
@@ -1635,13 +1638,13 @@
-
-
+
+
-
-
+
+
@@ -1650,13 +1653,13 @@
-
-
+
+
-
-
+
+
@@ -1665,13 +1668,13 @@
-
-
+
+
-
-
+
+
@@ -1680,8 +1683,8 @@
-
-
+
+
@@ -1690,23 +1693,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1715,13 +1718,13 @@
-
-
+
+
-
-
+
+
@@ -1730,8 +1733,8 @@
-
-
+
+
@@ -1740,23 +1743,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1765,23 +1768,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1790,28 +1793,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1820,28 +1823,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1850,28 +1853,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1880,28 +1883,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1910,28 +1913,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1940,18 +1943,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1960,18 +1963,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1980,28 +1983,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2010,18 +2013,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2030,13 +2033,13 @@
-
-
+
+
-
-
+
+
@@ -2045,18 +2048,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2065,28 +2068,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl index ca2bc069355..3442e8a1110 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/CppClassHeader.mtl @@ -51,7 +51,7 @@ Bug 422373: The default initializer should not be generated if there are any use property values should be set in the constructors that are generated by CppClassOperationsDeclaration. /] -[if getOwnedOperations()->any(hasStereotype(l2::Create)) = null] +[if getOwnedOperations()->any(hasStereotype(standard::Create)) = null] [let attributeList : Set(Property) = attribute->select( (isStatic = false) and (defaultValue <> null) and diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.emtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.emtl index 1066c347464..12ada4e50f1 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.emtl +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.emtl @@ -1,6 +1,6 @@ - + @@ -17,7 +17,7 @@ - + @@ -673,7 +673,7 @@ - + @@ -1902,48 +1902,48 @@ -
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1952,38 +1952,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1992,38 +1992,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2032,163 +2032,163 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2197,13 +2197,13 @@
-
-
+
+
-
-
+
+
@@ -2212,28 +2212,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2242,38 +2242,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2282,58 +2282,58 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2342,18 +2342,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2362,13 +2362,13 @@
-
-
+
+
-
-
+
+
@@ -2377,18 +2377,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2412,18 +2412,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2432,13 +2432,13 @@
-
-
+
+
-
-
+
+
@@ -2462,13 +2462,13 @@
-
-
+
+
-
-
+
+
@@ -2492,38 +2492,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2532,23 +2532,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2557,23 +2557,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2582,13 +2582,13 @@
-
-
+
+
-
-
+
+
@@ -2597,13 +2597,13 @@
-
-
+
+
-
-
+
+
@@ -2612,33 +2612,33 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2647,33 +2647,33 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2682,18 +2682,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2702,13 +2702,13 @@
-
-
+
+
-
-
+
+
@@ -2717,8 +2717,8 @@
-
-
+
+
@@ -2727,8 +2727,8 @@
-
-
+
+
@@ -2737,8 +2737,8 @@
-
-
+
+
@@ -2747,8 +2747,8 @@
-
-
+
+
@@ -2757,23 +2757,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2782,18 +2782,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2802,8 +2802,8 @@
-
-
+
+
@@ -2812,23 +2812,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2837,13 +2837,13 @@
-
-
+
+
-
-
+
+
@@ -2852,8 +2852,8 @@
-
-
+
+
@@ -2862,23 +2862,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2887,18 +2887,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2907,43 +2907,43 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2952,23 +2952,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -2977,13 +2977,13 @@
-
-
+
+
-
-
+
+
@@ -2992,33 +2992,33 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3027,43 +3027,43 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3072,8 +3072,8 @@
-
-
+
+
@@ -3082,53 +3082,53 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3137,18 +3137,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3157,23 +3157,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3182,18 +3182,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3202,43 +3202,43 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3247,8 +3247,8 @@
-
-
+
+
@@ -3257,8 +3257,8 @@
-
-
+
+
@@ -3267,23 +3267,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3297,8 +3297,8 @@
-
-
+
+
@@ -3307,13 +3307,13 @@
-
-
+
+
-
-
+
+
@@ -3322,23 +3322,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3347,18 +3347,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3367,8 +3367,8 @@
-
-
+
+
@@ -3377,8 +3377,8 @@
-
-
+
+
@@ -3387,13 +3387,13 @@
-
-
+
+
-
-
+
+
@@ -3402,28 +3402,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3432,13 +3432,13 @@
-
-
+
+
-
-
+
+
@@ -3447,43 +3447,43 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3492,18 +3492,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
@@ -3512,13 +3512,13 @@
-
-
+
+
-
-
+
+
@@ -3527,18 +3527,18 @@
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl index 543654aaea3..4394b939c8a 100644 --- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl +++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperations.mtl @@ -36,7 +36,7 @@ return a list of owned operations, since this is not supported directly on a cla [query public isConsOrDestructor(operation : Operation) : Boolean = -hasStereotype(l2::Create) or hasStereotype(l2::Destroy) +hasStereotype(standard::Create) or hasStereotype(standard::Destroy) /] [query public ConsDestructorOrVoid(operation : Operation) : String = @@ -48,7 +48,7 @@ endif/] [query public destructor(operation : Operation) : String = -if hasStereotype(l2::Destroy) and not operation.name.startsWith('~') then +if hasStereotype(standard::Destroy) and not operation.name.startsWith('~') then '~' else '' @@ -84,7 +84,7 @@ endif/] [/template] [template public CppConstInit(operation : Operation)] -[if (hasStereotype(ConstInit) and hasStereotype(l2::Create))] : [getApplication(ConstInit).oclAsType(ConstInit).initialisation/][/if] +[if (hasStereotype(ConstInit) and hasStereotype(standard::Create))] : [getApplication(ConstInit).oclAsType(ConstInit).initialisation/][/if] [/template] diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/build.acceleo b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/build.acceleo index ae5d907111e..47e207d7f7a 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/build.acceleo +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/build.acceleo @@ -18,7 +18,7 @@ diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/build.acceleo b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/build.acceleo index 5065c7657c5..33b00e54fd1 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/build.acceleo +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/build.acceleo @@ -18,7 +18,7 @@ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo index c17ba204b24..29a2c80ecb9 100644 --- a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo @@ -18,7 +18,7 @@ diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java index bc57fa0ca1a..93d889f796d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java @@ -41,7 +41,7 @@ public class DirectEditorsContributionItem extends ContributionItem implements I * */ public DirectEditorsContributionItem() { - setId("org.eclipse.papyrus.editors.menuitem"); + setId("org.eclipse.papyrus.editors.menuitem"); //$NON-NLS-1$ } /** @@ -86,7 +86,7 @@ public class DirectEditorsContributionItem extends ContributionItem implements I return; } - // get the uml object type of this element, using the business resolver + // get the UML object type of this element, using the business resolver final Object businessObject = EMFHelper.getEObject(selectedElement); // no object found: exit @@ -111,9 +111,10 @@ public class DirectEditorsContributionItem extends ContributionItem implements I protected void createSubMenu(Menu menu, int index, Object businessObject, Collection configurations) { // create direct item, and then create sub-items subMenuItem = new MenuItem(menu, SWT.CASCADE); - String type = ((businessObject instanceof EObject) ? ((EObject)businessObject).eClass().getName() : ""); + String type = ((businessObject instanceof EObject) ? + ((EObject)businessObject).eClass().getName() : ""); //$NON-NLS-1$ - subMenuItem.setText("Edit " + type); + subMenuItem.setText("Edit " + type); //$NON-NLS-1$ // submenu Menu subMenu = new Menu(menu); @@ -127,11 +128,10 @@ public class DirectEditorsContributionItem extends ContributionItem implements I for(final DirectEditorExtensionPoint configuration : configurations) { MenuItem item = new MenuItem(subMenu, SWT.NONE); StringBuffer buffer = new StringBuffer(); - buffer.append("Using "); + buffer.append("Using "); //$NON-NLS-1$ buffer.append(configuration.getLanguage()); - buffer.append(" Editor"); if(configuration.equals(defaultConfig)) { - buffer.append(" (Default via F2)"); + buffer.append(" (Default via F2)"); //$NON-NLS-1$ } item.setText(buffer.toString()); item.addSelectionListener(new SelectionListener() { diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.transition.xtext.ui/src/org/eclipse/papyrus/uml/textedit/transition/xtext/ui/contributions/TransitionEditorConfigurationContribution.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.transition.xtext.ui/src/org/eclipse/papyrus/uml/textedit/transition/xtext/ui/contributions/TransitionEditorConfigurationContribution.java index 9c5d08258fa..a93cac1795f 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.transition.xtext.ui/src/org/eclipse/papyrus/uml/textedit/transition/xtext/ui/contributions/TransitionEditorConfigurationContribution.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.transition.xtext.ui/src/org/eclipse/papyrus/uml/textedit/transition/xtext/ui/contributions/TransitionEditorConfigurationContribution.java @@ -82,7 +82,7 @@ public class TransitionEditorConfigurationContribution extends DefaultXtextDirec */ @Override public int getStyle() { - return SWT.MULTI; + return SWT.MULTI | SWT.WRAP; } /* diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/CompletionProposalUtils.java b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/CompletionProposalUtils.java index a701f5c3e31..2c7678d5f2c 100644 --- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/CompletionProposalUtils.java +++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/CompletionProposalUtils.java @@ -28,6 +28,7 @@ import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; /** * @author CEA LIST - Initial contribution and API */ +@SuppressWarnings("nls") public class CompletionProposalUtils { protected final static ILabelProvider labelProvider = DisplayUtils.getLabelProvider() ; -- cgit v1.2.3 From 0975d26d2f725ac7bb1563504cf10210161b74f5 Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Tue, 11 Mar 2014 14:45:25 +0100 Subject: merge file plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/DropTargetListener.java --- .../common/commands/DeferredSnapToGridCommand.java | 247 +++++++++++++++++++++ .../infra/gmfdiag/common/snap/NodeSnapHelper.java | 6 +- .../policy/CommonDiagramDragDropEditPolicy.java | 12 + .../internalblock/utils/BlockDropHelper.java | 17 ++ .../common/listeners/DropTargetListener.java | 6 + 5 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DeferredSnapToGridCommand.java (limited to 'plugins/infra') diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DeferredSnapToGridCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DeferredSnapToGridCommand.java new file mode 100644 index 00000000000..ad47a39aad6 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DeferredSnapToGridCommand.java @@ -0,0 +1,247 @@ +/***************************************************************************** + * Copyright (c) 2011 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: + * + * CEALIST - Initial API and implementation (Adapted code from DeferredLayoutCommand) + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.commands; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.PrecisionRectangle; +import org.eclipse.emf.transaction.RunnableWithResult; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.gef.SnapToHelper; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.snap.BorderNodeSnapHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.snap.NodeSnapHelper; + +/** + * This command is used to snap editparts on the grid, when only the view + * adapters are available at the time of creating the command. It is necessary + * to have the editparts when creating a snap command so this command defers + * the creation of the layout command until execution time at which point it can + * get the editparts from the editpart registry using the view adapters. + * + * @author vlorenzo + */ +//TODO : creation from the palette should use me +//TODO : move action could use me??? +public class DeferredSnapToGridCommand extends AbstractTransactionalCommand { + + /** the IAdaptables from which an View can be retrieved */ + protected List viewAdapters; + + /** the diagram editpart used to get the editpart registry */ + protected IGraphicalEditPart containerEP; + + /** + * Constructor for DefferedSnapToGridCommand. + * + * @param editingDomain + * the editing domain through which model changes are made + * @param viewAdapters + * the IAdaptables from which an IView can be retrieved + * @param containerEP + * the container editpart used to get the editpart registry + */ + public DeferredSnapToGridCommand(TransactionalEditingDomain editingDomain, List viewAdapters, IGraphicalEditPart containerEP) { + super(editingDomain, "Deferred Snap to grid command", null); //$NON-NLS-1$ + this.viewAdapters = viewAdapters; + this.containerEP = containerEP; + } + + /** + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#getAffectedFiles() + * + * @return + */ + @SuppressWarnings("rawtypes") + public List getAffectedFiles() { + if(containerEP != null) { + View view = (View)containerEP.getModel(); + if(view != null) { + IFile f = WorkspaceSynchronizer.getFile(view.eResource()); + return f != null ? Collections.singletonList(f) : Collections.EMPTY_LIST; + } + } + return super.getAffectedFiles(); + } + + /** + * Executes a layout command with all the editparts for the view adapters. + * + */ + protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + + final RunnableWithResult> refreshRunnable = new RunnableWithResult>() { + + private IStatus status; + + private List result; + + public List getResult() { + return result; + } + + public void setStatus(IStatus status) { + this.status = status; + } + + public IStatus getStatus() { + return status; + } + + public void run() { + containerEP.refresh(); + + // The layout command requires that the figure world is updated. + getContainerFigure().invalidate(); + getContainerFigure().validate(); + + List editParts = new ArrayList(viewAdapters.size()); + Map epRegistry = containerEP.getRoot().getViewer().getEditPartRegistry(); + for(Iterator iter = viewAdapters.iterator(); iter.hasNext();) { + IAdaptable ad = (IAdaptable)iter.next(); + View view = (View)ad.getAdapter(View.class); + Object ep = epRegistry.get(view); + if(ep instanceof IGraphicalEditPart) { + editParts.add((IGraphicalEditPart)ep); + } + } + + if(editParts.isEmpty()) { + result = editParts; + return; + } + + //probably useless + // Set layoutSet = new HashSet(editParts.size()); + // layoutSet.addAll(editParts); + // + // // refresh source and target connections of any shapes in the container not being considered for layout + // Iterator iter = containerEP.getChildren().iterator(); + // while(iter.hasNext()) { + // Object obj = iter.next(); + // if(!layoutSet.contains(obj) && obj instanceof IGraphicalEditPart) { + // IGraphicalEditPart ep = (IGraphicalEditPart)obj; + // ep.refresh(); + // } + // } + + result = editParts; + } + }; + + EditPartUtil.synchronizeRunnableToMainThread(containerEP, refreshRunnable); + List editParts = refreshRunnable.getResult(); + if(editParts == null || editParts.isEmpty()) { + return CommandResult.newOKCommandResult(); + } + + // add an arrange command, to layout the related shapes + CompoundCommand cc = new CompoundCommand("Snap Command"); //$NON-NLS-1$ + for(final IGraphicalEditPart current : editParts) { + final SnapToHelper snapHelper = (SnapToHelper)((IAdaptable)current).getAdapter(SnapToHelper.class); + final NodeSnapHelper nodeSnapHelper; + final PrecisionRectangle boundsFigure = new PrecisionRectangle(((GraphicalEditPart)current).getFigure().getBounds()); + current.getFigure().translateToAbsolute(boundsFigure); + final PrecisionRectangle result = new PrecisionRectangle(boundsFigure); + if(current instanceof BorderedBorderItemEditPart) { + nodeSnapHelper = new BorderNodeSnapHelper(snapHelper, boundsFigure); + } else { + nodeSnapHelper = new NodeSnapHelper(snapHelper, boundsFigure); + } + ChangeBoundsRequest request = new ChangeBoundsRequest("move"); //$NON-NLS-1$ + request.setEditParts(Collections.singletonList(current)); + request.setSnapToEnabled(true); + request.setLocation(boundsFigure.getLocation()); + nodeSnapHelper.snapPoint(request); + request.setLocation(result.getLocation()); + cc.add(((GraphicalEditPart)current).getCommand(request)); + } + + + if(!cc.isEmpty() && cc.canExecute()) { + cc.execute(); + } + return CommandResult.newOKCommandResult(); + } + + /** + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#cleanup() + * + */ + protected void cleanup() { + containerEP = null;//for garbage collection + viewAdapters = null; + super.cleanup(); + } + + /** + * gets the container edit part's figure + * + * @return the container figure + */ + protected IFigure getContainerFigure() { + return containerEP.getFigure(); + } + + /** + * gets the container edit part + * + * @return the container edit part + */ + protected IGraphicalEditPart getContainerEP() { + return containerEP; + } + + /** + * gets a list of IAdaptable that can adapt to + * View + * + * @return view adapters + */ + protected List getViewAdapters() { + return viewAdapters; + } + + /** + * + * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute() + * + * @return + */ + @Override + public boolean canExecute() { + return super.canExecute() && containerEP != null; + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/snap/NodeSnapHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/snap/NodeSnapHelper.java index 329b6229324..25bfe373d68 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/snap/NodeSnapHelper.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/snap/NodeSnapHelper.java @@ -330,9 +330,9 @@ public class NodeSnapHelper { final Point ref = baseRectTopLeft.getTopLeft(); distVSPoints.put(distance(ref, topLeftCornerDelta), topLeftCornerDelta); - distVSPoints.put(distance(ref, topRightCornerDelta), topRightCornerDelta); - distVSPoints.put(distance(ref, bottomLeftCornerDelta), bottomLeftCornerDelta); - distVSPoints.put(distance(ref, bottomRightCornerDelta), bottomRightCornerDelta); + // distVSPoints.put(distance(ref, topRightCornerDelta), topRightCornerDelta); + // distVSPoints.put(distance(ref, bottomLeftCornerDelta), bottomLeftCornerDelta); + // distVSPoints.put(distance(ref, bottomRightCornerDelta), bottomRightCornerDelta); } return distVSPoints; } diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java index 2b0ddf98a55..1733997dcd0 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java @@ -56,6 +56,8 @@ import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.commands.wrappers.CommandProxyWithResult; import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry; +import org.eclipse.papyrus.infra.gmfdiag.common.commands.DeferredSnapToGridCommand; +import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; import org.eclipse.papyrus.infra.gmfdiag.common.utils.ViewDescriptorUtil; import org.eclipse.papyrus.uml.diagram.common.commands.CommonDeferredCreateConnectionViewCommand; import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter; @@ -161,6 +163,16 @@ public abstract class CommonDiagramDragDropEditPolicy extends DiagramDragDropEdi Command dropCommand = new ICommandProxy(gmfDropCommand); completeDropCommand.add(dropCommand.chain(refreshCommand)); completeDropCommand.add(arrangeCommand); + + //add snap command if required + //430099: [Diagram] Snap to Grid for elements dropped from the ModelExplorer is ignored + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=430099 + final Object value = dropRequest.getExtendedData().get(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT); + if(value instanceof Boolean && Boolean.TRUE.equals(value)) { + DeferredSnapToGridCommand snapCommand = new DeferredSnapToGridCommand(getEditingDomain(), newValues, (IGraphicalEditPart)getHost()); + completeDropCommand.add(new ICommandProxy(snapCommand)); + } + } return completeDropCommand; diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/utils/BlockDropHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/utils/BlockDropHelper.java index 25b35621f7b..e662f87e867 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/utils/BlockDropHelper.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/utils/BlockDropHelper.java @@ -13,6 +13,8 @@ *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.internalblock.utils; +import java.util.Collections; + import org.eclipse.core.runtime.IAdaptable; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; @@ -32,6 +34,8 @@ import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.commands.DeferredSnapToGridCommand; +import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; import org.eclipse.papyrus.infra.gmfdiag.common.utils.ViewDescriptorUtil; import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureCommandFactory; import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; @@ -114,6 +118,12 @@ public class BlockDropHelper extends ElementHelper { cc.add(new ICommandProxy(createElementCommand)); cc.add(viewCreateCommand); + final Object value = request.getExtendedData().get(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT); + if(value instanceof Boolean && Boolean.TRUE.equals(value)) { + DeferredSnapToGridCommand snapCommand = new DeferredSnapToGridCommand(getEditingDomain(), Collections.singletonList(descriptor), host); + cc.add(new ICommandProxy(snapCommand)); + } + return cc; } @@ -159,10 +169,17 @@ public class BlockDropHelper extends ElementHelper { createViewRequest.setLocation(request.getLocation().getCopy()); Command viewCreateCommand = host.getCommand(createViewRequest); + // 3. Create the compound command cc.add(new ICommandProxy(createElementCommand)); cc.add(viewCreateCommand); + final Object value = request.getExtendedData().get(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT); + if(value instanceof Boolean && Boolean.TRUE.equals(value)) { + DeferredSnapToGridCommand snapCommand = new DeferredSnapToGridCommand(getEditingDomain(), Collections.singletonList(descriptor), host); + cc.add(new ICommandProxy(snapCommand)); + } + return cc; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/DropTargetListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/DropTargetListener.java index eea5043e77d..e10ff7cea22 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/DropTargetListener.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/DropTargetListener.java @@ -24,7 +24,9 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.Request; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramDropTargetListener; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; import org.eclipse.papyrus.infra.services.localizer.IObjectLocalizer; import org.eclipse.papyrus.infra.services.localizer.util.LocalizerUtil; import org.eclipse.swt.dnd.Transfer; @@ -49,6 +51,10 @@ public abstract class DropTargetListener extends DiagramDropTargetListener { Request r = super.createTargetRequest(); if(r != null && r.getExtendedData() != null) { r.getExtendedData().put(EVENT_DETAIL, getCurrentEvent().detail); + //430099: [Diagram] Snap to Grid for elements dropped from the ModelExplorer is ignored + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=430099 + boolean isSnapping = ((DiagramGraphicalViewer)getViewer()).getWorkspaceViewerPreferenceStore().getBoolean(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT); + r.getExtendedData().put(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, isSnapping); } return r; } -- cgit v1.2.3 From e677d8492683aeb279606c035a2c79cc148099e1 Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Tue, 11 Mar 2014 16:13:39 +0100 Subject: 430115: [Table2] Paste/Import must be possible when the number of columns is not the same in the table and in the clipboard/file https://bugs.eclipse.org/bugs/show_bug.cgi?id=430115 --- .../manager/AbstractPasteImportInNattableManager.java | 14 ++++++++++++-- .../eclipse/papyrus/infra/nattable/messages/Messages.java | 2 ++ .../papyrus/infra/nattable/messages/messages.properties | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'plugins/infra') diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java index 13bfe2307be..c1f689580fd 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java @@ -239,6 +239,7 @@ public abstract class AbstractPasteImportInNattableManager { * a status indicating if the first line of the file allows to do the paste */ private IStatus verifyColumnCountOnFirstLine(final INattableModelManager tableManager, final Reader reader) { + final int axisCount = tableManager.getColumnCount(); CSVParser parser = this.pasteHelper.createParser(reader); //we verify the nb of columns final RowIterator rowIter = parser.parse(); @@ -250,12 +251,21 @@ public abstract class AbstractPasteImportInNattableManager { nbCell++; } } - final int axisCount = tableManager.getColumnCount(); + //430115: [Table2] Paste/Import must be possible when the number of columns is not the same in the table and in the clipboard/file + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=430115 + if(axisCount == 0) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_TheTableDoesntHaveColumns); + } + //commented because the next line could have data + // if(nbCell == 0) { + // return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Your data doesn't have cell on the first row"); + // } if(axisCount == nbCell) { return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_NumberOfColumnsAreEquals); } else { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.AbstractPasteImportInNattableManager_NumberOfColumnsAreNotEquals, nbCell, axisCount)); + return new Status(IStatus.OK, Activator.PLUGIN_ID, NLS.bind(Messages.AbstractPasteImportInNattableManager_NumberOfColumnsAreNotEquals, nbCell, axisCount)); } + } diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java index 2ee63196322..eec308428a3 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java @@ -59,6 +59,8 @@ public class Messages extends NLS { public static String AbstractPasteImportInNattableManager_TheTableCantCreateElement; + public static String AbstractPasteImportInNattableManager_TheTableDoesntHaveColumns; + public static String AbstractPasteImportInNattableManager_TheTableHasAConfigurationToPaste; public static String AbstractPasteImportInNattableManager_TheUserChosesToPasteColumns; diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties index 4c646b3cda0..31a35e4fdb6 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties @@ -16,6 +16,7 @@ AbstractPasteImportInNattableManager_TheContextOfTheTableHasNotTheContainmentFea AbstractPasteImportInNattableManager_TheContextOfTheTableHasTheContainmentFeatureDefinedForThePaste=The context of the table has the containment feature defined for the paste AbstractPasteImportInNattableManager_TheTableCanCreateElement=The table can create {0} as {1} AbstractPasteImportInNattableManager_TheTableCantCreateElement=The table can't create {0} as {1} +AbstractPasteImportInNattableManager_TheTableDoesntHaveColumns=The table doesn't have columns AbstractPasteImportInNattableManager_TheTableHasAConfigurationToPaste=The table has a configuration to paste {0}. AbstractPasteImportInNattableManager_TheUserChosesToPasteColumns=The user has chosen to paste columns. AbstractPasteImportInNattableManager_TheUserChosesToPasteRows=The user has chosen to paste rows. -- cgit v1.2.3