Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2012-06-12 18:15:26 +0000
committerrschnekenbu2012-06-12 18:15:26 +0000
commit309ebac0d347a3f8254a813f10b7d67a25988dc7 (patch)
tree245f3e5d535bc1e3eb210c092d420012cb8b7b04 /plugins
parent2a0bb72e089ece0703d085a6625fe8ab9f7ed641 (diff)
downloadorg.eclipse.papyrus-309ebac0d347a3f8254a813f10b7d67a25988dc7.tar.gz
org.eclipse.papyrus-309ebac0d347a3f8254a813f10b7d67a25988dc7.tar.xz
org.eclipse.papyrus-309ebac0d347a3f8254a813f10b7d67a25988dc7.zip
375041: [SysML Block Definition Diagram] Copy/paste of a flowport from the border into the structure compartment leads to bogus port symbol and corrupted diagram
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375041 - adding a new edit policy for duplication, which tests that the ports should not be duplicable. This should also be done in UML diagrams. Even better, the copy or duplication should test if the element can be displayed in the diagram. The graphical edit policy should be asked for a hint. - adding this policy using edit policy provider for diagram edit parts. - specifying in custom code for compartments.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java16
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java57
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java3
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java3
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java12
6 files changed, 90 insertions, 4 deletions
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 f15efefe162..5490554cdf8 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
@@ -24,6 +24,7 @@ import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultGraphicalNodeEd
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSemanticEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultXYLayoutEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.policy.CustomBlockCompositeSemanticEditPolicy;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.policy.CustomDefaultSemanticEditPolicy;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.policy.CustomDiagramDragDropEditPolicy;
@@ -34,6 +35,7 @@ import org.eclipse.papyrus.sysml.diagram.common.edit.part.DimensionEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowSpecificationEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.UnitEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.ValueTypeEditPart;
+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.CommentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.CommentEditPartCN;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ConstraintEditPart;
@@ -63,6 +65,7 @@ import org.eclipse.papyrus.uml.diagram.common.edit.part.InterfaceRealizationEdit
import org.eclipse.papyrus.uml.diagram.common.edit.part.PrimitiveTypeEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.SignalEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.UsageEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.NavigationEditPolicy;
/**
@@ -102,12 +105,22 @@ public class CustomEditPolicyProvider extends BlockDefinitionDiagramEditPolicyPr
return true;
}
+ if(gep instanceof BlockDefinitionDiagramEditPart) {
+ return true;
+ }
+
return super.provides(operation);
}
public void createEditPolicies(EditPart editPart) {
super.createEditPolicies(editPart);
+ if(editPart instanceof BlockDefinitionDiagramEditPart) {
+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
+ // no installation of other policies.
+ return;
+ }
+
editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy());
editPart.installEditPolicy(EditPolicyRoles.OPEN_ROLE, new NavigationEditPolicy());
@@ -117,6 +130,7 @@ public class CustomEditPolicyProvider extends BlockDefinitionDiagramEditPolicyPr
editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
editPart.installEditPolicy(NavigationEditPolicy.NAVIGATION_POLICY, new NavigationEditPolicy());
editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new DefaultXYLayoutEditPolicy());
+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
}
@@ -125,6 +139,7 @@ public class CustomEditPolicyProvider extends BlockDefinitionDiagramEditPolicyPr
editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
editPart.installEditPolicy(NavigationEditPolicy.NAVIGATION_POLICY, new NavigationEditPolicy());
editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new DefaultXYLayoutEditPolicy());
+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
}
@@ -237,5 +252,6 @@ public class CustomEditPolicyProvider extends BlockDefinitionDiagramEditPolicyPr
if(editPart instanceof InterfaceRealizationEditPart) {
editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy());
}
+
}
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
index 3a5d83fbf55..ce02e3c95ba 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.uml.tools;bundle-version="0.9.0",
org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.emf.appearance;bundle-version="0.9.0"
+ org.eclipse.papyrus.infra.emf.appearance;bundle-version="0.9.0",
+ org.eclipse.papyrus.uml.pastemanager;bundle-version="0.9.0"
Export-Package: org.eclipse.papyrus.gmf.diagram.common.commands,
org.eclipse.papyrus.gmf.diagram.common.compatibility,
org.eclipse.papyrus.gmf.diagram.common.edit.part,
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java
new file mode 100644
index 00000000000..8921a3807e6
--- /dev/null
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.diagram.common.edit.policy;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DuplicateRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
+
+
+/**
+ * Specific edit policy for compartment, to forbid the duplication of ports as affixed children.
+ * @see bug 375041
+ */
+public class CustomDuplicatePasteEditPolicy extends DuplicatePasteEditPolicy {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Command constructDuplicationCommand(List notationViewsToDuplicate, Set elementsToDuplicate, DuplicateRequest request, TransactionalEditingDomain editingDomain) {
+ if(notationViewsToDuplicate !=null && !notationViewsToDuplicate.isEmpty()) {
+ for(Object o : notationViewsToDuplicate) {
+ if(o instanceof View) {
+ String type = ((View)o).getType();
+ if(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID.equals(type) || UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID.equals(type)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ }
+ }
+ }
+
+
+ return super.constructDuplicationCommand(notationViewsToDuplicate, elementsToDuplicate, request, editingDomain);
+ }
+
+}
+
+ \ No newline at end of file
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
index 9cb2bd99c95..772702b9597 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
@@ -16,7 +16,9 @@ package org.eclipse.papyrus.sysml.diagram.common.edit.part;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.sysml.diagram.common.edit.policy.BlockPropertyStructureCompartmentSemanticEditPolicy;
+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractShapeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
public class BlockPropertyStructureCompartmentEditPart extends AbstractShapeCompartmentEditPart {
@@ -31,6 +33,7 @@ public class BlockPropertyStructureCompartmentEditPart extends AbstractShapeComp
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new BlockPropertyStructureCompartmentSemanticEditPolicy());
// Start of user code custom edit policies
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
// End of user code
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
index 7e4ef9d9002..88aee1412b1 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
@@ -15,8 +15,10 @@ package org.eclipse.papyrus.sysml.diagram.common.edit.part;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy;
import org.eclipse.papyrus.sysml.diagram.common.edit.policy.StructureCompartmentSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractShapeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
public class StructureCompartmentEditPart extends AbstractShapeCompartmentEditPart {
@@ -31,6 +33,7 @@ public class StructureCompartmentEditPart extends AbstractShapeCompartmentEditPa
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StructureCompartmentSemanticEditPolicy());
// Start of user code custom edit policies
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
// End of user code
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
index 381dbcd9f85..e5e7c17f0da 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
@@ -29,6 +29,7 @@ import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyStructure
import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.NestedBlockPropertyCompositeEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart;
+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy;
import org.eclipse.papyrus.sysml.diagram.internalblock.edit.part.InternalBlockDiagramEditPart;
import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockCompositeSemanticEditPolicy;
import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockPropertyCompositeDropEditPolicy;
@@ -47,6 +48,7 @@ import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementLinkEditP
import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.DependencyEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.NavigationEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPartCN;
@@ -100,6 +102,13 @@ public class CustomEditPolicyProvider extends InternalBlockDiagramEditPolicyProv
public void createEditPolicies(EditPart editPart) {
super.createEditPolicies(editPart);
+ if(editPart instanceof InternalBlockDiagramEditPart) {
+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDropEditPolicy());
+ // no installation of other policies.
+ return;
+ }
+
editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy());
editPart.installEditPolicy(NavigationEditPolicy.NAVIGATION_POLICY, new NavigationEditPolicy());
@@ -158,9 +167,6 @@ public class CustomEditPolicyProvider extends InternalBlockDiagramEditPolicyProv
editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy());
}
- if(editPart instanceof InternalBlockDiagramEditPart) {
- editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDropEditPolicy());
- }
}
}

Back to the top