Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorytanguy2012-02-23 10:05:41 -0500
committerytanguy2012-02-23 10:05:41 -0500
commit44ec0009add487beafc98b99b3b78f761b57f250 (patch)
tree693f2489e0eb3278c684082e2b643beee2e245e7 /plugins
parentc929e2d8501806481527012d3eb1fb8ba4c5953a (diff)
downloadorg.eclipse.papyrus-44ec0009add487beafc98b99b3b78f761b57f250.tar.gz
org.eclipse.papyrus-44ec0009add487beafc98b99b3b78f761b57f250.tar.xz
org.eclipse.papyrus-44ec0009add487beafc98b99b3b78f761b57f250.zip
ASSIGNED - bug 370854: [SysML Block Definition Diagram] Exception raised when drawing a directed composition from a block to another association
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370854 ASSIGNED - bug 348651: [SysML Block Definition Diagram] Forbidden Association creation involving Actor is not detected before creation https://bugs.eclipse.org/bugs/show_bug.cgi?id=348651 Merged from branch 0.8
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java3
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/plugin.xml14
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java70
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java34
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java78
5 files changed, 197 insertions, 2 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java
index 50962be7d97..8ca3e9494f4 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java
@@ -21,7 +21,6 @@ import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
@@ -34,7 +33,7 @@ import org.eclipse.papyrus.uml.diagram.common.figure.EdgeDecorationType;
* Abstract non-diagram specific edit part for links.
* This class is adapted from edit parts generated by GMF Tooling.
*/
-public abstract class AbstractElementLinkEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
+public abstract class AbstractElementLinkEditPart extends UMLConnectionNodeEditPart {
/**
* Constructor.
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/plugin.xml b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/plugin.xml
index ac0029d5535..b7249772164 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/plugin.xml
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/plugin.xml
@@ -406,7 +406,19 @@
class="org.eclipse.papyrus.sysml.service.types.helper.advice.PropertyEditHelperAdvice"
inheritance="all" typeId="org.eclipse.papyrus.uml.Property">
</adviceBinding>
+
+ <!-- Helper advice for Package (Manage SysML association creation: do not target association, actor if not directed association, etc) -->
+ <adviceBinding id="org.eclipse.papyrus.sysml.advice.Package"
+ class="org.eclipse.papyrus.sysml.service.types.helper.advice.PackageEditHelperAdvice"
+ inheritance="all" typeId="org.eclipse.papyrus.uml.Package">
+ </adviceBinding>
+ <!-- Helper advice for Actor (Manage SysML association creation: do not get out of an actor -->
+ <adviceBinding id="org.eclipse.papyrus.sysml.advice.Actor"
+ class="org.eclipse.papyrus.sysml.service.types.helper.advice.ActorEditHelperAdvice"
+ inheritance="all" typeId="org.eclipse.papyrus.uml.Actor">
+ </adviceBinding>
+
</metamodel>
</extension>
@@ -457,6 +469,8 @@
<advice ref="org.eclipse.papyrus.sysml.advice.ConstraintBlockPropertyHelperAdvice" />
<advice ref="org.eclipse.papyrus.sysml.advice.Classifier" />
<advice ref="org.eclipse.papyrus.sysml.advice.Property" />
+ <advice ref="org.eclipse.papyrus.sysml.advice.Package" />
+ <advice ref="org.eclipse.papyrus.sysml.advice.Actor" />
</binding>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java
new file mode 100644
index 00000000000..219363b33e4
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.helper.advice;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.uml2.uml.Actor;
+import org.eclipse.uml2.uml.Association;
+
+
+/**
+ * Advice to restrict {@link Association} creation in SysML
+ */
+public class ActorEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * {@inheritDoc}
+ *
+ * In case of {@link Association} creation, it should not be possible to have an {@link Actor} as source.
+ */
+ @Override
+ protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
+ IElementType type = request.getElementType();
+ if(SysMLElementTypes.ASSOCIATION.equals(type)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if(type != null) {
+ List<IElementType> superTypes = Arrays.asList(type.getAllSuperTypes());
+ if(superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ }
+ return super.getBeforeCreateRelationshipCommand(request);
+ }
+
+ protected boolean hasSuperType(IElementType elementType, IElementType typeToTest) {
+ if(elementType == null || typeToTest == null) {
+ return false;
+ }
+
+ if(elementType.equals(typeToTest)) {
+ return true;
+ }
+
+ List<IElementType> superTypes = Arrays.asList(elementType.getAllSuperTypes());
+ if(superTypes.contains(typeToTest)) {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java
index 6566a294bec..6522a1ddeff 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.sysml.service.types.helper.advice;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -27,10 +28,13 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
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.commands.ConfigureElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
@@ -55,6 +59,31 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice {
* <pre>
* {@inheritDoc}
*
+ * avoid creation of association on another association
+ *
+ * </pre>
+ */
+ @Override
+ protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
+ IElementType type = request.getElementType();
+ if(SysMLElementTypes.ASSOCIATION.equals(type)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if(type != null) {
+ List<IElementType> superTypes = Arrays.asList(type.getAllSuperTypes());
+ if(superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ }
+
+ return super.getBeforeCreateRelationshipCommand(request);
+ }
+
+ /**
+ * <pre>
+ * {@inheritDoc}
+ *
* Add a command to destroy {@link Association} when only 1 end remains.
*
* </pre>
@@ -168,6 +197,11 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice {
request.getParameters().put(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS, currentlyRefactoredElements);
}
+ // not possible to have an association on another association, so reorient is forbidden here
+ if(request.getNewRelationshipEnd() instanceof Association) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
// Retrieve property ends of the Association (assumed to be binary)
Property semanticSource = association.getMemberEnds().get(0);
Property semanticTarget = association.getMemberEnds().get(1);
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java
new file mode 100644
index 00000000000..4dac36c9f4a
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.helper.advice;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.uml2.uml.Actor;
+import org.eclipse.uml2.uml.Association;
+
+
+/**
+ * Advice to restrict {@link Association} creation in SysML
+ */
+public class PackageEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * {@inheritDoc}
+ *
+ * In case of {@link Association} creation, it should not be possible to target an association as target end.
+ */
+ @Override
+ protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
+ // test if the creation is for a SysML association
+
+ IElementType type = request.getElementType();
+ if(hasSuperType(type, SysMLElementTypes.ASSOCIATION)) {
+ // test source and target...
+ EObject target = request.getTarget();
+ if(target instanceof Association) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ if(target instanceof Actor) {
+ // association should be directed to the actor. In this case, the property is owned by the association, not by the actor
+ if(!(hasSuperType(type, SysMLElementTypes.ASSOCIATION_NONE_DIRECTED) || hasSuperType(type, SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED) || hasSuperType(type, SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED))) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ }
+ }
+
+ return super.getBeforeCreateRelationshipCommand(request);
+ }
+
+ protected boolean hasSuperType(IElementType elementType, IElementType typeToTest) {
+ if(elementType == null || typeToTest == null) {
+ return false;
+ }
+
+ if(elementType.equals(typeToTest)) {
+ return true;
+ }
+
+ List<IElementType> superTypes = Arrays.asList(elementType.getAllSuperTypes());
+ if(superTypes.contains(typeToTest)) {
+ return true;
+ }
+
+ return false;
+ }
+}

Back to the top