Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-02-18 04:24:18 -0500
committerCamille Letavernier2015-02-18 04:52:10 -0500
commitbb4df6d969ec69fb5a951e7f7baaaf6c66870054 (patch)
treecdf211ce801b64054450b756101b31f4ea08252c
parent9d3d18039a0b9f4cdbe0f3465f9789d953a6c452 (diff)
downloadorg.eclipse.papyrus-bb4df6d969ec69fb5a951e7f7baaaf6c66870054.tar.gz
org.eclipse.papyrus-bb4df6d969ec69fb5a951e7f7baaaf6c66870054.tar.xz
org.eclipse.papyrus-bb4df6d969ec69fb5a951e7f7baaaf6c66870054.zip
Revert "Bug 447641 - [SysML BDD] Cannot create associations between
instances" This reverts commit b27ae06f180ca83754b9354050373eedb3019b2e. - Revert the Instance Specification Link improvements to avoid regressions on Luna SR2
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/icons/obj16/InstanceLink.gifbin93 -> 0 bytes
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/palettes/blockdefinition.palette.associations.xml4
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/plugin.xml12
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/factory/DiagramPaletteFactory.java2
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomGraphicalTypeRegistry.java4
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/ElementTypes.java11
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/GraphicalTypeRegistry.java1
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/InheritedClassDiagramEditPartProvider.java4
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/edit/policy/CustomDiagramDragDropEditPolicy.java260
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java1
10 files changed, 5 insertions, 294 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/icons/obj16/InstanceLink.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/icons/obj16/InstanceLink.gif
deleted file mode 100644
index d9712d1dad7..00000000000
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/icons/obj16/InstanceLink.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/palettes/blockdefinition.palette.associations.xml b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/palettes/blockdefinition.palette.associations.xml
index 51548e1734c..2c9e99aefa1 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/palettes/blockdefinition.palette.associations.xml
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/palettes/blockdefinition.palette.associations.xml
@@ -28,10 +28,6 @@
<aspectTool description="Create a new DirectedAggregation" id="blockdefinition_associations.tool.association_shared_directed"
name="DirectedAggregation" refToolId="blockdefinition.tool.association_shared_directed">
</aspectTool>
-
- <aspectTool description="Create a new InstanceSpecificationLink" id="blockdefinition_associations.tool.instance_specification_link"
- name="InstanceSpecificationLink" refToolId="blockdefinition.tool.instance_specification_link">
- </aspectTool>
</drawer>
</content>
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/plugin.xml b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/plugin.xml
index 2e371f0c226..410f1b4a6b4 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/plugin.xml
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/plugin.xml
@@ -390,18 +390,6 @@
large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Association.gif"
small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Association.gif">
</entry>
-
- <!-- blockdefinition.tool.instance_specification_link -->
- <entry
- defineOnly="true"
- description="Create an InstanceSpecification link"
- id="blockdefinition.tool.instance_specification_link"
- kind="tool"
- label="InstanceSpecification link"
- path=""
- large_icon="icons/obj16/InstanceLink.gif"
- small_icon="icons/obj16/InstanceLink.gif">
- </entry>
<!-- blockdefinition.tool.dependency -->
<entry
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/factory/DiagramPaletteFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/factory/DiagramPaletteFactory.java
index 3d2bfe8cbf1..bc15d2be9ca 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/factory/DiagramPaletteFactory.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/factory/DiagramPaletteFactory.java
@@ -91,8 +91,6 @@ public class DiagramPaletteFactory extends PaletteFactory.Adapter {
put("blockdefinition.tool.comment_constraint_link", new IElementType[] { ElementTypes.COMMENT_ANNOTATED_ELEMENT, ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT });
- put("blockdefinition.tool.instance_specification_link", new IElementType[] { ElementTypes.INSTANCE_SPECIFICATION_LINK });
-
// End of user code
}
};
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomGraphicalTypeRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomGraphicalTypeRegistry.java
index cbaf713b4ba..7144cc98dfc 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomGraphicalTypeRegistry.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomGraphicalTypeRegistry.java
@@ -806,10 +806,6 @@ public class CustomGraphicalTypeRegistry extends GraphicalTypeRegistry {
if (UMLElementTypes.GENERALIZATION.getEClass().isInstance(domainElement)) {
return UMLGraphicalTypes.LINK_UML_GENERALIZATION_ID;
}
- if (UMLElementTypes.INSTANCE_SPECIFICATION.getEClass().isInstance(domainElement)) {
- return ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint();
- }
-
return super.getEdgeGraphicalType(domainElement);
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/ElementTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/ElementTypes.java
index 05bf715fe09..3de817da6d2 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/ElementTypes.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/ElementTypes.java
@@ -14,7 +14,6 @@
package org.eclipse.papyrus.sysml.diagram.blockdefinition.provider;
import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeEnumerator;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
public class ElementTypes extends AbstractElementTypeEnumerator {
@@ -65,9 +64,6 @@ public class ElementTypes extends AbstractElementTypeEnumerator {
/** ClassDiagram :: INSTANCE_SPECIFICATION */
public static final IHintedType INSTANCE_SPECIFICATION = (IHintedType) getElementType("org.eclipse.papyrus.uml.diagram.clazz.InstanceSpecification_2001"); //$NON-NLS-1$
- /** ClassDiagram :: INSTANCE_SPECIFICATION_LINK */
- public static final IHintedType INSTANCE_SPECIFICATION_LINK = (IHintedType) getElementType("org.eclipse.papyrus.uml.diagram.clazz.InstanceSpecificationLink_4021"); //$NON-NLS-1$
-
public static final String INSTANCE_SPECIFICATION_COMPARTMENT_SLOT_HINT = "7001"; //$NON-NLS-1$
public static final String INSTANCE_SPECIFICATION_LABEL_NAME_HINT = "5002"; //$NON-NLS-1$
@@ -113,11 +109,4 @@ public class ElementTypes extends AbstractElementTypeEnumerator {
/** ClassDiagram :: ChildLabelNodes */
public static final IHintedType INSTANCE_SPECIFICATION_SLOT_CLN = (IHintedType) getElementType("org.eclipse.papyrus.uml.diagram.clazz.Slot_3030"); //$NON-NLS-1$
-
- public static IElementType getElementTypeByID(String visualID) {
- if (ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint().equalsIgnoreCase(visualID)) {
- return ElementTypes.INSTANCE_SPECIFICATION_LINK;
- }
- return null;
- }
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/GraphicalTypeRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/GraphicalTypeRegistry.java
index 8aaeab46461..0c4d5755417 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/GraphicalTypeRegistry.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/GraphicalTypeRegistry.java
@@ -43,7 +43,6 @@ public class GraphicalTypeRegistry implements IGraphicalTypeRegistry {
// Fill known edges set
knownEdges.add(ElementTypes.COMMENT_ANNOTATED_ELEMENT.getSemanticHint());
knownEdges.add(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT.getSemanticHint());
- knownEdges.add(ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint());
// Fill known nodes set (primary nodes)
knownNodes.add(UMLElementTypes.MODEL.getSemanticHint());
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/InheritedClassDiagramEditPartProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/InheritedClassDiagramEditPartProvider.java
index f361f5be524..c48b5404d86 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/InheritedClassDiagramEditPartProvider.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/InheritedClassDiagramEditPartProvider.java
@@ -19,10 +19,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.providers.CustomUMLEditPartProvider;
+import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLEditPartProvider;
import org.eclipse.papyrus.uml.diagram.common.edit.part.SlotChildLabelEditPart;
-public class InheritedClassDiagramEditPartProvider extends CustomUMLEditPartProvider {
+public class InheritedClassDiagramEditPartProvider extends UMLEditPartProvider {
@Override
public synchronized boolean provides(IOperation operation) {
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/edit/policy/CustomDiagramDragDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/edit/policy/CustomDiagramDragDropEditPolicy.java
index 2aea40789da..c3ee977720e 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/edit/policy/CustomDiagramDragDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/edit/policy/CustomDiagramDragDropEditPolicy.java
@@ -13,32 +13,14 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.policy;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
+import java.util.Collections;
import java.util.Set;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
-import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CommonDiagramDragDropEditPolicy;
@@ -46,16 +28,9 @@ import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.dnd.helper.CustomLinkMappingHelper;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.messages.Messages;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.provider.CustomGraphicalTypeRegistry;
-import org.eclipse.papyrus.sysml.diagram.blockdefinition.provider.ElementTypes;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.InstanceSpecificationLinkHelper;
-import org.eclipse.papyrus.uml.diagram.common.commands.CommonDeferredCreateConnectionViewCommand;
-import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.AssociationClass;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.InstanceSpecification;
-import org.eclipse.uml2.uml.TypedElement;
/**
* Custom diagram drag drop edit policy for elements handling drop in the Block Definition Diagram.
@@ -73,53 +48,7 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
*/
@Override
protected Set<String> getSpecificDropBehaviorTypes() {
- Set<String> result = new HashSet<String>();
- result.add(ElementTypes.INSTANCE_SPECIFICATION.getSemanticHint());
- result.add(ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint());
- return result;
- }
-
- @Override
- protected ICommand getSpecificDropCommand(DropObjectsRequest dropRequest, EObject droppedEObject, String nodeType, String edgeType) {
- if (ElementTypes.INSTANCE_SPECIFICATION.getSemanticHint().equalsIgnoreCase(nodeType) ||
- ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint().equalsIgnoreCase(edgeType)) {
- return new CommandProxy(dropInstanceSpecification(dropRequest, droppedEObject));
- }
- return super.getSpecificDropCommand(dropRequest, droppedEObject, nodeType, edgeType);
- }
-
- /**
- * drop a instance specification as a link or as a node
- *
- * @param dropRequest
- * the drop request
- * @param droppedEObject
- * the element
- * @param edgeType
- * the edge type
- * @return the command in charge of the drop
- */
- protected Command dropInstanceSpecification(DropObjectsRequest dropRequest, EObject droppedEObject) {
- if (false == droppedEObject instanceof InstanceSpecification) {
- return UnexecutableCommand.INSTANCE;
- }
- if (((InstanceSpecification) droppedEObject).getClassifiers().size() > 0) {
- if (((InstanceSpecification) droppedEObject).getClassifiers().get(0) instanceof Association) {
- // DROP AS LINK
- List<InstanceSpecification> endTypes = InstanceSpecificationLinkHelper.getEnds(((InstanceSpecification) droppedEObject));
- if (endTypes.size() > 0) {
- Element source = endTypes.get(0);
- Element target = endTypes.get(1);
- return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop InstanceSpecification link"), source, target, ElementTypes.INSTANCE_SPECIFICATION_LINK.getSemanticHint(), dropRequest.getLocation(), (Element) droppedEObject));
- }
- }
- }
- // DROP AS A NODE
- // drop into diagram
- if (getHost().getModel() instanceof Diagram) {
- return new ICommandProxy(getDefaultDropNodeCommand(ElementTypes.INSTANCE_SPECIFICATION.getSemanticHint(), dropRequest.getLocation(), droppedEObject));
- }
- return UnexecutableCommand.INSTANCE;
+ return Collections.emptySet();
}
/**
@@ -137,189 +66,4 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
return super.getUnknownDropCommand(dropRequest, droppedEObject);
}
-
- /**
- * the method provides command to create the binary link into the diagram.
- * If the source and the target views do not exist, these views will be
- * created.
- *
- * @param cc
- * the composite command that will contain the set of command to
- * create the binary link
- * @param source
- * the source the element source of the link
- * @param target
- * the target the element target of the link
- * @param edgeType
- * the edge type used to create the view
- * @param location
- * the location the location where the view will be be created
- * @param semanticLink
- * the semantic link that will be attached to the view
- *
- * @return the composite command
- */
- protected CompositeCommand dropBinaryLink(CompositeCommand cc, Element source, Element target, String edgeType, Point absoluteLocation, Element semanticLink) {
- IAdaptable sourceViewAdapter = findAdapter(cc, source, getLinkSourceDropLocation(absoluteLocation, source, target), edgeType);
- IAdaptable targetViewAdapter = findAdapter(cc, target, getLinkTargetDropLocation(absoluteLocation, source, target), edgeType);
-
- CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(getElementType(edgeType, semanticLink), edgeType, getDiagramPreferencesHint());
- CommonDeferredCreateConnectionViewCommand createConnectionViewCommand = new CommonDeferredCreateConnectionViewCommand(getEditingDomain(), edgeType, sourceViewAdapter, targetViewAdapter, getViewer(), getDiagramPreferencesHint(), linkdescriptor, null);
- createConnectionViewCommand.setElement(semanticLink);
- cc.compose(createConnectionViewCommand);
- return cc;
- }
-
- /**
- * {@inheritDoc}
- */
- protected IAdaptable getElementType(String elementID, Element semanticLink) {
- IElementType result = ElementTypes.getElementTypeByID(elementID);
- return result == null ? new SemanticAdapter(semanticLink, null) : result;
- }
-
- /**
- * This method allows to specify a location for the creation of a node at
- * the source of a dropped link. Overriding implementations must not modify
- * the absoluteLocation parameter (use {@link Point#getCopy()})
- *
- * @param absoluteLocation
- * the request's drop location
- * @param source
- * the source of the dropped link
- * @param target
- * the target of the dropped link
- * @return the new location for the node
- */
- protected Point getLinkSourceDropLocation(Point absoluteLocation, Element source, Element target) {
- return absoluteLocation;
- }
-
- /**
- * This method allows to specify a location for the creation of a node at
- * the target of a dropped link. Overriding implementations must not modify
- * the absoluteLocation parameter (use {@link Point#getCopy()})
- *
- * @param absoluteLocation
- * the request's drop location
- * @param source
- * the source of the dropped link
- * @param target
- * the target of the dropped link
- * @return the new location for the node
- */
- protected Point getLinkTargetDropLocation(Point absoluteLocation, Element source, Element target) {
- if (lookForEditPart(source) == null && lookForEditPart(target) == null) {
- return absoluteLocation.getTranslated(100, 0);
- }
- return absoluteLocation;
- }
-
- /**
- * the method provides command to create the binary link into the diagram.
- * Find source/target adapter
- * If the source and the target views do not exist, these views will be
- * created.
- *
- * @see dropBinaryLink(CompositeCommand cc, Element source, Element target, int linkVISUALID
- * , Point absoluteLocation, Element semanticLink)
- *
- * @param cc
- * the composite command that will contain the set of command to
- * create the binary link
- * @param source
- * source/target link node
- * @param point
- * source/target node location
- */
- private IAdaptable findAdapter(CompositeCommand cc, Element source, Point dropLocation, String edgeType) {
- GraphicalEditPart editPart = (GraphicalEditPart) lookForEditPart(source);
- if (editPart != null) {
- return new SemanticAdapter(null, editPart.getModel());
- }
- ICommand createCommand = getDefaultDropNodeCommand(edgeType, dropLocation, source);
- cc.add(createCommand);
- return (IAdaptable) createCommand.getCommandResult().getReturnValue();
- }
-
- /**
- * {@inheritDoc}
- */
- protected EditPart lookForEditPart(EObject semantic) {
- return lookForEditPart(semantic, false);
- }
-
- /**
- * Look for editPart from his semantic.
- *
- * @param semantic
- * the semantic
- *
- * @return the edits the part or null if not found
- */
- protected EditPart lookForEditPart(EObject semantic, boolean byType) {
- Collection<EditPart> editPartSet = getHost().getViewer().getEditPartRegistry().values();
- Iterator<EditPart> editPartIterator = editPartSet.iterator();
- while (editPartIterator.hasNext()) {
- EditPart nextEditPart = editPartIterator.next();
- if (false == isEditPartTypeAdapted(nextEditPart.getClass(), semantic.eClass())) {
- continue;
- }
- EObject nextSemantic = ((GraphicalEditPart) nextEditPart).resolveSemanticElement();
- if (semantic.equals(nextSemantic)) {
- return nextEditPart;
- }
- if (byType && nextSemantic instanceof TypedElement && ((TypedElement) nextSemantic).getType() != null) {
- EObject nextSemanticType = ((TypedElement) nextSemantic).getType();
- if (semantic.equals(nextSemanticType)) {
- return nextEditPart;
- }
- }
- }
- return null;
- }
-
- /**
- * Check if the edit part type is the best one to represent an object of the
- * given EClass type
- *
- * @param editPartClass
- * the type of EditPart which may represent a semantic element
- * @param eClass
- * the EClass type of the represented semantic element
- * @return true if an edit part of this type should be selected
- */
- private boolean isEditPartTypeAdapted(Class<? extends EditPart> editPartClass, EClass eClass) {
- if (DiagramEditPart.class.isAssignableFrom(editPartClass) || CompartmentEditPart.class.isAssignableFrom(editPartClass)) {
- // the edit part is disqualified, as a compartment or a diagram can
- // not be dropped
- return false;
- } else if (GraphicalEditPart.class.isAssignableFrom(editPartClass)) {
- // check the edit part type against advised ones
- return isEditPartTypeSuitableForEClass(editPartClass.asSubclass(GraphicalEditPart.class), eClass);
- } else {
- // only a GraphicalEditPart must be selected
- return false;
- }
- }
-
- /**
- * Check if an edit part type correctly represent a semantic element of the
- * given EClass. Subclasses should implement this method to restrict the
- * possibilities during drop of a link. If an edit part is not of a suitable
- * type, returning false will eliminate it to represent the element as a
- * source or target edit part. This can be used for example to disable label
- * edit parts, which may represent the same model element as the main node.
- *
- * @param editPartClass
- * the type of EditPart which must be checked
- * @param eClass
- * the EClass type of the element which the edit part must
- * represent
- * @return the only edit part type which can be selected (return a common
- * super type if several edit parts can be chosen)
- */
- protected boolean isEditPartTypeSuitableForEClass(Class<? extends GraphicalEditPart> editPartClass, EClass eClass) {
- return true;
- }
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
index 67749b4e3a2..7055680c86c 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
@@ -159,6 +159,7 @@ public class CustomEditPolicyProvider extends BlockDefinitionDiagramEditPolicyPr
}
if ((editPart instanceof InstanceSpecificationEditPart) || (editPart instanceof InstanceSpecificationEditPartCN)) {
+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy());
editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
editPart.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy());
}

Back to the top