Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2015-11-09 17:05:07 +0000
committerGerrit Code Review @ Eclipse.org2016-01-28 12:30:11 +0000
commit712d97566d99446546055c44e8fe6806d99478dd (patch)
tree5b417a19e3b869c5abcb2d7788460dbe4fa7c8f8
parent23fae62909798c7159511510bc139f1d5ecb0b0d (diff)
downloadorg.eclipse.papyrus-712d97566d99446546055c44e8fe6806d99478dd.tar.gz
org.eclipse.papyrus-712d97566d99446546055c44e8fe6806d99478dd.tar.xz
org.eclipse.papyrus-712d97566d99446546055c44e8fe6806d99478dd.zip
Bug 419357: [Diagram][Palette] Diagram must provide a way to restore
existing links https://bugs.eclipse.org/bugs/show_bug.cgi?id=419357 Creation of a EditPolicyProvider on "org.eclipse.papyrus.uml.diagram.common" to modify the "DefaultSemanticEditPolicy" used by many EditPart Change-Id: I1d3a329841509e1d297b4695019e0455a528a4f5 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java1042
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/Messages.java197
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages.properties73
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/pages/PapyrusAllDiagramsPreferencePage.java290
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RestoreElementGroup.java75
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java122
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/AssociationUtils.java101
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/dialogs/CreateOrShowExistingLinkDialog.java746
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomDefaultSemanticEditPolicy.java44
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java584
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/CustomEditPolicyProvider.java59
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/AssociationUtil.java94
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java151
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java129
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF111
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java9
19 files changed, 2100 insertions, 1741 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
index df97306756a..d4728ccebe9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
@@ -1,516 +1,526 @@
-/*****************************************************************************
- * Copyright (c) 2013 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:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.preferences;
-
-import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties;
-
-
-
-/**
- * <p>
- * A class that defines the available preference type available through Papyrus.
- * </p>
- * <p>
- * It defines the following type:
- * </p>
- * <ul>
- * <li>COLOR_FILL</li>
- * <li>FONT</li>
- * <li>COLOR_FONT</li>
- * <li>COLOR_LINE</li>
- * <li>COLOR_GRADIENT</li>
- * <li>GRADIENT_POLICY</li>
- * <li>JUMPLINK_STATUS</li>
- * <li>JUMPLINK_REVERSE</li>
- * <li>JUMPLINK_TYPE</li>
- * <li>ROUTING_POLICY_DISTANCE</li>
- * <li>ROUTING_POLICY_OBSTRUCTION</li>
- * <li>ROUTING_STYLE</li>
- * <li>SMOOTHNESS</li>
- * </ul>
- * <p>
- * It also helps to retrieve the string used to store the preference type for a given element.
- * </p>
- *
- */
-@SuppressWarnings("restriction")
-public class PreferencesConstantsHelper {
-
- /**
- * Prefix for preference for Papyrus Level editor
- */
- public final static String PAPYRUS_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_EDITOR"; //$NON-NLS-1$
-
- /**
- * Prefix for preference for Diagram Level
- */
- public final static String DIAGRAM_PREFERENCE_PREFIX = "DIAGRAM_"; //$NON-NLS-1$
-
- /**
- * Prefix for preference for element Level
- */
- public final static String DIAGRAM_ELEMENT = "ELEMENT_"; //$NON-NLS-1$
-
- private final static String COLOR = "color."; //$NON-NLS-1$
-
- private final static String GRADIENT = "gradient"; //$NON-NLS-1$
-
- private final static String POLICY = ".policy"; //$NON-NLS-1$
-
- private final static String JUMPLINK = "jumplink."; //$NON-NLS-1$
-
- private final static String ROUTING = "routing"; //$NON-NLS-1$
-
- private final static String ROUTING_POLICY = ROUTING + POLICY;
-
- private final static String COLOR_FILL_CONSTANT = COLOR + "fill"; //$NON-NLS-1$
-
- private final static String FONT_CONSTANT = "font"; //$NON-NLS-1$
-
- private final static String COLOR_FONT_CONSTANT = COLOR + FONT_CONSTANT;
-
- private final static String COLOR_LINE_CONSTANT = COLOR + "line"; //$NON-NLS-1$
-
- private final static String COLOR_GRADIENT_CONSTANT = COLOR + GRADIENT;
-
- private final static String GRADIENT_POLICY_CONSTANT = GRADIENT + POLICY;
-
- private final static String JUMPLINK_STATUS_CONSTANT = JUMPLINK + "status"; //$NON-NLS-1$
-
- private final static String JUMPLINK_REVERSE_CONSTANT = JUMPLINK + "reverse"; //$NON-NLS-1$
-
- private final static String JUMPLINK_TYPE_CONSTANT = JUMPLINK + "type"; //$NON-NLS-1$
-
- private final static String ROUTING_POLICY_DISTANCE_CONSTANT = ROUTING_POLICY + ".distance"; //$NON-NLS-1$
-
- private final static String ROUTING_POLICY_OBSTRUCTION_CONSTANT = ROUTING_POLICY + ".obstruction"; //$NON-NLS-1$
-
- private final static String ROUTING_STYLE_CONSTANT = ROUTING + ".style"; //$NON-NLS-1$
-
- private final static String SMOOTHNESS_CONSTANT = "smoothness"; //$NON-NLS-1$
-
- private final static String SHADOW_CONSTANT = "shadow"; //$NON-NLS-1$
-
- private final static String ELEMENTICON_CONSTANT = "elementicon"; //$NON-NLS-1$
-
- private final static String QUALIFIEDNAME_CONSTANT = "qualifiedname"; //$NON-NLS-1$
-
- private final static String HEIGHT_CONSTANT = "height";//$NON-NLS-1$
-
- private final static String WIDTH_CONSTANT = "width"; //$NON-NLS-1$
-
- private final static String COMPARTMENT_VISIBILITY_CONSTANT = "compartment.visibility"; //$NON-NLS-1$
-
- private final static String COMPARTMENT_NAME_VISIBILITY_CONSTANT = "compartment_name.visibility"; //$NON-NLS-1$
-
- private final static String LABEL_VISIBILITY_CONSTANT = "label.visibility"; //$NON-NLS-1$
-
- private final static String LOCATION_X_CONSTANT = "location_x";//$NON-NLS-1$
-
- private final static String LOCATION_Y_CONSTANT = "location_y"; //$NON-NLS-1$
-
- public final static String VIEW_RULERS_CONSTANT = WorkspaceViewerProperties.VIEWRULERS;
-
- public final static String VIEW_GRID_CONSTANT = WorkspaceViewerProperties.VIEWGRID;
-
- public final static String RULER_UNITS_CONSTANT = WorkspaceViewerProperties.RULERUNIT;
-
- public final static String SNAP_TO_GRID_CONSTANT = WorkspaceViewerProperties.SNAPTOGRID;
-
- public final static String SNAP_TO_GEOMETRY_CONSTANT = WorkspaceViewerProperties.SNAPTOGEOMETRY;
-
- public final static String GRID_LINE_COLOR_CONSTANT = WorkspaceViewerProperties.GRIDLINECOLOR;
-
- public final static String GRID_SPACING_CONSTANT = WorkspaceViewerProperties.GRIDSPACING;
-
- public final static String GRID_ORDER_CONSTANT = WorkspaceViewerProperties.GRIDORDER;
-
- public final static String GRID_LINE_STYLE_CONSTANT = WorkspaceViewerProperties.GRIDLINESTYLE;
-
- public final static String VIEW_PAGE_BREAK_CONSTANT = WorkspaceViewerProperties.VIEWPAGEBREAKS;
-
- public final static String DRAW_CONNECTION_POINT_CONSTANT = "drawConnectionPoint"; //$NON-NLS-1$
-
- public final static String INVERT_BINDING_FOR_DEFAULT_RESIZE_AND_CONSTRAINED_RESIZE_CONSTANT = "invertBindingForDefaultResizeAndConstrainedResize"; //$NON-NLS-1$
-
-
- /**
- * A preference of type COLOR FILL
- */
- public final static int COLOR_FILL = 0;
-
- /**
- * A preference of type FONT
- */
- public final static int FONT = COLOR_FILL + 1;
-
- /**
- * A preference of type COLOR FONT
- */
- public final static int COLOR_FONT = FONT + 1;
-
- /**
- * A preference of type COLOR LINE
- */
- public final static int COLOR_LINE = COLOR_FONT + 1;
-
- /**
- * A preference of type COLOR GRADIENT
- */
- public final static int COLOR_GRADIENT = COLOR_LINE + 1;
-
- /**
- * A preference of type GRADIENT POLICY
- */
- public final static int GRADIENT_POLICY = COLOR_GRADIENT + 1;
-
- /**
- * A preference of type JUMPLINK STATUS
- */
- public final static int JUMPLINK_STATUS = GRADIENT_POLICY + 1;
-
- /**
- * A preference of type JUMPLINK REVERSE
- */
- public final static int JUMPLINK_REVERSE = JUMPLINK_STATUS + 1;
-
- /**
- * A preference of type JUMPLINK TYPE
- */
- public final static int JUMPLINK_TYPE = JUMPLINK_REVERSE + 1;
-
- /**
- * A preference of type ROUTING POLICY DISTANCE
- */
- public final static int ROUTING_POLICY_DISTANCE = JUMPLINK_TYPE + 1;
-
- /**
- * A preference of type ROUTING POLICY OBSTRUCTION
- */
- public final static int ROUTING_POLICY_OBSTRUCTION = ROUTING_POLICY_DISTANCE + 1;
-
- /**
- * A preference of type ROUTING STYLE
- */
- public final static int ROUTING_STYLE = ROUTING_POLICY_OBSTRUCTION + 1;
-
- /**
- * A preference of type SMOOTHNESS
- */
- public final static int SMOOTHNESS = ROUTING_STYLE + 1;
-
- /**
- * A preference of type Shadow
- */
- public final static int SHADOW = SMOOTHNESS + 1;
-
- /**
- * A preference of type elementIcon
- */
- public final static int ELEMENTICON = SHADOW + 1;
-
- /**
- * A preference of type QualifiedName
- */
- public final static int QUALIFIEDNAME = ELEMENTICON + 1;
-
- /**
- * A preference of type height
- */
- public static final int HEIGHT = QUALIFIEDNAME + 1;
-
- /**
- * A preference of type width
- */
- public static final int WIDTH = HEIGHT + 1;
-
- /**
- * A preference of type compartment visibility
- */
- public static final int COMPARTMENT_VISIBILITY = WIDTH + 1;
-
- /**
- * A preference of type compartment visibility
- */
- public static final int COMPARTMENT_NAME_VISIBILITY = COMPARTMENT_VISIBILITY + 1;
-
- /**
- * A preference of type label visibility
- */
- public static final int LABEL_VISIBILITY = COMPARTMENT_NAME_VISIBILITY + 1;
-
- /**
- * A preference for label default location
- */
- public static final int LOCATION_X = LABEL_VISIBILITY + 1;
-
- /**
- * A preference for label default location
- */
- public static final int LOCATION_Y = LOCATION_X + 1;
-
- /**
- * A preference to diplay or not the rulers
- */
- public static final int VIEW_RULER = LOCATION_Y + 1;
-
- /**
- * A preference to diplay or not the grid
- */
-
- public static final int VIEW_GRID = VIEW_RULER + 1;
-
- /**
- * A preference to change the ruler unit
- */
-
- public static final int RULER_UNITS = VIEW_GRID + 1;
-
- /**
- * A preference to snap the created element to the grid
- */
- public static final int SNAP_TO_GRID = RULER_UNITS + 1;
-
- /**
- * A preference to snap the created element to the shape
- */
- public static final int SNAP_TO_GEOMETRY = SNAP_TO_GRID + 1;
-
- /**
- * A preference to change the grid color
- */
- public static final int GRID_LINE_COLOR = SNAP_TO_GEOMETRY + 1;
-
- /**
- * A preference to change the grid spacing
- */
- public static final int GRID_SPACING = GRID_LINE_COLOR + 1;
-
- /**
- * A preference to change the Z order of the Grid
- */
- public static final int GRID_ORDER = GRID_SPACING + 1;
-
- /**
- * A preference to change the style of the grid
- */
- public static final int GRID_LINE_STYLE = GRID_ORDER + 1;
-
- /**
- * A preference to view the page break on the diagram
- */
- public static final int VIEW_PAGE_BREAK = GRID_LINE_STYLE + 1;
-
- /**
- * A preference to draw big point when 2 links have a common part
- */
- public static final int DRAW_CONNECTION_POINT = VIEW_PAGE_BREAK + 1;
-
- /**
- * A Papyrus preference to define the if the default resize action is constrained or not.
- * if the preference is <code>false</code>
- * <ul>
- * <li>default resize is not constraint</li>
- * <li>resize + SHIFT is constrained</li>
- * </ul>
- */
- public static final int INVERT_BINDING_FOR_DEFAULT_RESIZE_AND_CONSTRAINED_RESIZE = DRAW_CONNECTION_POINT + 1;
-
- /**
- * Get the preference constant used to store the preference of an element.
- *
- * @param elementName
- * the name of the element
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return the constant used.
- */
- public static String getConstant(String elementName, int preferenceType) {
- StringBuffer sb = new StringBuffer();
- sb.append(elementName);
- sb.append("."); //$NON-NLS-1$
-
- switch (preferenceType) {
- case COLOR_FILL:
- sb.append(COLOR_FILL_CONSTANT);
- break;
- case FONT:
- sb.append(FONT_CONSTANT);
- break;
- case COLOR_FONT:
- sb.append(COLOR_FONT_CONSTANT);
- break;
- case COLOR_LINE:
- sb.append(COLOR_LINE_CONSTANT);
- break;
- case COLOR_GRADIENT:
- sb.append(COLOR_GRADIENT_CONSTANT);
- break;
- case GRADIENT_POLICY:
- sb.append(GRADIENT_POLICY_CONSTANT);
- break;
- case JUMPLINK_STATUS:
- sb.append(JUMPLINK_STATUS_CONSTANT);
- break;
- case JUMPLINK_REVERSE:
- sb.append(JUMPLINK_REVERSE_CONSTANT);
- break;
- case JUMPLINK_TYPE:
- sb.append(JUMPLINK_TYPE_CONSTANT);
- break;
- case ROUTING_POLICY_DISTANCE:
- sb.append(ROUTING_POLICY_DISTANCE_CONSTANT);
- break;
- case ROUTING_POLICY_OBSTRUCTION:
- sb.append(ROUTING_POLICY_OBSTRUCTION_CONSTANT);
- break;
- case ROUTING_STYLE:
- sb.append(ROUTING_STYLE_CONSTANT);
- break;
- case SMOOTHNESS:
- sb.append(SMOOTHNESS_CONSTANT);
- break;
- case SHADOW:
- sb.append(SHADOW_CONSTANT);
- break;
- case ELEMENTICON:
- sb.append(ELEMENTICON_CONSTANT);
- break;
- case QUALIFIEDNAME:
- sb.append(QUALIFIEDNAME_CONSTANT);
- break;
- case HEIGHT:
- sb.append(HEIGHT_CONSTANT);
- break;
- case WIDTH:
- sb.append(WIDTH_CONSTANT);
- break;
- case COMPARTMENT_VISIBILITY:
- sb.append(COMPARTMENT_VISIBILITY_CONSTANT);
- break;
- case COMPARTMENT_NAME_VISIBILITY:
- sb.append(COMPARTMENT_NAME_VISIBILITY_CONSTANT);
- break;
- case LABEL_VISIBILITY:
- sb.append(LABEL_VISIBILITY_CONSTANT);
- break;
- case LOCATION_X:
- sb.append(LOCATION_X_CONSTANT);
- break;
- case LOCATION_Y:
- sb.append(LOCATION_Y_CONSTANT);
- break;
- case VIEW_RULER:
- sb.append(VIEW_RULERS_CONSTANT);
- break;
- case VIEW_GRID:
- sb.append(VIEW_GRID_CONSTANT);
- break;
- case RULER_UNITS:
- sb.append(RULER_UNITS_CONSTANT);
- break;
- case SNAP_TO_GRID:
- sb.append(SNAP_TO_GRID_CONSTANT);
- break;
- case SNAP_TO_GEOMETRY:
- sb.append(SNAP_TO_GEOMETRY_CONSTANT);
- break;
- case GRID_LINE_COLOR:
- sb.append(GRID_LINE_COLOR_CONSTANT);
- break;
- case GRID_SPACING:
- sb.append(GRID_SPACING_CONSTANT);
- break;
- case GRID_ORDER:
- sb.append(GRID_ORDER_CONSTANT);
- break;
- case GRID_LINE_STYLE:
- sb.append(GRID_LINE_STYLE_CONSTANT);
- break;
- case VIEW_PAGE_BREAK:
- sb.append(VIEW_PAGE_BREAK_CONSTANT);
- break;
- default:
- break;
- }
-
- return sb.toString();
- }
-
- /**
- *
- * @param elementName
- * diagramKind+'_'+element
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return the key for the element of a diagram
- */
- public static String getElementConstant(String elementName, int preferenceType) {
- return DIAGRAM_ELEMENT + getConstant(elementName, preferenceType);
- }
-
- /**
- *
- * @param elementName
- * diagramKind+'_'+element
- * @param compartmentName
- * the compartment name
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return the key for the element of a diagram
- */
- public static String getCompartmentElementConstant(String elementName, String compartmentName, int preferenceType) {
- String tmp = getElementConstant(elementName, preferenceType);
- return tmp.replaceFirst("\\.", "_" + compartmentName + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- *
- *
- * @param elementName
- * diagramKind+'_'+element
- * @param labelRole
- * he role of the label
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return the key for the element of a diagram
- */
- public static String getLabelElementConstant(String elementName, String labelRole, int preferenceType) {
- String tmp = getElementConstant(elementName, preferenceType);
- return tmp.replaceFirst("\\.", "_" + labelRole + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- *
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return get the preference key at the papyrus editor level
- */
- public static String getPapyrusEditorConstant(int preferenceType) {
- return getConstant(PAPYRUS_EDITOR_PREFERENCE_PREFIX, preferenceType);
- }
-
- /**
- *
- * @param diagramKind
- * the kind of diagram.
- * @param preferenceType
- * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
- * @return the preference key at the diagram level
- */
- public static String getDiagramConstant(String diagramKind, int preferenceType) {
- return DIAGRAM_PREFERENCE_PREFIX + getConstant(diagramKind, preferenceType);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * CEA LIST - Initial API and implementation
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.preferences;
+
+import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties;
+
+
+
+/**
+ * <p>
+ * A class that defines the available preference type available through Papyrus.
+ * </p>
+ * <p>
+ * It defines the following type:
+ * </p>
+ * <ul>
+ * <li>COLOR_FILL</li>
+ * <li>FONT</li>
+ * <li>COLOR_FONT</li>
+ * <li>COLOR_LINE</li>
+ * <li>COLOR_GRADIENT</li>
+ * <li>GRADIENT_POLICY</li>
+ * <li>JUMPLINK_STATUS</li>
+ * <li>JUMPLINK_REVERSE</li>
+ * <li>JUMPLINK_TYPE</li>
+ * <li>ROUTING_POLICY_DISTANCE</li>
+ * <li>ROUTING_POLICY_OBSTRUCTION</li>
+ * <li>ROUTING_STYLE</li>
+ * <li>SMOOTHNESS</li>
+ * </ul>
+ * <p>
+ * It also helps to retrieve the string used to store the preference type for a given element.
+ * </p>
+ *
+ */
+@SuppressWarnings("restriction")
+public class PreferencesConstantsHelper {
+
+ /**
+ * Prefix for preference for Papyrus Level editor
+ */
+ public final static String PAPYRUS_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_EDITOR"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for Diagram Level
+ */
+ public final static String DIAGRAM_PREFERENCE_PREFIX = "DIAGRAM_"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for element Level
+ */
+ public final static String DIAGRAM_ELEMENT = "ELEMENT_"; //$NON-NLS-1$
+
+ private final static String COLOR = "color."; //$NON-NLS-1$
+
+ private final static String GRADIENT = "gradient"; //$NON-NLS-1$
+
+ private final static String POLICY = ".policy"; //$NON-NLS-1$
+
+ private final static String JUMPLINK = "jumplink."; //$NON-NLS-1$
+
+ private final static String ROUTING = "routing"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY = ROUTING + POLICY;
+
+ private final static String COLOR_FILL_CONSTANT = COLOR + "fill"; //$NON-NLS-1$
+
+ private final static String FONT_CONSTANT = "font"; //$NON-NLS-1$
+
+ private final static String COLOR_FONT_CONSTANT = COLOR + FONT_CONSTANT;
+
+ private final static String COLOR_LINE_CONSTANT = COLOR + "line"; //$NON-NLS-1$
+
+ private final static String COLOR_GRADIENT_CONSTANT = COLOR + GRADIENT;
+
+ private final static String GRADIENT_POLICY_CONSTANT = GRADIENT + POLICY;
+
+ private final static String JUMPLINK_STATUS_CONSTANT = JUMPLINK + "status"; //$NON-NLS-1$
+
+ private final static String JUMPLINK_REVERSE_CONSTANT = JUMPLINK + "reverse"; //$NON-NLS-1$
+
+ private final static String JUMPLINK_TYPE_CONSTANT = JUMPLINK + "type"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY_DISTANCE_CONSTANT = ROUTING_POLICY + ".distance"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY_OBSTRUCTION_CONSTANT = ROUTING_POLICY + ".obstruction"; //$NON-NLS-1$
+
+ private final static String ROUTING_STYLE_CONSTANT = ROUTING + ".style"; //$NON-NLS-1$
+
+ private final static String SMOOTHNESS_CONSTANT = "smoothness"; //$NON-NLS-1$
+
+ private final static String SHADOW_CONSTANT = "shadow"; //$NON-NLS-1$
+
+ private final static String ELEMENTICON_CONSTANT = "elementicon"; //$NON-NLS-1$
+
+ private final static String QUALIFIEDNAME_CONSTANT = "qualifiedname"; //$NON-NLS-1$
+
+ private final static String HEIGHT_CONSTANT = "height";//$NON-NLS-1$
+
+ private final static String WIDTH_CONSTANT = "width"; //$NON-NLS-1$
+
+ private final static String COMPARTMENT_VISIBILITY_CONSTANT = "compartment.visibility"; //$NON-NLS-1$
+
+ private final static String COMPARTMENT_NAME_VISIBILITY_CONSTANT = "compartment_name.visibility"; //$NON-NLS-1$
+
+ private final static String LABEL_VISIBILITY_CONSTANT = "label.visibility"; //$NON-NLS-1$
+
+ private final static String LOCATION_X_CONSTANT = "location_x";//$NON-NLS-1$
+
+ private final static String LOCATION_Y_CONSTANT = "location_y"; //$NON-NLS-1$
+
+ public final static String VIEW_RULERS_CONSTANT = WorkspaceViewerProperties.VIEWRULERS;
+
+ public final static String VIEW_GRID_CONSTANT = WorkspaceViewerProperties.VIEWGRID;
+
+ public final static String RULER_UNITS_CONSTANT = WorkspaceViewerProperties.RULERUNIT;
+
+ public final static String SNAP_TO_GRID_CONSTANT = WorkspaceViewerProperties.SNAPTOGRID;
+
+ public final static String SNAP_TO_GEOMETRY_CONSTANT = WorkspaceViewerProperties.SNAPTOGEOMETRY;
+
+ public final static String GRID_LINE_COLOR_CONSTANT = WorkspaceViewerProperties.GRIDLINECOLOR;
+
+ public final static String GRID_SPACING_CONSTANT = WorkspaceViewerProperties.GRIDSPACING;
+
+ public final static String GRID_ORDER_CONSTANT = WorkspaceViewerProperties.GRIDORDER;
+
+ public final static String GRID_LINE_STYLE_CONSTANT = WorkspaceViewerProperties.GRIDLINESTYLE;
+
+ public final static String VIEW_PAGE_BREAK_CONSTANT = WorkspaceViewerProperties.VIEWPAGEBREAKS;
+
+ public final static String DRAW_CONNECTION_POINT_CONSTANT = "drawConnectionPoint"; //$NON-NLS-1$
+
+ public final static String INVERT_BINDING_FOR_DEFAULT_RESIZE_AND_CONSTRAINED_RESIZE_CONSTANT = "invertBindingForDefaultResizeAndConstrainedResize"; //$NON-NLS-1$
+
+ public final static String RESTORE_LINK_ELEMENT_CONSTANT = "restoreLinkElement"; //$NON-NLS-1$
+
+ /**
+ * A preference of type COLOR FILL
+ */
+ public final static int COLOR_FILL = 0;
+
+ /**
+ * A preference of type FONT
+ */
+ public final static int FONT = COLOR_FILL + 1;
+
+ /**
+ * A preference of type COLOR FONT
+ */
+ public final static int COLOR_FONT = FONT + 1;
+
+ /**
+ * A preference of type COLOR LINE
+ */
+ public final static int COLOR_LINE = COLOR_FONT + 1;
+
+ /**
+ * A preference of type COLOR GRADIENT
+ */
+ public final static int COLOR_GRADIENT = COLOR_LINE + 1;
+
+ /**
+ * A preference of type GRADIENT POLICY
+ */
+ public final static int GRADIENT_POLICY = COLOR_GRADIENT + 1;
+
+ /**
+ * A preference of type JUMPLINK STATUS
+ */
+ public final static int JUMPLINK_STATUS = GRADIENT_POLICY + 1;
+
+ /**
+ * A preference of type JUMPLINK REVERSE
+ */
+ public final static int JUMPLINK_REVERSE = JUMPLINK_STATUS + 1;
+
+ /**
+ * A preference of type JUMPLINK TYPE
+ */
+ public final static int JUMPLINK_TYPE = JUMPLINK_REVERSE + 1;
+
+ /**
+ * A preference of type ROUTING POLICY DISTANCE
+ */
+ public final static int ROUTING_POLICY_DISTANCE = JUMPLINK_TYPE + 1;
+
+ /**
+ * A preference of type ROUTING POLICY OBSTRUCTION
+ */
+ public final static int ROUTING_POLICY_OBSTRUCTION = ROUTING_POLICY_DISTANCE + 1;
+
+ /**
+ * A preference of type ROUTING STYLE
+ */
+ public final static int ROUTING_STYLE = ROUTING_POLICY_OBSTRUCTION + 1;
+
+ /**
+ * A preference of type SMOOTHNESS
+ */
+ public final static int SMOOTHNESS = ROUTING_STYLE + 1;
+
+ /**
+ * A preference of type Shadow
+ */
+ public final static int SHADOW = SMOOTHNESS + 1;
+
+ /**
+ * A preference of type elementIcon
+ */
+ public final static int ELEMENTICON = SHADOW + 1;
+
+ /**
+ * A preference of type QualifiedName
+ */
+ public final static int QUALIFIEDNAME = ELEMENTICON + 1;
+
+ /**
+ * A preference of type height
+ */
+ public static final int HEIGHT = QUALIFIEDNAME + 1;
+
+ /**
+ * A preference of type width
+ */
+ public static final int WIDTH = HEIGHT + 1;
+
+ /**
+ * A preference of type compartment visibility
+ */
+ public static final int COMPARTMENT_VISIBILITY = WIDTH + 1;
+
+ /**
+ * A preference of type compartment visibility
+ */
+ public static final int COMPARTMENT_NAME_VISIBILITY = COMPARTMENT_VISIBILITY + 1;
+
+ /**
+ * A preference of type label visibility
+ */
+ public static final int LABEL_VISIBILITY = COMPARTMENT_NAME_VISIBILITY + 1;
+
+ /**
+ * A preference for label default location
+ */
+ public static final int LOCATION_X = LABEL_VISIBILITY + 1;
+
+ /**
+ * A preference for label default location
+ */
+ public static final int LOCATION_Y = LOCATION_X + 1;
+
+ /**
+ * A preference to diplay or not the rulers
+ */
+ public static final int VIEW_RULER = LOCATION_Y + 1;
+
+ /**
+ * A preference to diplay or not the grid
+ */
+
+ public static final int VIEW_GRID = VIEW_RULER + 1;
+
+ /**
+ * A preference to change the ruler unit
+ */
+
+ public static final int RULER_UNITS = VIEW_GRID + 1;
+
+ /**
+ * A preference to snap the created element to the grid
+ */
+ public static final int SNAP_TO_GRID = RULER_UNITS + 1;
+
+ /**
+ * A preference to snap the created element to the shape
+ */
+ public static final int SNAP_TO_GEOMETRY = SNAP_TO_GRID + 1;
+
+ /**
+ * A preference to change the grid color
+ */
+ public static final int GRID_LINE_COLOR = SNAP_TO_GEOMETRY + 1;
+
+ /**
+ * A preference to change the grid spacing
+ */
+ public static final int GRID_SPACING = GRID_LINE_COLOR + 1;
+
+ /**
+ * A preference to change the Z order of the Grid
+ */
+ public static final int GRID_ORDER = GRID_SPACING + 1;
+
+ /**
+ * A preference to change the style of the grid
+ */
+ public static final int GRID_LINE_STYLE = GRID_ORDER + 1;
+
+ /**
+ * A preference to view the page break on the diagram
+ */
+ public static final int VIEW_PAGE_BREAK = GRID_LINE_STYLE + 1;
+
+ /**
+ * A preference to draw big point when 2 links have a common part
+ */
+ public static final int DRAW_CONNECTION_POINT = VIEW_PAGE_BREAK + 1;
+
+ /**
+ * A Papyrus preference to define the if the default resize action is constrained or not.
+ * if the preference is <code>false</code>
+ * <ul>
+ * <li>default resize is not constraint</li>
+ * <li>resize + SHIFT is constrained</li>
+ * </ul>
+ */
+ public static final int INVERT_BINDING_FOR_DEFAULT_RESIZE_AND_CONSTRAINED_RESIZE = DRAW_CONNECTION_POINT + 1;
+
+ /**
+ * A preference to indicate if the link element must be restore or not
+ */
+ public static final int RESTORE_LINK_ELEMENT = INVERT_BINDING_FOR_DEFAULT_RESIZE_AND_CONSTRAINED_RESIZE + 1;
+
+ /**
+ * Get the preference constant used to store the preference of an element.
+ *
+ * @param elementName
+ * the name of the element
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the constant used.
+ */
+ public static String getConstant(String elementName, int preferenceType) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(elementName);
+ sb.append("."); //$NON-NLS-1$
+
+ switch (preferenceType) {
+ case COLOR_FILL:
+ sb.append(COLOR_FILL_CONSTANT);
+ break;
+ case FONT:
+ sb.append(FONT_CONSTANT);
+ break;
+ case COLOR_FONT:
+ sb.append(COLOR_FONT_CONSTANT);
+ break;
+ case COLOR_LINE:
+ sb.append(COLOR_LINE_CONSTANT);
+ break;
+ case COLOR_GRADIENT:
+ sb.append(COLOR_GRADIENT_CONSTANT);
+ break;
+ case GRADIENT_POLICY:
+ sb.append(GRADIENT_POLICY_CONSTANT);
+ break;
+ case JUMPLINK_STATUS:
+ sb.append(JUMPLINK_STATUS_CONSTANT);
+ break;
+ case JUMPLINK_REVERSE:
+ sb.append(JUMPLINK_REVERSE_CONSTANT);
+ break;
+ case JUMPLINK_TYPE:
+ sb.append(JUMPLINK_TYPE_CONSTANT);
+ break;
+ case ROUTING_POLICY_DISTANCE:
+ sb.append(ROUTING_POLICY_DISTANCE_CONSTANT);
+ break;
+ case ROUTING_POLICY_OBSTRUCTION:
+ sb.append(ROUTING_POLICY_OBSTRUCTION_CONSTANT);
+ break;
+ case ROUTING_STYLE:
+ sb.append(ROUTING_STYLE_CONSTANT);
+ break;
+ case SMOOTHNESS:
+ sb.append(SMOOTHNESS_CONSTANT);
+ break;
+ case SHADOW:
+ sb.append(SHADOW_CONSTANT);
+ break;
+ case ELEMENTICON:
+ sb.append(ELEMENTICON_CONSTANT);
+ break;
+ case QUALIFIEDNAME:
+ sb.append(QUALIFIEDNAME_CONSTANT);
+ break;
+ case HEIGHT:
+ sb.append(HEIGHT_CONSTANT);
+ break;
+ case WIDTH:
+ sb.append(WIDTH_CONSTANT);
+ break;
+ case COMPARTMENT_VISIBILITY:
+ sb.append(COMPARTMENT_VISIBILITY_CONSTANT);
+ break;
+ case COMPARTMENT_NAME_VISIBILITY:
+ sb.append(COMPARTMENT_NAME_VISIBILITY_CONSTANT);
+ break;
+ case LABEL_VISIBILITY:
+ sb.append(LABEL_VISIBILITY_CONSTANT);
+ break;
+ case LOCATION_X:
+ sb.append(LOCATION_X_CONSTANT);
+ break;
+ case LOCATION_Y:
+ sb.append(LOCATION_Y_CONSTANT);
+ break;
+ case VIEW_RULER:
+ sb.append(VIEW_RULERS_CONSTANT);
+ break;
+ case VIEW_GRID:
+ sb.append(VIEW_GRID_CONSTANT);
+ break;
+ case RULER_UNITS:
+ sb.append(RULER_UNITS_CONSTANT);
+ break;
+ case SNAP_TO_GRID:
+ sb.append(SNAP_TO_GRID_CONSTANT);
+ break;
+ case SNAP_TO_GEOMETRY:
+ sb.append(SNAP_TO_GEOMETRY_CONSTANT);
+ break;
+ case GRID_LINE_COLOR:
+ sb.append(GRID_LINE_COLOR_CONSTANT);
+ break;
+ case GRID_SPACING:
+ sb.append(GRID_SPACING_CONSTANT);
+ break;
+ case GRID_ORDER:
+ sb.append(GRID_ORDER_CONSTANT);
+ break;
+ case GRID_LINE_STYLE:
+ sb.append(GRID_LINE_STYLE_CONSTANT);
+ break;
+ case VIEW_PAGE_BREAK:
+ sb.append(VIEW_PAGE_BREAK_CONSTANT);
+ break;
+ case RESTORE_LINK_ELEMENT:
+ sb.append(RESTORE_LINK_ELEMENT_CONSTANT);
+ break;
+ default:
+ break;
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getElementConstant(String elementName, int preferenceType) {
+ return DIAGRAM_ELEMENT + getConstant(elementName, preferenceType);
+ }
+
+ /**
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param compartmentName
+ * the compartment name
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getCompartmentElementConstant(String elementName, String compartmentName, int preferenceType) {
+ String tmp = getElementConstant(elementName, preferenceType);
+ return tmp.replaceFirst("\\.", "_" + compartmentName + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ *
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param labelRole
+ * he role of the label
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getLabelElementConstant(String elementName, String labelRole, int preferenceType) {
+ String tmp = getElementConstant(elementName, preferenceType);
+ return tmp.replaceFirst("\\.", "_" + labelRole + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ *
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return get the preference key at the papyrus editor level
+ */
+ public static String getPapyrusEditorConstant(int preferenceType) {
+ return getConstant(PAPYRUS_EDITOR_PREFERENCE_PREFIX, preferenceType);
+ }
+
+ /**
+ *
+ * @param diagramKind
+ * the kind of diagram.
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the preference key at the diagram level
+ */
+ public static String getDiagramConstant(String diagramKind, int preferenceType) {
+ return DIAGRAM_PREFERENCE_PREFIX + getConstant(diagramKind, preferenceType);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/Messages.java
index 1211a683f2d..cd0971c8a03 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/Messages.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/Messages.java
@@ -1,98 +1,99 @@
-/****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- * 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
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.preferences;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.preferences.messages"; //$NON-NLS-1$
-
-
-
- public static String AbstractPapyrusElementPreferencePage_Colors;
-
- public static String AbstractPapyrusElementPreferencePage_Font;
-
- public static String AbstractPapyrusLinkPreferencePage_Above;
-
- public static String AbstractPapyrusLinkPreferencePage_All;
-
- public static String AbstractPapyrusLinkPreferencePage_AvoidObstructions;
-
- public static String AbstractPapyrusLinkPreferencePage_Below;
-
- public static String AbstractPapyrusLinkPreferencePage_Chamfered;
-
- public static String AbstractPapyrusLinkPreferencePage_ClosestDistance;
-
- public static String AbstractPapyrusLinkPreferencePage_Connection;
-
- public static String AbstractPapyrusLinkPreferencePage_JUMPLINKS;
-
- public static String AbstractPapyrusLinkPreferencePage_Less;
-
- public static String AbstractPapyrusLinkPreferencePage_More;
-
- public static String AbstractPapyrusLinkPreferencePage_None;
-
- public static String AbstractPapyrusLinkPreferencePage_Normal;
-
- public static String AbstractPapyrusLinkPreferencePage_Oblique;
-
- public static String AbstractPapyrusLinkPreferencePage_Rectilinear;
-
- public static String AbstractPapyrusLinkPreferencePage_ReverseJumpLinks;
-
- public static String AbstractPapyrusLinkPreferencePage_Routing;
-
- public static String AbstractPapyrusLinkPreferencePage_SemiCircle;
-
- public static String AbstractPapyrusLinkPreferencePage_Smoothness;
-
- public static String AbstractPapyrusLinkPreferencePage_Square;
-
- public static String AbstractPapyrusLinkPreferencePage_Status;
-
- public static String AbstractPapyrusLinkPreferencePage_Styles;
-
- public static String AbstractPapyrusLinkPreferencePage_Tree;
-
- public static String AbstractPapyrusLinkPreferencePage_Type;
-
- public static String AbstractPapyrusNodePreferencePage_Activate;
-
- public static String AbstractPapyrusNodePreferencePage_Gradient;
-
- public static String GradientFieldEditor_Color;
-
- public static String GradientFieldEditor_Horizontal;
-
- public static String GradientFieldEditor_Style;
-
- public static String GradientFieldEditor_Transparency;
-
- public static String GradientFieldEditor_Vertical;
-
- public static String DecorationGroup_Name;
-
- public static String DimensionGroupName;
-
-
-
- public static String NodeCompartmentGroup_Compartiments;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.preferences.messages"; //$NON-NLS-1$
+
+ public static String AbstractPapyrusElementPreferencePage_Colors;
+
+ public static String AbstractPapyrusElementPreferencePage_Font;
+
+ public static String AbstractPapyrusLinkPreferencePage_Above;
+
+ public static String AbstractPapyrusLinkPreferencePage_All;
+
+ public static String AbstractPapyrusLinkPreferencePage_AvoidObstructions;
+
+ public static String AbstractPapyrusLinkPreferencePage_Below;
+
+ public static String AbstractPapyrusLinkPreferencePage_Chamfered;
+
+ public static String AbstractPapyrusLinkPreferencePage_ClosestDistance;
+
+ public static String AbstractPapyrusLinkPreferencePage_Connection;
+
+ public static String AbstractPapyrusLinkPreferencePage_JUMPLINKS;
+
+ public static String AbstractPapyrusLinkPreferencePage_Less;
+
+ public static String AbstractPapyrusLinkPreferencePage_More;
+
+ public static String AbstractPapyrusLinkPreferencePage_None;
+
+ public static String AbstractPapyrusLinkPreferencePage_Normal;
+
+ public static String AbstractPapyrusLinkPreferencePage_Oblique;
+
+ public static String AbstractPapyrusLinkPreferencePage_Rectilinear;
+
+ public static String AbstractPapyrusLinkPreferencePage_ReverseJumpLinks;
+
+ public static String AbstractPapyrusLinkPreferencePage_Routing;
+
+ public static String AbstractPapyrusLinkPreferencePage_SemiCircle;
+
+ public static String AbstractPapyrusLinkPreferencePage_Smoothness;
+
+ public static String AbstractPapyrusLinkPreferencePage_Square;
+
+ public static String AbstractPapyrusLinkPreferencePage_Status;
+
+ public static String AbstractPapyrusLinkPreferencePage_Styles;
+
+ public static String AbstractPapyrusLinkPreferencePage_Tree;
+
+ public static String AbstractPapyrusLinkPreferencePage_Type;
+
+ public static String AbstractPapyrusNodePreferencePage_Activate;
+
+ public static String AbstractPapyrusNodePreferencePage_Gradient;
+
+ public static String GradientFieldEditor_Color;
+
+ public static String GradientFieldEditor_Horizontal;
+
+ public static String GradientFieldEditor_Style;
+
+ public static String GradientFieldEditor_Transparency;
+
+ public static String GradientFieldEditor_Vertical;
+
+ public static String DecorationGroup_Name;
+
+ public static String DimensionGroupName;
+
+ public static String NodeCompartmentGroup_Compartiments;
+
+ public static String RestoreElementGroup_RestoreElementLink;
+
+ public static String RestoreElementGroup_AlwaysCreateANewLink;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages.properties
index 5372bd6a1de..7e901ab06f9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages.properties
@@ -1,35 +1,38 @@
-AbstractPapyrusElementPreferencePage_Colors=Colors
-AbstractPapyrusElementPreferencePage_Font=Font
-AbstractPapyrusLinkPreferencePage_Above=Above
-AbstractPapyrusLinkPreferencePage_All=All
-AbstractPapyrusLinkPreferencePage_AvoidObstructions=Avoid Obstructions
-AbstractPapyrusLinkPreferencePage_Below=Below
-AbstractPapyrusLinkPreferencePage_Chamfered=Chamfered
-AbstractPapyrusLinkPreferencePage_ClosestDistance=Closest Distance
-AbstractPapyrusLinkPreferencePage_Connection=Connection
-AbstractPapyrusLinkPreferencePage_JUMPLINKS=Jump Links
-AbstractPapyrusLinkPreferencePage_Less=Less
-AbstractPapyrusLinkPreferencePage_More=More
-AbstractPapyrusLinkPreferencePage_None=None
-AbstractPapyrusLinkPreferencePage_Normal=Normal
-AbstractPapyrusLinkPreferencePage_Oblique=Oblique
-AbstractPapyrusLinkPreferencePage_Rectilinear=Rectilinear
-AbstractPapyrusLinkPreferencePage_ReverseJumpLinks=Reverse jump links
-AbstractPapyrusLinkPreferencePage_Routing=Routing
-AbstractPapyrusLinkPreferencePage_SemiCircle=Semi-Circle
-AbstractPapyrusLinkPreferencePage_Smoothness=Smoothness
-AbstractPapyrusLinkPreferencePage_Square=Square
-AbstractPapyrusLinkPreferencePage_Status=Status
-AbstractPapyrusLinkPreferencePage_Styles=Styles
-AbstractPapyrusLinkPreferencePage_Tree=Tree
-AbstractPapyrusLinkPreferencePage_Type=Type
-AbstractPapyrusNodePreferencePage_Activate=Activate
-AbstractPapyrusNodePreferencePage_Gradient=Gradient :
-GradientFieldEditor_Color=Color
-GradientFieldEditor_Horizontal=Horizontal
-GradientFieldEditor_Style=Style
-GradientFieldEditor_Transparency=Transparency
-GradientFieldEditor_Vertical=Vertical
-DecorationGroup_Name=Decoration
-DimensionGroupName=Dimension
-NodeCompartmentGroup_Compartiments=Show/hide compartments
+AbstractPapyrusElementPreferencePage_Colors=Colors
+AbstractPapyrusElementPreferencePage_Font=Font
+AbstractPapyrusLinkPreferencePage_Above=Above
+AbstractPapyrusLinkPreferencePage_All=All
+AbstractPapyrusLinkPreferencePage_AvoidObstructions=Avoid Obstructions
+AbstractPapyrusLinkPreferencePage_Below=Below
+AbstractPapyrusLinkPreferencePage_Chamfered=Chamfered
+AbstractPapyrusLinkPreferencePage_ClosestDistance=Closest Distance
+AbstractPapyrusLinkPreferencePage_Connection=Connection
+AbstractPapyrusLinkPreferencePage_JUMPLINKS=Jump Links
+AbstractPapyrusLinkPreferencePage_Less=Less
+AbstractPapyrusLinkPreferencePage_More=More
+AbstractPapyrusLinkPreferencePage_None=None
+AbstractPapyrusLinkPreferencePage_Normal=Normal
+AbstractPapyrusLinkPreferencePage_Oblique=Oblique
+AbstractPapyrusLinkPreferencePage_Rectilinear=Rectilinear
+AbstractPapyrusLinkPreferencePage_ReverseJumpLinks=Reverse jump links
+AbstractPapyrusLinkPreferencePage_Routing=Routing
+AbstractPapyrusLinkPreferencePage_SemiCircle=Semi-Circle
+AbstractPapyrusLinkPreferencePage_Smoothness=Smoothness
+AbstractPapyrusLinkPreferencePage_Square=Square
+AbstractPapyrusLinkPreferencePage_Status=Status
+AbstractPapyrusLinkPreferencePage_Styles=Styles
+AbstractPapyrusLinkPreferencePage_Tree=Tree
+AbstractPapyrusLinkPreferencePage_Type=Type
+AbstractPapyrusNodePreferencePage_Activate=Activate
+AbstractPapyrusNodePreferencePage_Gradient=Gradient :
+GradientFieldEditor_Color=Color
+GradientFieldEditor_Horizontal=Horizontal
+GradientFieldEditor_Style=Style
+GradientFieldEditor_Transparency=Transparency
+GradientFieldEditor_Vertical=Vertical
+DecorationGroup_Name=Decoration
+DimensionGroupName=Dimension
+NodeCompartmentGroup_Compartiments=Show/hide compartments
+
+RestoreElementGroup_RestoreElementLink=Restore Link Element
+RestoreElementGroup_AlwaysCreateANewLink=Always create a new link
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/pages/PapyrusAllDiagramsPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/pages/PapyrusAllDiagramsPreferencePage.java
index 026dd1c7b68..ac34173993b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/pages/PapyrusAllDiagramsPreferencePage.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/pages/PapyrusAllDiagramsPreferencePage.java
@@ -1,141 +1,149 @@
-/****************************************************************************
- * Copyright (c) 2008 Atos Origin.
- *
- * 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:
- * Thibault Landre (Atos Origin) - Initial API and implementation
- * Patrick Tessier (CEA LIST)- modifications
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.preferences.pages;
-
-import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
-import org.eclipse.gmf.runtime.notation.Routing;
-import org.eclipse.gmf.runtime.notation.Smoothness;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.PapyrusPreferenceStore;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.BackgroundColor;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.ConnectionGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.DecorationGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.DimensionGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.FontGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.NodeColorGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.RulersAndGridGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorBackgroundColor;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorConnectionGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorDecorationGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorDimensionGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorFontGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorNodeColorGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorRulersAndGridGroup;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * The default preference page all element of diagrams
- *
- */
-public class PapyrusAllDiagramsPreferencePage extends AbstractPapyrusPreferencePage {
-
- @Override
- protected void createPageContents(Composite parent) {
- Group contentGroup = new Group(parent, 2);
- contentGroup.setLayout(new GridLayout(4, false));
-
- // FontGroup
- FontGroup fontGroupComposite = new EditorFontGroup(contentGroup, getTitle(), this);
- addAbstractGroup(fontGroupComposite);
- // color
- NodeColorGroup colorGroupForNodeComposite = new EditorNodeColorGroup(contentGroup, getTitle(), this);
- addAbstractGroup(colorGroupForNodeComposite);
-
-
- // router for links
- ConnectionGroup connectionGroupComposite = new EditorConnectionGroup(contentGroup, getTitle(), this);
- addAbstractGroup(connectionGroupComposite);
-
- // background
- BackgroundColor backgroundColorGroup = new EditorBackgroundColor(contentGroup, getTitle(), this);
- addAbstractGroup(backgroundColorGroup);
-
- DecorationGroup decorationGroupComposite = new EditorDecorationGroup(contentGroup, getTitle(), this);
- addAbstractGroup(decorationGroupComposite);
-
- DimensionGroup dimensionGroup = new EditorDimensionGroup(contentGroup, getTitle(), this);
- addAbstractGroup(dimensionGroup);
-
- RulersAndGridGroup viewGroupComposite = new EditorRulersAndGridGroup(parent, getTitle(), this);
- addAbstractGroup(viewGroupComposite);
- }
-
-
- @Override
- protected String getBundleId() {
- return Activator.PLUGIN_ID;
- }
-
- /**
- * use to init default preferences at the papyrus level
- *
- * @param store
- * the preference store
- */
- public static void initDefaults(final IPreferenceStore store) {
- Display.getDefault().syncExec(new Runnable() { // to be in the thread ui
-
- public void run() {
-
- // Nodes
- PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
- PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));
-
- // Set the default for the gradient
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRADIENT_POLICY), false);
- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(new org.eclipse.swt.graphics.RGB(255, 255, 255), new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());
-
- // Links
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.SMOOTHNESS), Smoothness.NONE);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_STATUS), JumpLinkStatus.NONE);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_TYPE), JumpLinkStatus.NONE);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_REVERSE), false);
-
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_STYLE), Routing.MANUAL);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_POLICY_OBSTRUCTION), false);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_POLICY_DISTANCE), false);
-
- // decoration
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.SHADOW), false);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ELEMENTICON), false);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.QUALIFIEDNAME), false);
- // dimension
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.WIDTH), 100);
- store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.HEIGHT), 100);
-
- // Rulers and grid group
- RulersAndGridGroup.initDefaults(store);
- }
- });
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void storeAllPreferences() {
- super.storeAllPreferences();
- ((PapyrusPreferenceStore) getPreferenceStore()).deleteAllSubPreference(PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX);
-
- }
-}
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Patrick Tessier (CEA LIST)- modifications
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.preferences.pages;
+
+import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
+import org.eclipse.gmf.runtime.notation.Routing;
+import org.eclipse.gmf.runtime.notation.Smoothness;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.PapyrusPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.DimensionGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.FontGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.RestoreElementGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.RulersAndGridGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorBackgroundColor;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorConnectionGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorDecorationGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorDimensionGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorFontGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorNodeColorGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.editor.EditorRulersAndGridGroup;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The default preference page all element of diagrams
+ *
+ */
+public class PapyrusAllDiagramsPreferencePage extends AbstractPapyrusPreferencePage {
+
+ @Override
+ protected void createPageContents(final Composite parent) {
+ Group contentGroup = new Group(parent, 2);
+ contentGroup.setLayout(new GridLayout(4, false));
+
+ // FontGroup
+ FontGroup fontGroupComposite = new EditorFontGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(fontGroupComposite);
+ // color
+ NodeColorGroup colorGroupForNodeComposite = new EditorNodeColorGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(colorGroupForNodeComposite);
+
+
+ // router for links
+ ConnectionGroup connectionGroupComposite = new EditorConnectionGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(connectionGroupComposite);
+
+ // background
+ BackgroundColor backgroundColorGroup = new EditorBackgroundColor(contentGroup, getTitle(), this);
+ addAbstractGroup(backgroundColorGroup);
+
+ DecorationGroup decorationGroupComposite = new EditorDecorationGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(decorationGroupComposite);
+
+ DimensionGroup dimensionGroup = new EditorDimensionGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(dimensionGroup);
+
+ RulersAndGridGroup viewGroupComposite = new EditorRulersAndGridGroup(parent, getTitle(), this);
+ addAbstractGroup(viewGroupComposite);
+
+ final RestoreElementGroup restoreElementGroup = new RestoreElementGroup(parent, getTitle(), this);
+ addAbstractGroup(restoreElementGroup);
+ }
+
+
+ @Override
+ protected String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+ /**
+ * use to init default preferences at the papyrus level
+ *
+ * @param store
+ * the preference store
+ */
+ public static void initDefaults(final IPreferenceStore store) {
+ Display.getDefault().syncExec(new Runnable() { // to be in the thread ui
+
+ public void run() {
+
+ // Nodes
+ PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
+ PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));
+
+ // Set the default for the gradient
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRADIENT_POLICY), false);
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(new org.eclipse.swt.graphics.RGB(255, 255, 255), new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());
+
+ // Links
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.SMOOTHNESS), Smoothness.NONE);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_STATUS), JumpLinkStatus.NONE);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_TYPE), JumpLinkStatus.NONE);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.JUMPLINK_REVERSE), false);
+
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_STYLE), Routing.MANUAL);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_POLICY_OBSTRUCTION), false);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ROUTING_POLICY_DISTANCE), false);
+
+ // decoration
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.SHADOW), false);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.ELEMENTICON), false);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.QUALIFIEDNAME), false);
+ // dimension
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.WIDTH), 100);
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.HEIGHT), 100);
+
+ // Rulers and grid group
+ RulersAndGridGroup.initDefaults(store);
+
+ // Restore Element Group
+ RestoreElementGroup.initDefaults(store);
+ }
+ });
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void storeAllPreferences() {
+ super.storeAllPreferences();
+ ((PapyrusPreferenceStore) getPreferenceStore()).deleteAllSubPreference(PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX);
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RestoreElementGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RestoreElementGroup.java
new file mode 100644
index 00000000000..273d40324c9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RestoreElementGroup.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Initial API and implementation, Bug 419357
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.preferences.ui;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class RestoreElementGroup contains a boolean field editor to always create a new link.
+ */
+public class RestoreElementGroup extends AbstractGroup {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * @param key
+ * @param dialogPage
+ */
+ public RestoreElementGroup(final Composite parent, final String key, final DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Create the content of the group.
+ *
+ * @param parent
+ */
+ private void createContent(final Composite parent) {
+ // Create a Group to hold the restore element fields
+ final Group group = new Group(parent, SWT.NONE);
+ group.setText(Messages.RestoreElementGroup_RestoreElementLink);
+
+ final GridLayout gridLayout = new GridLayout(1, false);
+ final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 1;
+
+
+ // Add the fields to the group
+ final BooleanFieldEditor restoreElement = new BooleanFieldEditor(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT), Messages.RestoreElementGroup_AlwaysCreateANewLink, group);
+ addFieldEditor(restoreElement);
+
+ group.setLayoutData(gridData);
+ group.setLayout(gridLayout);
+ }
+
+
+ /**
+ * Initializes the default values of the group.
+ */
+ public static void initDefaults(IPreferenceStore store) {
+ store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT), false);
+ }
+}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
index 9bcf5501c7d..b8a2e6cc40f 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
@@ -7,11 +7,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
* CEA LIST - Initial API and implementation
- * Bonnabesse Fanch (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 478288
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 478288, 419357
*
*****************************************************************************/
+
package org.eclipse.papyrus.sysml.diagram.common.utils;
import java.util.ArrayList;
@@ -27,10 +27,10 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
-import org.eclipse.papyrus.sysml.service.types.utils.AssociationUtils;
import org.eclipse.papyrus.sysml.service.types.utils.ConnectorUtils;
import org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper;
+import org.eclipse.papyrus.uml.diagram.common.util.AssociationUtil;
import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
import org.eclipse.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Association;
@@ -202,42 +202,7 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
final Collection<?> targets = this.linkMappingHelper.getTarget(current);
if (sources.contains(request.getSource()) && targets.contains(request.getTarget()) && (current instanceof Association)) {
- boolean identicalAssociation = true;
-
- final Iterator<Property> iterator = ((Association) current).getMemberEnds().iterator();
-
- while (iterator.hasNext() && identicalAssociation) {
- final Property property = iterator.next();
-
- final boolean source = request.getSource().equals(property.getType());
-
- // Handle of all types of Association in SysML
- if (SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(false, AggregationKind.NONE_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- } else if (SysMLElementTypes.ASSOCIATION_NONE.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(true, AggregationKind.NONE_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- } else if (SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(false, AggregationKind.COMPOSITE_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- } else if (SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(true, AggregationKind.COMPOSITE_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- } else if (SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(false, AggregationKind.SHARED_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- } else if (SysMLElementTypes.ASSOCIATION_SHARED.equals(wantedElementType)) {
- if (!AssociationUtils.isIdenticalProperties(true, AggregationKind.SHARED_LITERAL, source, property)) {
- identicalAssociation = false;
- }
- }
- }
+ boolean identicalAssociation = compareMembers(current, request, wantedElementType);
if (identicalAssociation) {
existingElement.add(new LinkEndsMapper(current, sources, null, null));
@@ -252,4 +217,83 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
return existingElement;
}
+ /**
+ * Manages all the members of the current relationship to compare with a new relationship.
+ *
+ * @param current
+ * The element to compare with the created element.
+ * @param request
+ * The creation relationship request.
+ * @param wantedElementType
+ * The type of the created relationship.
+ * @return The result of the comparison.
+ */
+ private boolean compareMembers(final Element current, final CreateRelationshipRequest request, final IElementType wantedElementType) {
+ boolean identicalAssociation = true;
+
+ final Iterator<Property> iterator = ((Association) current).getMemberEnds().iterator();
+
+ while (iterator.hasNext() && identicalAssociation) {
+ final Property property = iterator.next();
+
+ final boolean source = request.getSource().equals(property.getType());
+
+ boolean expectedNavigable = true;
+ AggregationKind expectedAggregation = AggregationKind.NONE_LITERAL;
+
+ // Handle of all types of Association in SysML
+ if (SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(wantedElementType)) {
+ if (source) {
+ expectedNavigable = false;
+ }
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ } else if (SysMLElementTypes.ASSOCIATION_NONE.equals(wantedElementType)) {
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ } else if (SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(wantedElementType)) {
+ if (source) {
+ expectedNavigable = false;
+ } else {
+ expectedAggregation = AggregationKind.COMPOSITE_LITERAL;
+ }
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ } else if (SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(wantedElementType)) {
+ if (!source) {
+ expectedAggregation = AggregationKind.COMPOSITE_LITERAL;
+ }
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ } else if (SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(wantedElementType)) {
+ if (source) {
+ expectedNavigable = false;
+ } else {
+ expectedAggregation = AggregationKind.SHARED_LITERAL;
+ }
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ } else if (SysMLElementTypes.ASSOCIATION_SHARED.equals(wantedElementType)) {
+ if (!source) {
+ expectedAggregation = AggregationKind.SHARED_LITERAL;
+ }
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, expectedAggregation, property)) {
+ identicalAssociation = false;
+ }
+ }
+ }
+
+ return identicalAssociation;
+ }
+
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/AssociationUtils.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/AssociationUtils.java
deleted file mode 100644
index 5b3f5e07576..00000000000
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/AssociationUtils.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Bonnabesse Fanch (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 478288
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.sysml.service.types.utils;
-
-import org.eclipse.uml2.uml.AggregationKind;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * Utility class for Association edit helpers.
- */
-public class AssociationUtils {
-
- /**
- * This compares the Property of an Association with expected informations.
- *
- * @param expectedNavigable
- * The expected navigable information.
- * @param expectedAggregation
- * The expected kind of aggregation.
- * @param source
- * To specify if the member in treatment is a source.
- * @param property
- * The property containing the aggregation to compare.
- * @return The result of the comparison.
- */
- public static boolean isIdenticalProperties(final boolean expectedNavigable, final AggregationKind expectedAggregation, final boolean source, final Property property) {
- return (isIdenticalAggregations(expectedAggregation, source, property) && isIdenticalNavigables(expectedNavigable, source, property));
- }
-
- /**
- * This compares the aggregation information of a Property with an expected kind of aggregation.
- *
- * @param expectedAggregation
- * The expected kind of aggregation.
- * @param source
- * To specify if the member in treatment is a source.
- * @param property
- * The property containing the aggregation to compare.
- * @return The result of the comparison.
- */
- public static boolean isIdenticalAggregations(final AggregationKind expectedAggregation, final boolean source, final Property property) {
- boolean identicalAggregation = false;
-
- final AggregationKind aggregation = property.getAggregation();
-
- if (source) {
- // If the member is the source member, the aggregation must be NONE
- if (AggregationKind.NONE_LITERAL.equals(aggregation)) {
- identicalAggregation = true;
- }
-
- // If the member is the target member, the aggregation must be the same than the expected aggregation
- } else if (expectedAggregation.equals(aggregation)) {
- identicalAggregation = true;
- }
-
- return identicalAggregation;
- }
-
- /**
- * This compares the navigable information of a Property with an expected navigable.
- *
- * @param expectedNavigable
- * The expected navigable information.
- * @param source
- * To specify if the member in treatment is a source.
- * @param property
- * The property containing the navigable information to compare.
- * @return The result of the comparison.
- */
- public static boolean isIdenticalNavigables(final boolean expectedNavigable, final boolean source, final Property property) {
- boolean identicalNavigable = false;
-
- final boolean navigable = property.isNavigable();
-
- if (source) {
- // If the member is the source member, the navigable value must be the same than the expected navigable
- if (expectedNavigable == navigable) {
- identicalNavigable = true;
- }
-
- // If the member is the source member, the navigable value must be the same than the expected navigable
- } else if (navigable) {
- identicalNavigable = true;
- }
-
- return identicalNavigable;
- }
-
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
index 0f7f527c62a..3229561d801 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
@@ -482,6 +482,12 @@
</Priority>
</editpolicyProvider>
<editpolicyProvider
+ class="org.eclipse.papyrus.uml.diagram.common.providers.CustomEditPolicyProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </editpolicyProvider>
+ <editpolicyProvider
class="org.eclipse.papyrus.uml.diagram.common.providers.ImportedElementEditPolicyProvider">
<Priority
name="Low">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/dialogs/CreateOrShowExistingLinkDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/dialogs/CreateOrShowExistingLinkDialog.java
index 2a3e6fd48ab..cc6bef0d690 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/dialogs/CreateOrShowExistingLinkDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/dialogs/CreateOrShowExistingLinkDialog.java
@@ -1,346 +1,400 @@
-/*****************************************************************************
- * Copyright (c) 2013 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.dialogs;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckboxCellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.ViewerColumn;
-import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
-import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-
-
-/**
- * This dialog is used to ask to the user if he wants create a new instance of a link, or show an existing link on the diagram
- *
- * @author VL222926
- *
- */
-public class CreateOrShowExistingLinkDialog extends MessageDialog {
-
- /**
- * indexes of the button
- */
- public static final int CREATE = Dialog.OK;
-
- public static final int RESTORE_SELECTED_LINK = CREATE + 1;
-
- public static final int CANCEL = RESTORE_SELECTED_LINK + 1;
-
- /**
- * title for the dialog
- */
- public static final String DIALOG_TITLE = Messages.CreateOrShowExistingLinkDialog_ShowOrCreate;
-
- /**
- * Message for the Buttons
- */
- private static final String CREATE_STRING = Messages.CreateOrShowExistingLinkDialog_Create;
-
- private static final String RESTORE_SELECTION = Messages.CreateOrShowExistingLinkDialog_RestoreSelection;
-
- private static final String CANCEL_STRING = "Cancel"; //$NON-NLS-1$
-
-
- /**
- * Titles for the columns
- */
- private static final String NAME = Messages.CreateOrShowExistingLinkDialog_Name;
-
- private static final String ENDS = Messages.CreateOrShowExistingLinkDialog_Ends;
-
- private static final String SOURCES = Messages.CreateOrShowExistingLinkDialog_Sources;
-
- private static final String TARGETS = Messages.CreateOrShowExistingLinkDialog_Targets;
-
- /**
- * Size for the columns
- */
- private static final int COLUMN_NAME_SIZE = 150;
-
- private static final int COLUMN_SIZE = 200;
-
- /**
- * the list of the elements to display in the Table
- */
- private final List<LinkEndsMapper> existingLinks;
-
-
- final UMLLabelProvider labelProvider = new UMLLabelProvider();
-
- /**
- * the string displayed when there is no value to display
- */
- private static final String NOT_AVAILABLE = "N/A"; //$NON-NLS-1$
-
- /**
- * the image to display when the link is selected
- */
- private static final String CHECKED_ICON_PATH = "icons/checkedRadioButton.gif"; //$NON-NLS-1$
-
- /**
- * the image to display when the link is not selected
- */
- private static final String UNCHECKED_ICON_PATH = "icons/uncheckedRadioButton.gif"; //$NON-NLS-1$
-
- /**
- * the index of the selected element
- */
- private int selectedElementIndex = 0;
-
- /**
- * the selected element
- */
- private EObject result = null;
-
- /**
- *
- * Constructor.
- *
- * @param dialogTitle
- * the title for the dialog
- * @param dialogMessage
- * the message for the dialog
- * @param elements
- * the list of the possible elements
- */
- public CreateOrShowExistingLinkDialog(final String dialogTitle, final String dialogMessage, final List<LinkEndsMapper> elements) {
- super(Display.getDefault().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { CREATE_STRING, RESTORE_SELECTION, CANCEL_STRING }, RESTORE_SELECTED_LINK);
- this.existingLinks = elements;
- }
-
- /**
- * Constructor.
- *
- * @param title
- * @param bound
- * @param viewer
- * @return
- */
- private TableViewerColumn createTableViewerColumn(String title, int bound, TableViewer viewer) {
- final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn column = viewerColumn.getColumn();
- column.setText(title);
- column.setWidth(bound);
- column.setResizable(false);
- column.setMoveable(false);
- return viewerColumn;
- }
-
- /**
- *
- * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
- *
- * @param parent
- * @return
- */
- @Override
- protected Control createCustomArea(final Composite parent) {
- final Composite composite = parent;
- final TableViewer viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- viewer.setContentProvider(new ArrayContentProvider());
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
-
- ViewerColumn colCheckbox = createTableViewerColumn("", 20, viewer); //$NON-NLS-1$
- colCheckbox.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- return ""; //$NON-NLS-1$
- }
-
- @Override
- public Image getImage(Object element) {
- if (existingLinks.get(selectedElementIndex) == element) {
- return Activator.getDefault().getImage(org.eclipse.papyrus.uml.diagram.common.Activator.ID, CHECKED_ICON_PATH);
- }
- return Activator.getDefault().getImage(org.eclipse.papyrus.uml.diagram.common.Activator.ID, UNCHECKED_ICON_PATH);
- }
-
- });
- colCheckbox.setEditingSupport(new EditingSupport(viewer) {
-
- private CheckboxCellEditor checkboxCellEditor;
-
- @Override
- protected void setValue(Object element, Object value) {
- if (checkboxCellEditor.getValue() == Boolean.TRUE) {
- selectedElementIndex = existingLinks.indexOf(element);
- }
- for (final LinkEndsMapper current : existingLinks) {
- viewer.update(current, null);
- }
- }
-
- @Override
- protected Object getValue(Object element) {
- return existingLinks.get(selectedElementIndex) == element;
- }
-
- @Override
- protected CellEditor getCellEditor(Object element) {
- checkboxCellEditor = new CheckboxCellEditor(parent, SWT.CHECK | SWT.READ_ONLY);
- return checkboxCellEditor;
- }
-
- @Override
- protected boolean canEdit(Object element) {
- return true;
- }
- });
- TableViewerColumn columnName = createTableViewerColumn(NAME, COLUMN_NAME_SIZE, viewer);
- configureColumn(columnName);
- columnName.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- if (element instanceof LinkEndsMapper) {
- return labelProvider.getText(((LinkEndsMapper) element).getLink());
- }
- // not possible
- return NOT_AVAILABLE;
- }
-
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
-
- });
-
- TableViewerColumn columnEnds = createTableViewerColumn(ENDS, COLUMN_SIZE, viewer);
- configureColumn(columnEnds);
- columnEnds.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- if (element instanceof LinkEndsMapper) {
- return getLabel(((LinkEndsMapper) element).getEnds());
- }
- return NOT_AVAILABLE;
- }
- });
-
-
- TableViewerColumn columnSources = createTableViewerColumn(SOURCES, COLUMN_SIZE, viewer);
- configureColumn(columnSources);
- columnSources.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- if (element instanceof LinkEndsMapper) {
- return getLabel(((LinkEndsMapper) element).getSources());
- }
- return NOT_AVAILABLE;
- }
- });
-
- TableViewerColumn columnTargets = createTableViewerColumn(TARGETS, COLUMN_SIZE, viewer);
- configureColumn(columnTargets);
- columnTargets.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- if (element instanceof LinkEndsMapper) {
- return getLabel(((LinkEndsMapper) element).getTargets());
- }
- return NOT_AVAILABLE;
- }
- });
-
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 2;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = GridData.FILL;
- viewer.getControl().setLayoutData(gridData);
- viewer.setInput(existingLinks);
- parent.pack();
- return parent;
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == RESTORE_SELECTED_LINK && this.existingLinks.size() >= this.selectedElementIndex) {
- this.result = this.existingLinks.get(this.selectedElementIndex).getLink();
- }
- super.buttonPressed(buttonId);
- }
-
- /**
- *
- * @param viewerColumn
- * the viewerColumn to configure
- */
- protected void configureColumn(final TableViewerColumn viewerColumn) {
- viewerColumn.getColumn().setMoveable(true);
- viewerColumn.getColumn().setResizable(true);
- }
-
- /**
- *
- * @param list
- * the list of the elements for which we want the label
- * @return
- * the string to display for this list
- */
- private String getLabel(final Collection<?> list) {
- if (list != null) {
- final StringBuilder builder = new StringBuilder();
- final Iterator<?> iter = list.iterator();
- while (iter.hasNext()) {
- builder.append(labelProvider.getText(iter.next()));
- if (iter.hasNext()) {
- builder.append(","); //$NON-NLS-1$
- }
- }
- return builder.toString();
- }
- return NOT_AVAILABLE;
- }
-
- /**
- *
- * @return
- * the selected link
- */
- public EObject getResult() {
- return this.result;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.dialogs;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerColumn;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.widgets.Activator;
+import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
+import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+
+
+/**
+ * This dialog is used to ask to the user if he wants create a new instance of a link, or show an existing link on the diagram
+ *
+ * @author VL222926
+ *
+ */
+public class CreateOrShowExistingLinkDialog extends MessageDialog {
+
+ /**
+ * indexes of the button
+ */
+ public static final int CREATE = Dialog.OK;
+ public static final int RESTORE_SELECTED_LINK = CREATE + 1;
+ public static final int CANCEL = RESTORE_SELECTED_LINK + 1;
+
+ /**
+ * title for the dialog
+ */
+ public static final String DIALOG_TITLE = Messages.CreateOrShowExistingLinkDialog_ShowOrCreate;
+
+ /**
+ * Message for the Buttons
+ */
+ private static final String CREATE_STRING = Messages.CreateOrShowExistingLinkDialog_Create;
+ private static final String RESTORE_SELECTION = Messages.CreateOrShowExistingLinkDialog_RestoreSelection;
+ private static final String CANCEL_STRING = "Cancel"; //$NON-NLS-1$
+
+
+ /**
+ * Titles for the columns
+ */
+ private static final String NAME = Messages.CreateOrShowExistingLinkDialog_Name;
+ private static final String ENDS = Messages.CreateOrShowExistingLinkDialog_Ends;
+ private static final String SOURCES = Messages.CreateOrShowExistingLinkDialog_Sources;
+ private static final String TARGETS = Messages.CreateOrShowExistingLinkDialog_Targets;
+ private static final String CHECKBOX_LABEL = Messages.CreateOrShowExistingElementHelper_AlwaysCreateNewLink;
+
+ /**
+ * Size for the columns
+ */
+ private static final int COLUMN_NAME_SIZE = 150;
+ private static final int COLUMN_SIZE = 200;
+
+ /**
+ * the list of the elements to display in the Table
+ */
+ private final List<LinkEndsMapper> existingLinks;
+
+ final UMLLabelProvider labelProvider = new UMLLabelProvider();
+
+ /**
+ * the string displayed when there is no value to display
+ */
+ private static final String NOT_AVAILABLE = "N/A"; //$NON-NLS-1$
+
+ /**
+ * the image to display when the link is selected
+ */
+ private static final String CHECKED_ICON_PATH = "icons/checkedRadioButton.gif"; //$NON-NLS-1$
+
+ /**
+ * the image to display when the link is not selected
+ */
+ private static final String UNCHECKED_ICON_PATH = "icons/uncheckedRadioButton.gif"; //$NON-NLS-1$
+
+ /**
+ * the index of the selected element
+ */
+ private int selectedElementIndex = 0;
+
+ /**
+ * the selected element
+ */
+ private EObject result = null;
+
+ /**
+ * The value of the toggle button of the dialog.
+ */
+ private boolean toggleState = false;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dialogTitle
+ * the title for the dialog
+ * @param dialogMessage
+ * the message for the dialog
+ * @param elements
+ * the list of the possible elements
+ */
+ public CreateOrShowExistingLinkDialog(final String dialogTitle, final String dialogMessage, final List<LinkEndsMapper> elements) {
+ super(Display.getDefault().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { CREATE_STRING, RESTORE_SELECTION, CANCEL_STRING }, RESTORE_SELECTED_LINK);
+ this.existingLinks = elements;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param title
+ * @param bound
+ * @param viewer
+ * @return
+ */
+ private TableViewerColumn createTableViewerColumn(final String title, final int bound, final TableViewer viewer) {
+ final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setWidth(bound);
+ column.setResizable(false);
+ column.setMoveable(false);
+ return viewerColumn;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ protected Control createCustomArea(final Composite parent) {
+ final Composite composite = parent;
+ final TableViewer viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ viewer.setContentProvider(new ArrayContentProvider());
+ final Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+
+ ViewerColumn colCheckbox = createTableViewerColumn("", 20, viewer); //$NON-NLS-1$
+ colCheckbox.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (existingLinks.get(selectedElementIndex) == element) {
+ return Activator.getDefault().getImage(org.eclipse.papyrus.uml.diagram.common.Activator.ID, CHECKED_ICON_PATH);
+ }
+ return Activator.getDefault().getImage(org.eclipse.papyrus.uml.diagram.common.Activator.ID, UNCHECKED_ICON_PATH);
+ }
+
+ });
+ colCheckbox.setEditingSupport(new EditingSupport(viewer) {
+
+ private CheckboxCellEditor checkboxCellEditor;
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if (checkboxCellEditor.getValue() == Boolean.TRUE) {
+ selectedElementIndex = existingLinks.indexOf(element);
+ }
+ for (final LinkEndsMapper current : existingLinks) {
+ viewer.update(current, null);
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ return existingLinks.get(selectedElementIndex) == element;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ checkboxCellEditor = new CheckboxCellEditor(parent, SWT.CHECK | SWT.READ_ONLY);
+ return checkboxCellEditor;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+ });
+ TableViewerColumn columnName = createTableViewerColumn(NAME, COLUMN_NAME_SIZE, viewer);
+ configureColumn(columnName);
+ columnName.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof LinkEndsMapper) {
+ return labelProvider.getText(((LinkEndsMapper) element).getLink());
+ }
+ // not possible
+ return NOT_AVAILABLE;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+
+ });
+
+ TableViewerColumn columnEnds = createTableViewerColumn(ENDS, COLUMN_SIZE, viewer);
+ configureColumn(columnEnds);
+ columnEnds.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof LinkEndsMapper) {
+ return getLabel(((LinkEndsMapper) element).getEnds());
+ }
+ return NOT_AVAILABLE;
+ }
+ });
+
+
+ TableViewerColumn columnSources = createTableViewerColumn(SOURCES, COLUMN_SIZE, viewer);
+ configureColumn(columnSources);
+ columnSources.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof LinkEndsMapper) {
+ return getLabel(((LinkEndsMapper) element).getSources());
+ }
+ return NOT_AVAILABLE;
+ }
+ });
+
+ TableViewerColumn columnTargets = createTableViewerColumn(TARGETS, COLUMN_SIZE, viewer);
+ configureColumn(columnTargets);
+ columnTargets.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof LinkEndsMapper) {
+ return getLabel(((LinkEndsMapper) element).getTargets());
+ }
+ return NOT_AVAILABLE;
+ }
+ });
+
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ viewer.getControl().setLayoutData(gridData);
+ viewer.setInput(existingLinks);
+ parent.pack();
+ return parent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void buttonPressed(final int buttonId) {
+ if (buttonId == RESTORE_SELECTED_LINK && this.existingLinks.size() >= this.selectedElementIndex) {
+ this.result = this.existingLinks.get(this.selectedElementIndex).getLink();
+ }
+
+ // If the user selects CREATE or RESTORE and check the toggle button, the preferences are modified
+ if ((CREATE == buttonId || RESTORE_SELECTED_LINK == buttonId) && toggleState) {
+ final IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore();
+ final String alwaysCreateLinkPreferenceName = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT);
+ store.setValue(alwaysCreateLinkPreferenceName, true);
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /**
+ *
+ * @param viewerColumn
+ * the viewerColumn to configure
+ */
+ protected void configureColumn(final TableViewerColumn viewerColumn) {
+ viewerColumn.getColumn().setMoveable(true);
+ viewerColumn.getColumn().setResizable(true);
+ }
+
+ /**
+ *
+ * @param list
+ * the list of the elements for which we want the label
+ * @return
+ * the string to display for this list
+ */
+ private String getLabel(final Collection<?> list) {
+ if (list != null) {
+ final StringBuilder builder = new StringBuilder();
+ final Iterator<?> iter = list.iterator();
+ while (iter.hasNext()) {
+ builder.append(labelProvider.getText(iter.next()));
+ if (iter.hasNext()) {
+ builder.append(","); //$NON-NLS-1$
+ }
+ }
+ return builder.toString();
+ }
+ return NOT_AVAILABLE;
+ }
+
+ /**
+ *
+ * @return
+ * the selected link
+ */
+ public EObject getResult() {
+ return this.result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ final Control createDialogArea = super.createDialogArea(parent);
+
+ if (createDialogArea instanceof Composite) {
+ createToggleButton((Composite) createDialogArea);
+ }
+
+ return createDialogArea;
+ }
+
+ /**
+ * Creates a toggle button.
+ *
+ * @param parent
+ * The composite in which the toggle button should be placed;
+ * must not be <code>null</code>.
+ * @return The added toggle button; never <code>null</code>.
+ */
+ protected Button createToggleButton(final Composite parent) {
+ final Button button = new Button(parent, SWT.CHECK | SWT.LEFT);
+ final GridData data = new GridData(SWT.NONE);
+ data.horizontalSpan = 2;
+ button.setLayoutData(data);
+ button.setFont(parent.getFont());
+ button.setText(CHECKBOX_LABEL);
+ button.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ toggleState = button.getSelection();
+ }
+
+ });
+
+ return button;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomDefaultSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomDefaultSemanticEditPolicy.java
new file mode 100644
index 00000000000..65965bf1dd6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomDefaultSemanticEditPolicy.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editpolicies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper;
+
+/**
+ * <pre>
+ * Custom semantic edit policy that replace DefaultSemanticEditPolicy
+ * in order to manage the creation of each links.
+ * </pre>
+ */
+public class CustomDefaultSemanticEditPolicy extends DefaultSemanticEditPolicy {
+
+ private CreateOrShowExistingElementHelper existingElementHelper = new CreateOrShowExistingElementHelper();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Command getCreateRelationshipCommand(final CreateRelationshipRequest req) {
+ Command defaultCommand = super.getCreateRelationshipCommand(req);
+ if ((defaultCommand.canExecute()) && (null != req.getSource()) && (null != req.getTarget())) {
+ final IElementType elementType = req.getElementType();
+ defaultCommand = this.existingElementHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
+ }
+ return defaultCommand;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
index e6ae1ae2e21..56e7aa92ad5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
@@ -1,257 +1,327 @@
-/*****************************************************************************
- * Copyright (c) 2013 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.helper;
-
-import java.util.ArrayList;
-import java.util.Collection;
-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.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.uml.diagram.common.dialogs.CreateOrShowExistingLinkDialog;
-import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
-import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- *
- * This class provides command to restore existing link instead of create new ones
- *
- *
- *
- * @author VL222926
- *
- */
-public class CreateOrShowExistingElementHelper {
-
-
- /**
- * the link helper to use. Will be used in the future
- */
- protected final ILinkMappingHelper linkMappingHelper;
-
- /**
- * preferences used to know if the dialog must be displayed or not
- */
- public static final String DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT = "Display Dialog For Create Or Restore Element"; //$NON-NLS-1$
-
- /**
- *
- * Constructor.
- *
- */
- public CreateOrShowExistingElementHelper() {
- this(new ILinkMappingHelper() {
-
- @Override
- public Collection<?> getTarget(Element link) {
- return LinkMappingHelper.getTarget(link);
- }
-
- @Override
- public Collection<?> getSource(Element link) {
- return LinkMappingHelper.getSource(link);
- }
- });
- }
-
- /**
- *
- * Constructor.
- *
- * @param linkHelper
- * the mapping helper to use to find sources and targets
- */
- public CreateOrShowExistingElementHelper(final ILinkMappingHelper linkHelper) {
- this.linkMappingHelper = linkHelper;
- }
-
- /**
- *
- * @param req
- * the create request
- * @param defaultCommand
- * the default command for this request
- * @param existingElements
- * the list of the link already existing between the source and the target for this kind of link
- * @return
- */
- public Command getCreateOrRestoreElementCommand(final CreateRelationshipRequest req, final Command defaultCommand, final IElementType linkElementType) {
- if (showDialogAccordingPreferences() && defaultCommand.canExecute()) {
- final EObject container = req.getContainer();
- if (container instanceof Element) {
- final List<LinkEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget(req, linkElementType);
- if (existingElements.size() > 0) {
- final String className = getIElementTypeNameToDisplay(linkElementType);
- final String dialogTitle = NLS.bind(Messages.CreateOrShowExistingElementHelper_CreateOrRestoreX, className);
- final String dialogMessage = NLS.bind(Messages.CreateOrShowExistingElementHelper_XBetweenTheseElementAlreadyExists, className);
- CreateOrShowExistingLinkDialog dialog = new CreateOrShowExistingLinkDialog(dialogTitle, dialogMessage, existingElements);
- return new ICommandProxy(getOpenLinkDialogCommand(req, defaultCommand, dialog, existingElements));
- }
- }
- }
- return defaultCommand;
- }
-
- /**
- *
- * @param element
- * an element
- * @param elementType
- * an element type
- * @return
- * <code>true</code> if the element has the wanted type according to the element type
- */
- protected boolean hasWantedType(final EObject element, final IElementType elementType) {
- return element.eClass() == elementType.getEClass();
- }
-
- /**
- * Returns the preferences AND Create the preference if it doesn't yet exist
- *
- * @return
- * the preference to know if a dialog must ask to the use if he wants create a new edge or restore an existing edge
- */
- protected boolean showDialogAccordingPreferences() {
- final IPreferenceStore store = org.eclipse.papyrus.uml.diagram.common.Activator.getDefault().getPreferenceStore();
- boolean contains = store.contains(DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT);
- if (!contains) {
- store.setValue(DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.ALWAYS);
- store.setDefault(DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.NEVER);
- }
- return store.getString(DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT).equals(MessageDialogWithToggle.ALWAYS);
- }
-
- /**
- *
- * @param elementType
- * an element type
- * @return
- * the element type to display in the dialog
- */
- protected String getIElementTypeNameToDisplay(final IElementType elementType) {
- return elementType.getEClass().getName();
- }
-
- /**
- *
- * @param request
- * the request to create the element
- * @param wantedEClass
- * @return
- * a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
- */
- protected List<LinkEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
- final List<LinkEndsMapper> existingElement = new ArrayList<LinkEndsMapper>();
- for (final Element current : ((Element) request.getContainer()).getOwnedElements()) {
- if (hasWantedType(current, wantedElementType)) {
- final Collection<?> sources = this.linkMappingHelper.getSource(current);
- final Collection<?> targets = this.linkMappingHelper.getTarget(current);
- if (sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
- final EClass wantedEClass = wantedElementType.getEClass();
- if ((wantedEClass == UMLPackage.eINSTANCE.getConnector()) || (wantedEClass == UMLPackage.eINSTANCE.getAssociation())) {
- existingElement.add(new LinkEndsMapper(current, sources, null, null));
- } else {
- existingElement.add(new LinkEndsMapper(current, null, sources, targets));
- }
- }
- }
- }
- return existingElement;
- }
-
- /**
- *
- * @param request
- * the request (can't be <code>null</code>)
- * @param defaultCommand
- * the default command to use to create the semantic element (can't be <code>null</code>)
- * @param dialog
- * the dialog to open (can't be <code>null</code>)
- * @param existingEObject
- * the list of the existing objects (can't be null, neither empty
- * @return
- * the command to open the dialog AND do the selected action
- */
- public static final ICommand getOpenLinkDialogCommand(final CreateRelationshipRequest request, final Command defaultCommand, final CreateOrShowExistingLinkDialog dialog, final List<LinkEndsMapper> existingEObject) {
- final AbstractTransactionalCommand compoundCommand = new AbstractTransactionalCommand(request.getEditingDomain(), "", null) { //$NON-NLS-1$
-
- /**
- *
- * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- *
- * @param monitor
- * @param info
- * @return
- * @throws ExecutionException
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- int result = dialog.open();
- switch (result) {
- case CreateOrShowExistingLinkDialog.CREATE:
- // we execute the default command
- defaultCommand.execute();
- return CommandResult.newOKCommandResult(request.getNewElement());
- case CreateOrShowExistingLinkDialog.RESTORE_SELECTED_LINK:
- final EObject selectedElement = dialog.getResult();
- if (selectedElement != null) {// must always be true
- request.setNewElement(selectedElement);
- return CommandResult.newOKCommandResult(selectedElement);
- } else {
- return CommandResult.newErrorCommandResult("The selected element in the dialog is null"); //$NON-NLS-1$
- }
- default:
- return CommandResult.newCancelledCommandResult();
- }
- }
-
- /**
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- *
- * @return
- */
- @Override
- public boolean canExecute() {
- return defaultCommand.canExecute();
- }
- };
- return compoundCommand;
- }
-
- /**
- *
- * @return
- * the link mapping helper to use
- */
- public ILinkMappingHelper getLinkMappingHelper() {
- return linkMappingHelper;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.helper;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+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.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
+import org.eclipse.papyrus.uml.diagram.common.dialogs.CreateOrShowExistingLinkDialog;
+import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
+import org.eclipse.papyrus.uml.diagram.common.util.AssociationUtil;
+import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ *
+ * This class provides command to restore existing link instead of create new ones
+ *
+ *
+ *
+ * @author VL222926
+ *
+ */
+public class CreateOrShowExistingElementHelper {
+
+
+ /**
+ * the link helper to use. Will be used in the future
+ */
+ protected final ILinkMappingHelper linkMappingHelper;
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public CreateOrShowExistingElementHelper() {
+ this(new ILinkMappingHelper() {
+
+ @Override
+ public Collection<?> getTarget(Element link) {
+ return LinkMappingHelper.getTarget(link);
+ }
+
+ @Override
+ public Collection<?> getSource(Element link) {
+ return LinkMappingHelper.getSource(link);
+ }
+ });
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param linkHelper
+ * the mapping helper to use to find sources and targets
+ */
+ public CreateOrShowExistingElementHelper(final ILinkMappingHelper linkHelper) {
+ this.linkMappingHelper = linkHelper;
+ }
+
+ /**
+ *
+ * Returns the command to restore or create a element.
+ *
+ * @param req
+ * the create request
+ * @param defaultCommand
+ * the default command for this request
+ * @param existingElements
+ * the list of the link already existing between the source and the target for this kind of link
+ * @return The command to restore or create element.
+ */
+ public Command getCreateOrRestoreElementCommand(final CreateRelationshipRequest req, final Command defaultCommand, final IElementType linkElementType) {
+ if (showDialogAccordingPreferences() && defaultCommand.canExecute()) {
+ final EObject container = req.getContainer();
+ if (container instanceof Element) {
+ final List<LinkEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget(req, linkElementType);
+ if (existingElements.size() > 0) {
+ final String className = getIElementTypeNameToDisplay(linkElementType);
+ final String dialogTitle = NLS.bind(Messages.CreateOrShowExistingElementHelper_CreateOrRestoreX, className);
+ final String dialogMessage = NLS.bind(Messages.CreateOrShowExistingElementHelper_XBetweenTheseElementAlreadyExists, className);
+ CreateOrShowExistingLinkDialog dialog = new CreateOrShowExistingLinkDialog(dialogTitle, dialogMessage, existingElements);
+ return new ICommandProxy(getOpenLinkDialogCommand(req, defaultCommand, dialog, existingElements));
+ }
+ }
+ }
+ return defaultCommand;
+ }
+
+ /**
+ *
+ * Comparison of two types.
+ *
+ * @param element
+ * an element
+ * @param elementType
+ * an element type
+ * @return
+ * <code>true</code> if the element has the wanted type according to the element type
+ */
+ protected boolean hasWantedType(final EObject element, final IElementType elementType) {
+ return element.eClass() == elementType.getEClass();
+ }
+
+ /**
+ *
+ * Returns the preferences AND Create the preference if it doesn't yet exist.
+ *
+ * @return
+ * the preference to know if a dialog must ask to the use if he wants create a new edge or restore an existing edge
+ */
+ protected boolean showDialogAccordingPreferences() {
+ boolean showDialog = true;
+ final IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore();
+ final String preferenceName = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT);
+
+ // If the store contains the preference, return the inverse of the value stored in the preferences.
+ final boolean contains = store.contains(preferenceName);
+ if (contains) {
+ showDialog = !store.getBoolean(preferenceName);
+ }
+ return showDialog;
+ }
+
+ /**
+ *
+ * Returns the name of the element type.
+ *
+ * @param elementType
+ * an element type
+ * @return
+ * the element type to display in the dialog
+ */
+ protected String getIElementTypeNameToDisplay(final IElementType elementType) {
+ return elementType.getEClass().getName();
+ }
+
+ /**
+ *
+ * Returns the value of parameter "navigable" of the request.
+ *
+ * @param source
+ * If the member tested is the source.
+ * @param request
+ * The creation relationship request.
+ * @return The value "navigable" of the member tested.
+ */
+ private boolean getExpectedNavigable(final boolean source, final CreateRelationshipRequest request) {
+ Object isAffects = null;
+ boolean expectedNavigable = false;
+
+ // Get the parameter "affects Target" to check if the target is navigable
+ if (!source) {
+ isAffects = request.getParameter(RequestParameterConstants.AFFECTS_TARGET);
+
+ if (null != isAffects && isAffects.equals(true)) {
+ expectedNavigable = true;
+ }
+ }
+
+ return expectedNavigable;
+ }
+
+ /**
+ *
+ * Returns the existing links between two objects.
+ *
+ * @param request
+ * the request to create the element
+ * @param wantedEClass
+ * @return
+ * a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
+ */
+ protected List<LinkEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
+ final List<LinkEndsMapper> existingElement = new ArrayList<LinkEndsMapper>();
+ final EClass wantedEClass = wantedElementType.getEClass();
+
+ if (UMLPackage.eINSTANCE.getAssociation().equals(wantedEClass)) {
+ for (final Element current : ((Element) request.getContainer()).getOwnedElements()) {
+ if (hasWantedType(current, wantedElementType)) {
+ final Collection<?> sources = this.linkMappingHelper.getSource(current);
+ final Collection<?> targets = this.linkMappingHelper.getTarget(current);
+ if (sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
+ boolean identicalAssociation = true;
+ final Iterator<Property> iterator = ((Association) current).getMemberEnds().iterator();
+
+ while (iterator.hasNext() && identicalAssociation) {
+ final Property property = iterator.next();
+ final boolean source = request.getSource().equals(property.getType());
+
+ boolean expectedNavigable = getExpectedNavigable(source, request);
+
+ if (!AssociationUtil.isIdenticalProperties(expectedNavigable, AggregationKind.NONE_LITERAL, property)) {
+ identicalAssociation = false;
+ }
+ }
+
+ if (identicalAssociation) {
+ existingElement.add(new LinkEndsMapper(current, sources, null, null));
+ }
+ }
+ }
+ }
+ } else {
+ for (final Element current : ((Element) request.getContainer()).getOwnedElements()) {
+ if (hasWantedType(current, wantedElementType)) {
+ final Collection<?> sources = this.linkMappingHelper.getSource(current);
+ final Collection<?> targets = this.linkMappingHelper.getTarget(current);
+ if (sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
+ if (UMLPackage.eINSTANCE.getConnector().equals(wantedEClass)) {
+ existingElement.add(new LinkEndsMapper(current, sources, null, null));
+ } else {
+ existingElement.add(new LinkEndsMapper(current, null, sources, targets));
+ }
+ }
+ }
+ }
+ }
+ return existingElement;
+ }
+
+ /**
+ *
+ * Returns the open link dialog.
+ *
+ * @param request
+ * the request (can't be <code>null</code>)
+ * @param defaultCommand
+ * the default command to use to create the semantic element (can't be <code>null</code>)
+ * @param dialog
+ * the dialog to open (can't be <code>null</code>)
+ * @param existingEObject
+ * the list of the existing objects (can't be null, neither empty
+ * @return
+ * the command to open the dialog AND do the selected action
+ */
+ public static final ICommand getOpenLinkDialogCommand(final CreateRelationshipRequest request, final Command defaultCommand, final CreateOrShowExistingLinkDialog dialog, final List<LinkEndsMapper> existingEObject) {
+ final AbstractTransactionalCommand compoundCommand = new AbstractTransactionalCommand(request.getEditingDomain(), "", null) { //$NON-NLS-1$
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ int result = dialog.open();
+ switch (result) {
+ case CreateOrShowExistingLinkDialog.CREATE:
+ // we execute the default command
+ defaultCommand.execute();
+ return CommandResult.newOKCommandResult(request.getNewElement());
+ case CreateOrShowExistingLinkDialog.RESTORE_SELECTED_LINK:
+ final EObject selectedElement = dialog.getResult();
+ if (selectedElement != null) {// must always be true
+ request.setNewElement(selectedElement);
+ return CommandResult.newOKCommandResult(selectedElement);
+ } else {
+ return CommandResult.newErrorCommandResult("The selected element in the dialog is null"); //$NON-NLS-1$
+ }
+ default:
+ return CommandResult.newCancelledCommandResult();
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
+ *
+ * @return
+ */
+ @Override
+ public boolean canExecute() {
+ return defaultCommand.canExecute();
+ }
+ };
+ return compoundCommand;
+ }
+
+ /**
+ *
+ * @return
+ * the link mapping helper to use
+ */
+ public ILinkMappingHelper getLinkMappingHelper() {
+ return linkMappingHelper;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
index 6e61c287366..e94d390daf4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.messages;
@@ -39,6 +40,8 @@ public class Messages extends NLS {
public static String CreateOrShowExistingElementHelper_XBetweenTheseElementAlreadyExists;
+ public static String CreateOrShowExistingElementHelper_AlwaysCreateNewLink;
+
public static String CreateOrShowExistingLinkDialog_Create;
public static String CreateOrShowExistingLinkDialog_Ends;
@@ -52,7 +55,7 @@ public class Messages extends NLS {
public static String CreateOrShowExistingLinkDialog_Sources;
public static String CreateOrShowExistingLinkDialog_Targets;
-
+
public static String CreateOrSelectTypeDialog_DialogTitle;
public static String CreateOrSelectTypeDialog_SelectionSectionTitle;
@@ -74,7 +77,7 @@ public class Messages extends NLS {
public static String CreateOrSelectTypeDialog_SelectNewTypeContainerDialogTitle;
public static String CreateOrSelectTypeDialog_SelectNewTypeContainerDialogMessage;
-
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
index fdda9f02625..0ced120eb38 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
@@ -1,5 +1,6 @@
CreateOrShowExistingElementHelper_CreateOrRestoreX=Create or Restore {0}
CreateOrShowExistingElementHelper_XBetweenTheseElementAlreadyExists={0} between these elements already exists in the model.\nDo you want to restore it?
+CreateOrShowExistingElementHelper_AlwaysCreateNewLink=Do not show this again. Always create a new link.
CreateOrShowExistingLinkDialog_Create=Create
CreateOrShowExistingLinkDialog_Ends=Ends
CreateOrShowExistingLinkDialog_Name=Name
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/CustomEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/CustomEditPolicyProvider.java
new file mode 100644
index 00000000000..82506653ac6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/CustomEditPolicyProvider.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.providers;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomDefaultSemanticEditPolicy;
+
+/**
+ * Edit policy provider for the editParts which used DefaultSemanticPolicy for Semantic Role.
+ */
+public class CustomEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean provides(final IOperation operation) {
+ if (operation instanceof CreateEditPoliciesOperation) {
+ final EditPart editPart = ((CreateEditPoliciesOperation) operation).getEditPart();
+ if (editPart instanceof NodeEditPart) {
+ final EditPolicy editPolicy = editPart.getEditPolicy(EditPolicyRoles.SEMANTIC_ROLE);
+ if (null != editPolicy) {
+ if (editPolicy instanceof DefaultSemanticEditPolicy) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void createEditPolicies(EditPart editPart) {
+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy());
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/AssociationUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/AssociationUtil.java
index 2a54b32ff11..887ee1f6223 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/AssociationUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/AssociationUtil.java
@@ -1,10 +1,84 @@
-package org.eclipse.papyrus.uml.diagram.common.util;
-
-import org.eclipse.uml2.uml.Property;
-
-public class AssociationUtil {
-
- public static boolean isAssociationEndProperty(Property property) {
- return property.getAssociation() != null;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.util;
+
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Property;
+
+/**
+ *
+ * An utility class to use association.
+ *
+ */
+public class AssociationUtil {
+
+ public static boolean isAssociationEndProperty(Property property) {
+ return property.getAssociation() != null;
+ }
+
+ /**
+ * This compares the Property of an Association with expected informations.
+ *
+ * @param expectedNavigable
+ * The expected navigable information.
+ * @param expectedAggregation
+ * The expected kind of aggregation.
+ * @param property
+ * The property containing the aggregation to compare.
+ * @return The result of the comparison.
+ */
+ public static boolean isIdenticalProperties(final boolean expectedNavigable, final AggregationKind expectedAggregation, final Property property) {
+ return (isIdenticalAggregations(expectedAggregation, property) && isIdenticalNavigables(expectedNavigable, property));
+ }
+
+ /**
+ * This compares the aggregation information of a Property with an expected kind of aggregation.
+ *
+ * @param expectedAggregation
+ * The expected kind of aggregation.
+ * @param property
+ * The property containing the aggregation to compare.
+ * @return The result of the comparison.
+ */
+ public static boolean isIdenticalAggregations(final AggregationKind expectedAggregation, final Property property) {
+ boolean identicalAggregation = false;
+
+ final AggregationKind aggregation = property.getAggregation();
+
+ if (expectedAggregation.equals(aggregation)) {
+ identicalAggregation = true;
+ }
+
+ return identicalAggregation;
+ }
+
+ /**
+ * This compares the navigable information of a Property with an expected navigable.
+ *
+ * @param expectedNavigable
+ * The expected navigable information.
+ * @param property
+ * The property containing the navigable information to compare.
+ * @return The result of the comparison.
+ */
+ public static boolean isIdenticalNavigables(final boolean expectedNavigable, final Property property) {
+ boolean identicalNavigable = false;
+ final boolean navigable = property.isNavigable();
+
+ if (expectedNavigable == navigable) {
+ identicalNavigable = true;
+ }
+
+ return identicalNavigable;
+ }
+}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
index c821d4b285a..18b68ef0992 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
@@ -1,76 +1,75 @@
-/*****************************************************************************
- * Copyright (c) 2011, 2014 CEA LIST and others.
- *
- * 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:
- *
- * CEA LIST - Initial API and implementation
- * Christian W. Damus (CEA) - bug 434993
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.diagram.blockdefinition.tests;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
-import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
-import org.eclipse.papyrus.sysml.diagram.blockdefinition.Activator;
-import org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.intro.IIntroPart;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-
-/**
- * Abstract Papyrus initialization class (required to get Service activation).
- */
-public abstract class AbstractTest extends AbstractPapyrusTest {
-
- @ClassRule
- public static final HouseKeeper.Static houseKeeper = new HouseKeeper.Static();
-
- public static IEditorPart editor = null;
-
- @BeforeClass
- public static void openPapyrusWithAnEmptyProject() throws Exception {
- Runnable closeIntroRunnable = new Runnable() {
-
- public void run() {
- IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
- }
- };
- PlatformUI.getWorkbench().getDisplay().syncExec(closeIntroRunnable);
-
- // Prepare new project for tests
- IProject testProject = houseKeeper.createProject("TestProject");
-
- // Copy EmptyModel from bundle to the test project
- final IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
- IFile emptyModel_no = testProject.getFile("ModelWithBDD.notation");
- IFile emptyModel_uml = testProject.getFile("ModelWithBDD.uml");
-
- emptyModel_di.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.di").openStream(), true, new NullProgressMonitor());
- emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.notation").openStream(), true, new NullProgressMonitor());
- emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.uml").openStream(), true, new NullProgressMonitor());
-
- // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- editor = houseKeeper.openPapyrusEditor(emptyModel_di);
-
- //set the preference to never for the dialog to display existing link instead of create a new one.
- final IPreferenceStore store = org.eclipse.papyrus.uml.diagram.common.Activator.getDefault().getPreferenceStore();
- boolean contains = store.contains(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT);
- if(!contains) {
- store.setValue(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.NEVER);
- store.setDefault(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.NEVER);
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2011, 2014 CEA LIST and others.
+ *
+ * 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:
+ *
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 434993
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.diagram.blockdefinition.tests;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.sysml.diagram.blockdefinition.Activator;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.intro.IIntroPart;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+
+/**
+ * Abstract Papyrus initialization class (required to get Service activation).
+ */
+public abstract class AbstractTest extends AbstractPapyrusTest {
+
+ @ClassRule
+ public static final HouseKeeper.Static houseKeeper = new HouseKeeper.Static();
+
+ public static IEditorPart editor = null;
+
+ @BeforeClass
+ public static void openPapyrusWithAnEmptyProject() throws Exception {
+ Runnable closeIntroRunnable = new Runnable() {
+
+ public void run() {
+ IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
+ PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ }
+ };
+ PlatformUI.getWorkbench().getDisplay().syncExec(closeIntroRunnable);
+
+ // Prepare new project for tests
+ IProject testProject = houseKeeper.createProject("TestProject");
+
+ // Copy EmptyModel from bundle to the test project
+ final IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
+ IFile emptyModel_no = testProject.getFile("ModelWithBDD.notation");
+ IFile emptyModel_uml = testProject.getFile("ModelWithBDD.uml");
+
+ emptyModel_di.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.di").openStream(), true, new NullProgressMonitor());
+ emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.notation").openStream(), true, new NullProgressMonitor());
+ emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.uml").openStream(), true, new NullProgressMonitor());
+
+ // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
+ editor = houseKeeper.openPapyrusEditor(emptyModel_di);
+
+ // Set the preference to never for the dialog to display existing link instead of create a new one.
+ // The activator of "org.eclipse.papyrus.sysml.diagram.blockdefinition" returns the preference store of "org.eclipse.papyrus.infra.gmfdiag.preferences".
+ final IPreferenceStore store = Activator.getInstance().getPreferenceStore();
+ final String alwaysCreateLinkPreferenceName = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT);
+ store.setValue(alwaysCreateLinkPreferenceName, true);
+ store.setDefault(alwaysCreateLinkPreferenceName, true);
+ }
+}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
index 20fd1e39909..9ca27005334 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
@@ -1,65 +1,64 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 CEA LIST and others.
- *
- * 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:
- *
- * CEA LIST - Initial API and implementation
- * Christian W. Damus (CEA) - bug 434993
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.diagram.internalblock.tests;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
-import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
-import org.eclipse.papyrus.sysml.diagram.internalblock.Activator;
-import org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper;
-import org.eclipse.ui.IEditorPart;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-
-/**
- * Abstract Papyrus initialization class (required to get Service activation).
- */
-public abstract class AbstractTest extends AbstractPapyrusTest {
-
- @ClassRule
- public static final HouseKeeper.Static houseKeeper = new HouseKeeper.Static();
-
- public static IEditorPart editor = null;
-
- @BeforeClass
- public static void openPapyrusWithAnEmptyProject() throws Exception {
- // Prepare new project for tests
- IProject testProject = houseKeeper.createProject("TestProject");
-
- // Copy EmptyModel from bundle to the test project
- final IFile emptyModel_di = testProject.getFile("ModelWithIBD.di");
- IFile emptyModel_no = testProject.getFile("ModelWithIBD.notation");
- IFile emptyModel_uml = testProject.getFile("ModelWithIBD.uml");
-
- emptyModel_di.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.di").openStream(), true, new NullProgressMonitor());
- emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.notation").openStream(), true, new NullProgressMonitor());
- emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.uml").openStream(), true, new NullProgressMonitor());
-
- // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- editor = houseKeeper.openPapyrusEditor(emptyModel_di);
-
- //set the preference to never for the dialog to display existing link instead of create a new one.
- final IPreferenceStore store = org.eclipse.papyrus.uml.diagram.common.Activator.getDefault().getPreferenceStore();
- boolean contains = store.contains(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT);
- if(!contains) {
- store.setValue(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.NEVER);
- store.setDefault(CreateOrShowExistingElementHelper.DISPLAY_DIALOG_FOR_CREATE_OR_RESTORE_ELEMENT, MessageDialogWithToggle.NEVER);
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 CEA LIST and others.
+ *
+ * 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:
+ *
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 434993
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 419357
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.diagram.internalblock.tests;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.sysml.diagram.internalblock.Activator;
+import org.eclipse.ui.IEditorPart;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+
+/**
+ * Abstract Papyrus initialization class (required to get Service activation).
+ */
+public abstract class AbstractTest extends AbstractPapyrusTest {
+
+ @ClassRule
+ public static final HouseKeeper.Static houseKeeper = new HouseKeeper.Static();
+
+ public static IEditorPart editor = null;
+
+ @BeforeClass
+ public static void openPapyrusWithAnEmptyProject() throws Exception {
+ // Prepare new project for tests
+ IProject testProject = houseKeeper.createProject("TestProject");
+
+ // Copy EmptyModel from bundle to the test project
+ final IFile emptyModel_di = testProject.getFile("ModelWithIBD.di");
+ IFile emptyModel_no = testProject.getFile("ModelWithIBD.notation");
+ IFile emptyModel_uml = testProject.getFile("ModelWithIBD.uml");
+
+ emptyModel_di.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.di").openStream(), true, new NullProgressMonitor());
+ emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.notation").openStream(), true, new NullProgressMonitor());
+ emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.uml").openStream(), true, new NullProgressMonitor());
+
+ // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
+ editor = houseKeeper.openPapyrusEditor(emptyModel_di);
+
+ // Set the preference to never for the dialog to display existing link instead of create a new one.
+ // The activator of "org.eclipse.papyrus.sysml.diagram.internalblock" returns the preference store of "org.eclipse.papyrus.infra.gmfdiag.preferences".
+ final IPreferenceStore store = Activator.getInstance().getPreferenceStore();
+ final String alwaysCreateLinkPreferenceName = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT);
+ store.setValue(alwaysCreateLinkPreferenceName, true);
+ store.setDefault(alwaysCreateLinkPreferenceName, true);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF
index ad3f3544795..176a90a1faf 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF
@@ -1,55 +1,56 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.uml.service.types,
- org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
- org.eclipse.papyrus.editor;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.diagram.common;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
- org.eclipse.uml2.uml;bundle-version="4.0.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
- org.junit;bundle-version="4.10.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.common.core,
- org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.diagram.profile;bundle-version="1.2.0",
- org.eclipse.gmf.tooling.runtime;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.papyrus.infra.emf.appearance;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
- org.eclipse.papyrus.views.modelexplorer;bundle-version="1.2.0",
- org.eclipse.xtend.lib,
- org.eclipse.xtend.lib.macro,
- org.eclipse.xtext.xbase.lib,
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.css.properties;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.2.0",
- org.eclipse.core.expressions;bundle-version="3.5.0",
- org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.ui;bundle-version="1.2.0"
-Export-Package: org.eclipse.papyrus.uml.diagram.tests.appearance,
- org.eclipse.papyrus.uml.diagram.tests.canonical,
- org.eclipse.papyrus.uml.diagram.tests.createFromPalette,
- org.eclipse.papyrus.uml.diagram.tests.delete,
- org.eclipse.papyrus.uml.diagram.tests.drop,
- org.eclipse.papyrus.uml.diagram.tests.edition,
- org.eclipse.papyrus.uml.diagram.tests.rules,
- org.eclipse.papyrus.uml.diagram.tests.synchronization
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.uml.diagram.tests.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.tests;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.uml.service.types,
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.papyrus.editor;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
+ org.eclipse.uml2.uml;bundle-version="4.0.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
+ org.eclipse.ui.ide;bundle-version="3.8.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.diagram.profile;bundle-version="1.2.0",
+ org.eclipse.gmf.tooling.runtime;bundle-version="[3.3.0,4.0.0)",
+ org.eclipse.papyrus.infra.emf.appearance;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="1.2.0",
+ org.eclipse.xtend.lib,
+ org.eclipse.xtend.lib.macro,
+ org.eclipse.xtext.xbase.lib,
+ com.google.guava;bundle-version="11.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.css.properties;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.2.0",
+ org.eclipse.core.expressions;bundle-version="3.5.0",
+ org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.2.0"
+Export-Package: org.eclipse.papyrus.uml.diagram.tests.appearance,
+ org.eclipse.papyrus.uml.diagram.tests.canonical,
+ org.eclipse.papyrus.uml.diagram.tests.createFromPalette,
+ org.eclipse.papyrus.uml.diagram.tests.delete,
+ org.eclipse.papyrus.uml.diagram.tests.drop,
+ org.eclipse.papyrus.uml.diagram.tests.edition,
+ org.eclipse.papyrus.uml.diagram.tests.rules,
+ org.eclipse.papyrus.uml.diagram.tests.synchronization
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.uml.diagram.tests.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.tests;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java
index 95cb9a395e5..766ff302022 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java
@@ -48,6 +48,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
@@ -56,8 +57,10 @@ import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
@@ -158,6 +161,12 @@ public abstract class AbstractPapyrusTestCase extends AbstractPapyrusTest {
*/
@Before
public void setUp() throws Exception {
+ // Set the preference to "true" for the dialog to display existing link instead of create a new one.
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ final String alwaysCreateLinkPreferenceName = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.RESTORE_LINK_ELEMENT);
+ store.setValue(alwaysCreateLinkPreferenceName, true);
+ store.setDefault(alwaysCreateLinkPreferenceName, true);
+
suiteState.setupTest();
}

Back to the top