Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2014-02-12 16:24:31 +0000
committerVincent Lorenzo2014-02-12 16:24:31 +0000
commit2729a7622507f39b9fa416fa07ee5f8579723e71 (patch)
tree092f3bd89dba08e74278201de4d70862babafe7f
parent74df1a9a52ad683d15a09cd9db1931c95f11b80a (diff)
downloadorg.eclipse.papyrus-2729a7622507f39b9fa416fa07ee5f8579723e71.tar.gz
org.eclipse.papyrus-2729a7622507f39b9fa416fa07ee5f8579723e71.tar.xz
org.eclipse.papyrus-2729a7622507f39b9fa416fa07ee5f8579723e71.zip
Apply bugfox from B. Maggi on master (already applied on branch (see
commit id in following text) e8fb604a0762987da518649578bbee6308742323 Use DiagramCommandStack to allow editPart creation notification (used when dropping a link create a view for a (source or target) node) 58f0eb6713f732753ab262d88cd13b2464aeadcc Bug 427271 - [SysML BDD] Can no more draw associations between a Block and an Actor. f86c1d8b36eb37cee0122e4de920ed71a6f952bc Bug 406290 - [SysML IBD] When the type of a part or a reference changes the nestedConnectors linked to an internal component of the part/refrence are hidden but are not deleted from the model. When destroying a part or changing its type, destroying all connectors that reference this part in NestedConnectorEnd.
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/META-INF/MANIFEST.MF3
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java6
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java164
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java30
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/util/SysmlResource.java9
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java8
6 files changed, 159 insertions, 61 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/META-INF/MANIFEST.MF b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/META-INF/MANIFEST.MF
index 8a2fcd1db35..c145eb447d2 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/META-INF/MANIFEST.MF
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.uml2.uml.profile.l2;bundle-version="1.0.0",
org.eclipse.core.expressions,
org.eclipse.papyrus.infra.tools;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.diagram.common;bundle-version="1.0.0"
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.sysml.service.types,
org.eclipse.papyrus.sysml.service.types.command,
org.eclipse.papyrus.sysml.service.types.element,
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java
index 0f69b4d04e0..2b9587b3122 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java
@@ -85,14 +85,12 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice
* @throws ExecutionException
*/
protected Property createTargetProperty(Property targetProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- addSourceInModel(targetProperty, propertyContainer, propertyType, association);
setPropertyType(targetProperty, propertyType, editingDomain, progressMonitor, info);
setPropertyName(targetProperty);
return targetProperty;
}
protected Property createSourceProperty(Property sourceProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- addTargetInModel(sourceProperty, propertyContainer, propertyType, association);
setPropertyType(sourceProperty, propertyType, editingDomain, progressMonitor, info);
setPropertyName(sourceProperty);
return sourceProperty;
@@ -216,6 +214,8 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice
association.getMemberEnds().add(sourceProperty);
// Create source and target ends
+ addSourceInModel(targetProperty, sourceType, targetType, association);
+ addTargetInModel(sourceProperty, targetType, sourceType, association);
createTargetProperty(targetProperty, sourceType, targetType, association, request.getEditingDomain(), progressMonitor, info);
configureSourceProperty(targetProperty);
createSourceProperty(sourceProperty, targetType, sourceType, association, request.getEditingDomain(), progressMonitor, info);
@@ -230,4 +230,4 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice
}
};
}
-}
+} \ No newline at end of file
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
index fd24bbb36cf..8b6dda12852 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
@@ -30,6 +30,7 @@ import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCo
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+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.ReorientRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
@@ -44,11 +45,13 @@ import org.eclipse.papyrus.sysml.constraints.ConstraintProperty;
import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage;
import org.eclipse.papyrus.sysml.service.types.Activator;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.service.types.utils.ConnectorUtils;
import org.eclipse.papyrus.uml.diagram.common.util.CrossReferencerUtil;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
import org.eclipse.papyrus.uml.service.types.utils.NamedElementHelper;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
@@ -78,23 +81,22 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
@SuppressWarnings("unchecked")
@Override
protected ICommand getBeforeSetCommand(SetRequest request) {
- ICommand gmfCommand = super.getBeforeSetCommand(request);
+ ICommand gmfCommand = super.getBeforeSetCommand(request);
EObject elementToEdit = request.getElementToEdit();
- if((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) &&
- (request.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (request.getValue() instanceof Type)) {
+ if((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (request.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (request.getValue() instanceof Type)) {
Property propertyToEdit = (Property)elementToEdit;
// SysML specification : all property typed by a ConstraintBlock must have a ContraintProperty stereotype applied
- if (request.getValue() instanceof org.eclipse.uml2.uml.Class) {
+ if(request.getValue() instanceof org.eclipse.uml2.uml.Class) {
ICommand stereotypeApplicationCommand = getConstraintPropertyStereotypeApplicationCommand(propertyToEdit, (org.eclipse.uml2.uml.Class)request.getValue(), request);
gmfCommand = CompositeCommand.compose(gmfCommand, stereotypeApplicationCommand);
}
// Exclude ConstraintParameter (simple property without ConstraintProperty stereotype owned by a ConstraintBlock)
- if (propertyToEdit.eContainer() instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element)propertyToEdit.eContainer(), ConstraintBlock.class) != null) {
- if (UMLUtil.getStereotypeApplication(propertyToEdit, ConstraintProperty.class) == null) {
+ if(propertyToEdit.eContainer() instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element)propertyToEdit.eContainer(), ConstraintBlock.class) != null) {
+ if(UMLUtil.getStereotypeApplication(propertyToEdit, ConstraintProperty.class) == null) {
return gmfCommand;
}
}
@@ -103,19 +105,16 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
// The edited property has to be related to a SysML association
if((relatedAssociation == null) || !(ElementUtil.hasNature(relatedAssociation, SysMLElementTypes.SYSML_NATURE))) {
-
+
// If no association exist and the new type is a Block
// (not a ConstraintBlock => a property typed by a ConstraintBlock is a ConstraintProperty, not a Part neither a Reference),
// add the association
- if ((relatedAssociation == null)
- && ((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches((Type) request.getValue())
- && !((ISpecializationType) SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type) request.getValue())
- && ((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(propertyToEdit.eContainer())) {
-
+ if((relatedAssociation == null) && ((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches((Type)request.getValue()) && !((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type)request.getValue()) && ((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(propertyToEdit.eContainer())) {
+
ICommand addAssociationCommand = getCreatePartAssociationCommand((org.eclipse.uml2.uml.Class)propertyToEdit.eContainer(), propertyToEdit, (org.eclipse.uml2.uml.Class)request.getValue());
gmfCommand = CompositeCommand.compose(gmfCommand, addAssociationCommand);
}
-
+
return gmfCommand;
}
@@ -135,10 +134,10 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
// If the new type is not a block, destroy related association
// This must be done only if the setting of the property type is not part of an association re-orient (hence after the previous code-block),
// otherwise there is no legitimate reason to destroy the existing association while re-orienting it.
- if (!((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches((Type) request.getValue()) && propertyToEdit.getType() != null) {
+ if(!((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches((Type)request.getValue()) && propertyToEdit.getType() != null) {
ICommand destroyCommand = getDestroyPartAssociationCommand(relatedAssociation, propertyToEdit);
gmfCommand = CompositeCommand.compose(gmfCommand, destroyCommand);
-
+
return gmfCommand;
}
@@ -154,6 +153,73 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
}
/**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param setRequest
+ * @return
+ */
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest setRequest) {
+ ICommand afterSetCommand = super.getAfterSetCommand(setRequest);
+ EObject elementToEdit = setRequest.getElementToEdit();
+ if((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (setRequest.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (setRequest.getValue() instanceof Type)) {
+ afterSetCommand = getDestroyAssociatedNestedConnectorCommand((Property)elementToEdit, afterSetCommand);
+ }
+ return afterSetCommand;
+ }
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
+ *
+ * @param destroyDependentsRequest
+ * @return
+ */
+ @Override
+ protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest destroyDependentsRequest) {
+ ICommand afterDestroyDependentsCommand = super.getAfterDestroyDependentsCommand(destroyDependentsRequest);
+ EObject elementToDestroy = destroyDependentsRequest.getElementToDestroy();
+ if(elementToDestroy instanceof Property) {
+ afterDestroyDependentsCommand = getDestroyAssociatedNestedConnectorCommand((Property)elementToDestroy, afterDestroyDependentsCommand);
+ }
+ return afterDestroyDependentsCommand;
+ }
+
+ /**
+ * Create a destroy command for all connectors that have this property in their <NestedConnectorEnd> property path.
+ *
+ * @param property
+ * the part to be destroyed
+ * @param command
+ * @return
+ */
+ private ICommand getDestroyAssociatedNestedConnectorCommand(Property property, ICommand command) {
+ List<Connector> instancesFilteredByType = org.eclipse.papyrus.uml.tools.utils.ElementUtil.getInstancesFilteredByType(property.getModel(), Connector.class, null);
+ List<Connector> connectorToDestroy = ConnectorUtils.filterConnectorByPropertyInNestedConnectorEnd(instancesFilteredByType, (Property)property);
+ for(Connector connector : connectorToDestroy) {
+ ICommand destroyConnectorCommand = getDestroyConnectorCommand(connector);
+ command = CompositeCommand.compose(command, destroyConnectorCommand);
+ }
+ return command;
+ }
+
+ /**
+ * Create a connector destroy command.
+ *
+ * @param connector
+ * @return the connector destroy command
+ */
+ private ICommand getDestroyConnectorCommand(Connector connector) {
+ DestroyElementRequest request = new DestroyElementRequest(connector, false);
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(connector.eContainer());
+ if(provider == null) {
+ return null;
+ }
+ return provider.getEditCommand(request);
+ }
+
+ /**
* Create a re-factoring command related to a Property move.
*
* @param setProperty
@@ -168,16 +234,16 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
Association relatedAssociation = setProperty.getAssociation(); // Should not be null, test before calling method.
- if (associationToRefactor.getMemberEnds().size() >= 2) {
+ if(associationToRefactor.getMemberEnds().size() >= 2) {
// Re-orient the related association (do not use edit service to avoid infinite loop here)
int direction = ReorientRelationshipRequest.REORIENT_TARGET;
if(setProperty == associationToRefactor.getMemberEnds().get(1)) {
direction = ReorientRelationshipRequest.REORIENT_SOURCE;
}
-
+
ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(relatedAssociation, (Type)request.getValue(), setProperty.eContainer(), direction);
reorientRequest.addParameters(request.getParameters());
-
+
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(relatedAssociation);
if(provider != null) {
return provider.getEditCommand(reorientRequest);
@@ -186,36 +252,36 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
return null;
}
-
+
/**
* Create a part association creation command.
*
* @return the part association creation command
*/
private ICommand getCreatePartAssociationCommand(final org.eclipse.uml2.uml.Class sourceBlock, final Property sourceProperty, final org.eclipse.uml2.uml.Class targetBlock) {
-
+
return new AbstractCommand("Create part association") {
-
+
@Override
protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// TODO Auto-generated method stub
return null;
}
-
+
@Override
protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// TODO Auto-generated method stub
return null;
}
-
+
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- Association association = UMLFactory.eINSTANCE.createAssociation();
-
+ Association association = UMLFactory.eINSTANCE.createAssociation();
+
// Add the association in the model
- org.eclipse.uml2.uml.Package container = (org.eclipse.uml2.uml.Package)EMFCoreUtil.getLeastCommonContainer(Arrays.asList(new EObject[]{sourceBlock, targetBlock}), UMLPackage.eINSTANCE.getPackage());
+ org.eclipse.uml2.uml.Package container = (org.eclipse.uml2.uml.Package)EMFCoreUtil.getLeastCommonContainer(Arrays.asList(new EObject[]{ sourceBlock, targetBlock }), UMLPackage.eINSTANCE.getPackage());
container.getPackagedElements().add(association);
-
+
// Use existing Property as source...
association.getMemberEnds().add(sourceProperty);
// ... and create the opposite (unnamed) Property
@@ -226,35 +292,35 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
// Initialize the element name based on the created IElementType
String initializedName = NamedElementHelper.getDefaultNameWithIncrementFromBase(UMLPackage.eINSTANCE.getAssociation().getName(), association.eContainer().eContents());
association.setName(initializedName);
-
+
// Add SysML Nature on the new Association
ElementUtil.addNature(association, SysMLElementTypes.SYSML_NATURE);
-
- return CommandResult.newOKCommandResult(association) ;
+
+ return CommandResult.newOKCommandResult(association);
}
};
}
-
+
/**
* Apply/remove the ConstraintProperty stereotype application
*
* @return the ConstraintProperty stereotype application command
*/
private ICommand getConstraintPropertyStereotypeApplicationCommand(final Property sourceProperty, final org.eclipse.uml2.uml.Class targetBlock, final SetRequest request) {
-
+
return new AbstractTransactionalCommand(request.getEditingDomain(), "Apply/Remove ConstraintProperty Stereotype", null) {
-
+
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// SysML specification : all property typed by a ConstraintBlock must have a ContraintProperty stereotype applied
ConstraintProperty constraintPropertyApplication = UMLUtil.getStereotypeApplication(sourceProperty, ConstraintProperty.class);
- if (UMLUtil.getStereotypeApplication(targetBlock, ConstraintBlock.class) != null) {
- if (constraintPropertyApplication == null) {
+ if(UMLUtil.getStereotypeApplication(targetBlock, ConstraintBlock.class) != null) {
+ if(constraintPropertyApplication == null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(sourceProperty, ConstraintsPackage.eINSTANCE.getConstraintProperty());
// Remove representations
Set<View> memberViewsToDestroy = CrossReferencerUtil.getCrossReferencingViews(sourceProperty, null);
- if (memberViewsToDestroy.size() != 0) {
+ if(memberViewsToDestroy.size() != 0) {
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
final String DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY = "displayMessageForTypingActionPreferenceKey";
boolean contains = store.contains(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
@@ -265,29 +331,23 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
final String hideValue = store.getString(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
if(!hideValue.equals(MessageDialogWithToggle.ALWAYS)) {
int size = memberViewsToDestroy.size();
- MessageDialogWithToggle.openInformation(Display.getDefault().getActiveShell(),
- "Change Type Action",
- "WARNING! Typing a Property by a ConstraintBlock make this property become a ConstraintProperty. ConstraintProperty have a specific representation. "
- + "\nSo all representations of this property will be removed from the model (" + size + " occurence" + ((size > 1) ? "s" : "") + ")."
- , "Don't show this dialog the next time",
- false, store, DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
+ MessageDialogWithToggle.openInformation(Display.getDefault().getActiveShell(), "Change Type Action", "WARNING! Typing a Property by a ConstraintBlock make this property become a ConstraintProperty. ConstraintProperty have a specific representation. " + "\nSo all representations of this property will be removed from the model (" + size + " occurence" + ((size > 1) ? "s" : "") + ").", "Don't show this dialog the next time", false, store, DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
}
-
+
}
- for (View view : memberViewsToDestroy) {
+ for(View view : memberViewsToDestroy) {
final DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), view, false);
final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(view);
ICommand editCommand = commandProvider.getEditCommand(destroyRequest);
editCommand.execute(progressMonitor, info);
}
}
- }
- else {
- if (constraintPropertyApplication != null) {
+ } else {
+ if(constraintPropertyApplication != null) {
StereotypeApplicationHelper.INSTANCE.removeFromContainmentList(sourceProperty, constraintPropertyApplication);
}
}
- return CommandResult.newOKCommandResult(sourceProperty) ;
+ return CommandResult.newOKCommandResult(sourceProperty);
}
};
}
@@ -299,17 +359,17 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
*/
@SuppressWarnings("unchecked")
private ICommand getDestroyPartAssociationCommand(Association partAssociation, Property propertyToEdit) {
-
+
DestroyElementRequest request = new DestroyElementRequest(partAssociation, false);
- List<EObject> dependentsToKeep = Arrays.asList(new EObject[] { propertyToEdit });
+ List<EObject> dependentsToKeep = Arrays.asList(new EObject[]{ propertyToEdit });
request.getParameters().put(RequestParameterConstants.DEPENDENTS_TO_KEEP, dependentsToKeep);
-
+
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(partAssociation.eContainer());
if(provider == null) {
return null;
}
ICommand destroyCommand = provider.getEditCommand(request);
-
+
return destroyCommand;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
index d9d723e6e10..4033a75abbd 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.sysml.blocks.Block;
@@ -428,4 +429,33 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils.
}
return true;
}
+
+
+
+ /**
+ * Filter connectors that have this property in their <NestedConnectorEnd> property path.
+ * @param connectors
+ * @param part
+ * @return connectors that have this property in their <NestedConnectorEnd> property path.
+ */
+ public static List<Connector> filterConnectorByPropertyInNestedConnectorEnd(List<Connector> connectors, Property part) {
+ List<Connector> res = new ArrayList<Connector>();
+ for(Connector connector : connectors) {
+ EList<ConnectorEnd> ends = connector.getEnds();
+ for(ConnectorEnd connectorEnd : ends) {
+ NestedConnectorEnd stereotypeApplication = UMLUtil.getStereotypeApplication(connectorEnd, NestedConnectorEnd.class);
+ if (stereotypeApplication != null){
+ EList<Property> propertyPath = stereotypeApplication.getPropertyPath();
+ for(Property property : propertyPath) {
+ if (property.equals(part)){
+ res.add(connector);
+ }
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/util/SysmlResource.java b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/util/SysmlResource.java
index b432ffae4c9..bf2230bd8c4 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/util/SysmlResource.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/util/SysmlResource.java
@@ -15,6 +15,12 @@ package org.eclipse.papyrus.sysml.util;
import org.eclipse.papyrus.sysml.SysmlPackage;
+/**
+ * For all deprecated : use org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication
+ * Ex :
+ * replace appliedStereotype = connectorEnd.getAppliedStereotype("SysML::Blocks::NestedConnectorEnd");connectorEnd.getStereotypeApplication(appliedStereotype);
+ * by org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(element, NestedConnectorEnd.class);
+ */
public class SysmlResource {
public static final String LIBRARIES_PATHMAP = "pathmap://SysML_LIBRARIES/"; //$NON-NLS-1$
@@ -27,6 +33,7 @@ public class SysmlResource {
public static final String SYSML_PROFILE_URI = PROFILES_PATHMAP + "SysML.profile.uml"; //$NON-NLS-1$
+
// Stereotypes ids
@Deprecated
public static String CONFORM_ID = "SysML::ModelElements::Conform";
@@ -62,7 +69,7 @@ public class SysmlResource {
@Deprecated
public static String VALUE_TYPE_ID = "SysML::Blocks::ValueType";
-
+
@Deprecated
public static String NESTED_CONNECTOR_END_ID = "SysML::Blocks::NestedConnectorEnd";
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
index e8f8220e9dd..09300f8df8b 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
@@ -726,23 +726,23 @@ public class TestUtils {
history.addOperationHistoryListener(historyChange);
// Test execution
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ EditorUtils.getDiagramCommandStack().execute(command);
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command execution failed ()");
}
// Test undo
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getCommandStack().undo();
+ EditorUtils.getDiagramCommandStack().undo();
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command undo failed ()");
}
// Test redo
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getCommandStack().redo();
+ EditorUtils.getDiagramCommandStack().redo();
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command redo failed ()");
}
// Remove listener.
history.removeOperationHistoryListener(historyChange);
}
-}
+} \ No newline at end of file

Back to the top