Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2012-06-13 15:36:27 +0000
committerrschnekenbu2012-06-13 15:36:27 +0000
commit8c9fc1b9d6a2e0c748a291d485767c5ed6048cf1 (patch)
treea6e80a79a635f8ddde712453745879f64084ca0b
parente6515c0e9fbd79a9e820a30d7cc83c2fe4f78581 (diff)
downloadorg.eclipse.papyrus-8c9fc1b9d6a2e0c748a291d485767c5ed6048cf1.tar.gz
org.eclipse.papyrus-8c9fc1b9d6a2e0c748a291d485767c5ed6048cf1.tar.xz
org.eclipse.papyrus-8c9fc1b9d6a2e0c748a291d485767c5ed6048cf1.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 - backport of r8280 from the trunk (version 0.9.X)
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java14
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF34
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java57
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java3
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java3
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java14
6 files changed, 111 insertions, 14 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
index 92ce6b819a3..42f0bf9c811 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/provider/CustomEditPolicyProvider.java
@@ -36,12 +36,14 @@ import org.eclipse.papyrus.diagram.clazz.edit.parts.PackageEditPartCN;
import org.eclipse.papyrus.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPart;
import org.eclipse.papyrus.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPartCN;
import org.eclipse.papyrus.diagram.common.editparts.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.diagram.common.editpolicies.DuplicatePasteEditPolicy;
import org.eclipse.papyrus.diagram.common.editpolicies.HyperLinkPopupBarEditPolicy;
import org.eclipse.papyrus.diagram.common.editpolicies.NavigationEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultCreationEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultGraphicalNodeEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSemanticEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultXYLayoutEditPolicy;
+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;
@@ -53,6 +55,7 @@ import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEdi
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.common.edit.part.AbstractElementChildLabelEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementEditPart;
import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementLinkEditPart;
@@ -105,12 +108,23 @@ 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());
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
index 4ac5a53f45f..a20c865be66 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF
@@ -17,20 +17,26 @@ Export-Package: org.eclipse.papyrus.gmf.diagram.common.commands,org.ec
factory,org.eclipse.papyrus.uml.diagram.common.figure,org.eclipse.pap
yrus.uml.diagram.common.parser,org.eclipse.papyrus.uml.diagram.common
.utils
-Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.eclipse.pa
- pyrus.core;bundle-version="0.8.0",org.eclipse.emf;bundle-version="2.6
- .0",org.eclipse.uml2.uml;bundle-version="3.1.0",org.eclipse.papyrus.s
- ysml;bundle-version="0.8.0",org.eclipse.papyrus.umlutils;bundle-versi
- on="0.8.0",org.eclipse.core.expressions,org.eclipse.papyrus.diagram.c
- ommon;bundle-version="0.8.0",org.eclipse.papyrus.editor;bundle-versio
- n="0.8.0",org.eclipse.papyrus.preferences;bundle-version="0.8.0",org.
- eclipse.papyrus.sysml.edit;bundle-version="0.8.0",org.eclipse.papyrus
- .extensionpoints.editors;bundle-version="0.8.0",org.eclipse.papyrus.s
- ervice.edit;bundle-version="0.8.0",org.eclipse.papyrus.uml.service.ty
- pes;bundle-version="0.8.0",org.eclipse.papyrus.sysml.service.types;bu
- ndle-version="0.8.0",org.eclipse.papyrus.ui.toolbox;bundle-version="0
- .8.0",org.eclipse.papyrus.widgets;bundle-version="0.8.1",org.eclipse.
- papyrus.uml.modelexplorer.widgets;bundle-version="0.8.1"
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.core;bundle-version="0.8.0",
+ org.eclipse.emf;bundle-version="2.6.0",
+ org.eclipse.uml2.uml;bundle-version="3.1.0",
+ org.eclipse.papyrus.sysml;bundle-version="0.8.0",
+ org.eclipse.papyrus.umlutils;bundle-version="0.8.0",
+ org.eclipse.core.expressions,
+ org.eclipse.papyrus.diagram.common;bundle-version="0.8.0",
+ org.eclipse.papyrus.editor;bundle-version="0.8.0",
+ org.eclipse.papyrus.preferences;bundle-version="0.8.0",
+ org.eclipse.papyrus.sysml.edit;bundle-version="0.8.0",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="0.8.0",
+ org.eclipse.papyrus.service.edit;bundle-version="0.8.0",
+ org.eclipse.papyrus.uml.service.types;bundle-version="0.8.0",
+ org.eclipse.papyrus.sysml.service.types;bundle-version="0.8.0",
+ org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0",
+ org.eclipse.papyrus.widgets;bundle-version="0.8.1",
+ org.eclipse.papyrus.uml.modelexplorer.widgets;bundle-version="0.8.1",
+ org.eclipse.papyrus.pastemanager;bundle-version="0.8.2"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.8.2.qualifier
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/CustomDuplicatePasteEditPolicy.java b/plugins/sysml/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..db45069a653
--- /dev/null
+++ b/plugins/sysml/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.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
+
+
+/**
+ * Specific edit policy for compartment, to forbid the duplication of ports as affixed children.
+ * [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/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
index 76c89240e1f..927b791fc38 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/BlockPropertyStructureCompartmentEditPart.java
@@ -14,6 +14,8 @@
package org.eclipse.papyrus.sysml.diagram.common.edit.part;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractShapeCompartmentEditPart;
public class BlockPropertyStructureCompartmentEditPart extends AbstractShapeCompartmentEditPart {
@@ -28,6 +30,7 @@ public class BlockPropertyStructureCompartmentEditPart extends AbstractShapeComp
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
// Start of user code custom edit policies
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
// End of user code
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
index 7e4ef9d9002..14644252428 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/edit/part/StructureCompartmentEditPart.java
@@ -15,6 +15,8 @@ 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.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+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;
@@ -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/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
index d8a7c06dfde..aaf518da676 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/provider/CustomEditPolicyProvider.java
@@ -20,6 +20,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
+import org.eclipse.papyrus.diagram.common.editpolicies.DuplicatePasteEditPolicy;
import org.eclipse.papyrus.diagram.common.editpolicies.NavigationEditPolicy;
import org.eclipse.papyrus.diagram.composite.edit.parts.CommentEditPart;
import org.eclipse.papyrus.diagram.composite.edit.parts.CommentEditPartCN;
@@ -33,6 +34,8 @@ import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyComposite
import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyStructureCompartmentEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart;
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;
import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockPropertyCompositeSemanticEditPolicy;
@@ -90,12 +93,23 @@ public class CustomEditPolicyProvider extends InternalBlockDiagramEditPolicyProv
return true;
}
+ // provides for the main diagram edit part
+ if(gep instanceof InternalBlockDiagramEditPart) {
+ return true;
+ }
+
return super.provides(operation);
}
public void createEditPolicies(EditPart editPart) {
super.createEditPolicies(editPart);
+ if(editPart instanceof InternalBlockDiagramEditPart) {
+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy());
+ // no installation of other policies.
+ return;
+ }
+
editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy());
editPart.installEditPolicy(EditPolicyRoles.OPEN_ROLE, new NavigationEditPolicy());

Back to the top