Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java96
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/commands/CreateSysMLModelCommand.java16
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/strategy/paste/PartPasteStrategy.java81
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/ConstraintBlockHelper.java24
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java84
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLSelectionTester.java65
6 files changed, 187 insertions, 179 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java
index d1ba80264a0..ff7756726c2 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -96,7 +96,7 @@ public class Activator extends AbstractUIPlugin {
public void stop(BundleContext context) throws Exception {
adapterFactory.dispose();
adapterFactory = null;
- if(labelProvider != null) {
+ if (labelProvider != null) {
labelProvider.dispose();
labelProvider = null;
}
@@ -106,7 +106,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getInstance() {
@@ -115,10 +115,10 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns an image descriptor for the image file at the given plug-in relative path.
- *
+ *
* @generated
* @param path
- * the path
+ * the path
* @return the image descriptor
*/
public static ImageDescriptor getBundledImageDescriptor(String path) {
@@ -126,9 +126,9 @@ public class Activator extends AbstractUIPlugin {
}
/**
- *
+ *
* @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore()
- *
+ *
* @return Shared Preference Store.
*/
@Override
@@ -139,7 +139,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Get the item provider adapter factory.
- *
+ *
* @return the adapter factory.
*/
public AdapterFactory getItemProvidersAdapterFactory() {
@@ -148,14 +148,14 @@ public class Activator extends AbstractUIPlugin {
/**
* Get an image descriptor for current item.
- *
+ *
* @param item
- * the item for which an image descriptor searched.
+ * the item for which an image descriptor searched.
* @return the image descriptor.
*/
public ImageDescriptor getItemImageDescriptor(Object item) {
- IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(item, IItemLabelProvider.class);
- if(labelProvider != null) {
+ IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);
+ if (labelProvider != null) {
return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));
}
return null;
@@ -163,9 +163,9 @@ public class Activator extends AbstractUIPlugin {
/**
* Get an image for a ENamedElement in plug-in image registry.
- *
+ *
* @param element
- * the element.
+ * the element.
* @return the image.
*/
public Image getImage(ENamedElement element) {
@@ -173,9 +173,9 @@ public class Activator extends AbstractUIPlugin {
String imageKey = element.getName();
Image image = getImageRegistry().get(imageKey);
- if(image == null) {
+ if (image == null) {
ImageDescriptor imageDescriptor = getProvidedImageDescriptor(element);
- if(imageDescriptor == null) {
+ if (imageDescriptor == null) {
imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
}
getImageRegistry().put(imageKey, imageDescriptor);
@@ -202,19 +202,19 @@ public class Activator extends AbstractUIPlugin {
* <li> {@linkplain PositionConstants#SOUTH_EAST}</li>
* <li> {@linkplain PositionConstants#SOUTH_WEST}</li>
* </ul>
- *
+ *
* </pre>
*/
public Image getFlowPortImage(FlowPort flowport, int side) {
// Prepare the image key
String imageKey = "FlowPort_";
- if(flowport.isAtomic()) {
- if(flowport.getDirection() == FlowDirection.IN) {
+ if (flowport.isAtomic()) {
+ if (flowport.getDirection() == FlowDirection.IN) {
imageKey = imageKey + "IN_";
- } else if(flowport.getDirection() == FlowDirection.OUT) {
+ } else if (flowport.getDirection() == FlowDirection.OUT) {
imageKey = imageKey + "OUT_";
- } else if(flowport.getDirection() == FlowDirection.INOUT) {
+ } else if (flowport.getDirection() == FlowDirection.INOUT) {
imageKey = imageKey + "INOUT_";
}
@@ -223,31 +223,31 @@ public class Activator extends AbstractUIPlugin {
imageKey = imageKey + "NA_";
}
- if(side == PositionConstants.WEST) {
+ if (side == PositionConstants.WEST) {
imageKey = imageKey + "WEST";
- } else if(side == PositionConstants.NORTH) {
+ } else if (side == PositionConstants.NORTH) {
imageKey = imageKey + "NORTH";
- } else if(side == PositionConstants.SOUTH) {
+ } else if (side == PositionConstants.SOUTH) {
imageKey = imageKey + "SOUTH";
- } else if(side == PositionConstants.EAST) {
+ } else if (side == PositionConstants.EAST) {
imageKey = imageKey + "EAST";
- } else if(side == PositionConstants.NORTH_WEST) {
+ } else if (side == PositionConstants.NORTH_WEST) {
imageKey = imageKey + "NORTH_WEST";
- } else if(side == PositionConstants.NORTH_EAST) {
+ } else if (side == PositionConstants.NORTH_EAST) {
imageKey = imageKey + "NORTH_EAST";
- } else if(side == PositionConstants.SOUTH_EAST) {
+ } else if (side == PositionConstants.SOUTH_EAST) {
imageKey = imageKey + "SOUTH_EAST";
- } else if(side == PositionConstants.SOUTH_WEST) {
+ } else if (side == PositionConstants.SOUTH_WEST) {
imageKey = imageKey + "SOUTH_WEST";
}
// Retrieve image from registry or add it in the registry
Image image = getImageRegistry().get(imageKey);
- if(image == null) {
+ if (image == null) {
ImageDescriptor imageDescriptor = imageDescriptorFromPlugin(PLUGIN_ID, "/icons/flowports/" + imageKey + ".gif");
- if(imageDescriptor == null) {
+ if (imageDescriptor == null) {
imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
}
getImageRegistry().put(imageKey, imageDescriptor);
@@ -259,11 +259,11 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns a label provider supported by EMF Facet
- *
+ *
* @return a label provider supported by EMF Facet
*/
public ILabelProvider getLabelProvider() {
- if(labelProvider == null) {
+ if (labelProvider == null) {
// add a generic label provider for sysml elements
labelProvider = new UMLLabelProvider();
}
@@ -277,14 +277,14 @@ public class Activator extends AbstractUIPlugin {
ArrayList<AdapterFactory> factories = new ArrayList<AdapterFactory>();
// Add SysML adapters
-// factories.add(new ActivitiesItemProviderAdapterFactory());
-// factories.add(new AllocationsItemProviderAdapterFactory());
-// factories.add(new BlocksItemProviderAdapterFactory());
-// factories.add(new ConstraintsItemProviderAdapterFactory());
-// factories.add(new ModelelementsItemProviderAdapterFactory());
-// factories.add(new PortandflowsItemProviderAdapterFactory());
-// factories.add(new RequirementsItemProviderAdapterFactory());
- // Add UML adapter
+ // factories.add(new ActivitiesItemProviderAdapterFactory());
+ // factories.add(new AllocationsItemProviderAdapterFactory());
+ // factories.add(new BlocksItemProviderAdapterFactory());
+ // factories.add(new ConstraintsItemProviderAdapterFactory());
+ // factories.add(new ModelelementsItemProviderAdapterFactory());
+ // factories.add(new PortandflowsItemProviderAdapterFactory());
+ // factories.add(new RequirementsItemProviderAdapterFactory());
+ // Add UML adapter
factories.add(new UMLItemProviderAdapterFactory());
// Other adapters
@@ -295,19 +295,19 @@ public class Activator extends AbstractUIPlugin {
}
private ImageDescriptor getProvidedImageDescriptor(ENamedElement element) {
- if(element instanceof EStructuralFeature) {
- EStructuralFeature feature = ((EStructuralFeature)element);
+ if (element instanceof EStructuralFeature) {
+ EStructuralFeature feature = ((EStructuralFeature) element);
EClass eContainingClass = feature.getEContainingClass();
EClassifier eType = feature.getEType();
- if(eContainingClass != null && !eContainingClass.isAbstract()) {
+ if (eContainingClass != null && !eContainingClass.isAbstract()) {
element = eContainingClass;
- } else if(eType instanceof EClass && !((EClass)eType).isAbstract()) {
+ } else if (eType instanceof EClass && !((EClass) eType).isAbstract()) {
element = eType;
}
}
- if(element instanceof EClass) {
- EClass eClass = (EClass)element;
- if(!eClass.isAbstract()) {
+ if (element instanceof EClass) {
+ EClass eClass = (EClass) element;
+ if (!eClass.isAbstract()) {
return getItemImageDescriptor(eClass.getEPackage().getEFactoryInstance().create(eClass));
}
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/commands/CreateSysMLModelCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/commands/CreateSysMLModelCommand.java
index f9aa4c0527e..c82b1e12599 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/commands/CreateSysMLModelCommand.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/commands/CreateSysMLModelCommand.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -31,7 +31,7 @@ public class CreateSysMLModelCommand extends ModelCreationCommandBase {
/**
* @see org.eclipse.papyrus.infra.core.extension.commands.ModelCreationCommandBase#createRootElement()
- *
+ *
* @return
*/
@@ -42,25 +42,25 @@ public class CreateSysMLModelCommand extends ModelCreationCommandBase {
/**
* @see org.eclipse.papyrus.infra.core.extension.commands.ModelCreationCommandBase#initializeModel(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param owner
*/
@Override
protected void initializeModel(EObject owner) {
super.initializeModel(owner);
- ((org.eclipse.uml2.uml.Package)owner).setName(getModelName());
+ ((org.eclipse.uml2.uml.Package) owner).setName(getModelName());
// Retrieve SysML profile and apply with Sub-profile
- Profile sysml = (Profile)PackageUtil.loadPackage(URI.createURI(SysmlResource.SYSML_PROFILE_URI), owner.eResource().getResourceSet());
- if(sysml != null) {
- PackageUtil.applyProfile(((org.eclipse.uml2.uml.Package)owner), sysml, true);
+ Profile sysml = (Profile) PackageUtil.loadPackage(URI.createURI(SysmlResource.SYSML_PROFILE_URI), owner.eResource().getResourceSet());
+ if (sysml != null) {
+ PackageUtil.applyProfile(((org.eclipse.uml2.uml.Package) owner), sysml, true);
}
}
/**
* Gets the model name.
- *
+ *
* @return the model name
*/
protected String getModelName() {
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/strategy/paste/PartPasteStrategy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/strategy/paste/PartPasteStrategy.java
index 4b140657d28..c85e409050b 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/strategy/paste/PartPasteStrategy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/strategy/paste/PartPasteStrategy.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2014 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
@@ -67,6 +67,7 @@ public class PartPasteStrategy implements IPasteStrategy {
*
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getLabel()
*/
+ @Override
public String getLabel() {
return "partPasteStrategy"; //$NON-NLS-1$
}
@@ -76,6 +77,7 @@ public class PartPasteStrategy implements IPasteStrategy {
*
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getID()
*/
+ @Override
public String getID() {
return Activator.ID + ".partPasteStrategy"; //$NON-NLS-1$
}
@@ -85,6 +87,7 @@ public class PartPasteStrategy implements IPasteStrategy {
*
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getDescription()
*/
+ @Override
public String getDescription() {
return "Paste part elements with association"; //$NON-NLS-1$
}
@@ -112,6 +115,7 @@ public class PartPasteStrategy implements IPasteStrategy {
*
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getImage()
*/
+ @Override
@Deprecated
public Image getImage() {
return null;
@@ -122,6 +126,7 @@ public class PartPasteStrategy implements IPasteStrategy {
*
* @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getPriority()
*/
+ @Override
@Deprecated
public int getPriority() {
return 1;
@@ -131,10 +136,10 @@ public class PartPasteStrategy implements IPasteStrategy {
* Sets the options.
*
* @param options
- * the options
+ * the options
*/
public void setOptions(Map<String, Object> options) {
- //Nothing
+ // Nothing
}
/*
@@ -145,51 +150,51 @@ public class PartPasteStrategy implements IPasteStrategy {
*/
@Override
public org.eclipse.emf.common.command.Command getSemanticCommand(EditingDomain domain, EObject targetOwner, PapyrusClipboard<Object> papyrusClipboard) {
- if(targetOwner instanceof Classifier || targetOwner instanceof Package) { // test if block or package
+ if (targetOwner instanceof Classifier || targetOwner instanceof Package) { // test if block or package
// get affiliate AdditionnalData
Map<Object, ?> additionalDataMap = papyrusClipboard.getAdditionalDataForStrategy(getID());
- if(additionalDataMap != null) {
+ if (additionalDataMap != null) {
CompoundCommand compoundCommand = new CompoundCommand("Copy associations for parts"); //$NON-NLS-1$
- for(Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
+ for (Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
Object object = iterator.next();
EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object);
Object additionnalData = additionalDataMap.get(object);
EList<Association> listDuplicatedAssociation = new BasicEList<Association>();
EObject associationContainer = null;
- if(target != null && target instanceof Property && targetOwner instanceof Classifier && additionnalData instanceof PartAdditionalData) { // test if it is a part
- Classifier block = (Classifier)targetOwner;
- Property property = (Property)target;
- PartAdditionalData partAdditionalData = (PartAdditionalData)additionnalData;
+ if (target != null && target instanceof Property && targetOwner instanceof Classifier && additionnalData instanceof PartAdditionalData) { // test if it is a part
+ Classifier block = (Classifier) targetOwner;
+ Property property = (Property) target;
+ PartAdditionalData partAdditionalData = (PartAdditionalData) additionnalData;
Association newAssociation = partAdditionalData.getDuplicatedAssociation();
restoreAssociationPartContext(block, property, newAssociation);
listDuplicatedAssociation.add(newAssociation);
associationContainer = block.eContainer();
- } else if(target != null && target instanceof Classifier && targetOwner instanceof Package && additionnalData instanceof PartBlockAdditionalData) { // test if it is a block
- Classifier classifier = (Classifier)target;
+ } else if (target != null && target instanceof Classifier && targetOwner instanceof Package && additionnalData instanceof PartBlockAdditionalData) { // test if it is a block
+ Classifier classifier = (Classifier) target;
EList<Property> allAttributes = classifier.getAllAttributes();
- PartBlockAdditionalData partBlockAdditionalData = (PartBlockAdditionalData)additionnalData;
- for(Property property : allAttributes) {
+ PartBlockAdditionalData partBlockAdditionalData = (PartBlockAdditionalData) additionnalData;
+ for (Property property : allAttributes) {
Association duplicatedAssociation = partBlockAdditionalData.getDuplicatedAssociationByPropertyName(property.getName());
- if (duplicatedAssociation != null){
+ if (duplicatedAssociation != null) {
restoreAssociationPartContext(classifier, property, duplicatedAssociation);
- listDuplicatedAssociation.add(duplicatedAssociation);
+ listDuplicatedAssociation.add(duplicatedAssociation);
}
}
associationContainer = targetOwner;
}
- if(associationContainer != null && !listDuplicatedAssociation.isEmpty()) {
- // add associations to the nearest container
+ if (associationContainer != null && !listDuplicatedAssociation.isEmpty()) {
+ // add associations to the nearest container
MoveRequest moveRequest = new MoveRequest(associationContainer, listDuplicatedAssociation);
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetOwner);
- if(provider != null) {
+ if (provider != null) {
ICommand editCommand = provider.getEditCommand(moveRequest);
GMFtoEMFCommandWrapper gmFtoEMFCommandWrapper = new GMFtoEMFCommandWrapper(editCommand);
compoundCommand.append(gmFtoEMFCommandWrapper);
}
}
}
- // An empty command can't be executed
- if(compoundCommand.getCommandList().isEmpty()) {
+ // An empty command can't be executed
+ if (compoundCommand.getCommandList().isEmpty()) {
return null;
}
return compoundCommand;
@@ -210,10 +215,10 @@ public class PartPasteStrategy implements IPasteStrategy {
*/
@Override
public Command getGraphicalCommand(EditingDomain domain, org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart targetEditPart, PapyrusClipboard<Object> papyrusClipboard) {
- View targetView = (View)targetEditPart.getModel();
- EObject targetOwner = (EObject)targetView.getElement();
+ View targetView = (View) targetEditPart.getModel();
+ EObject targetOwner = targetView.getElement();
org.eclipse.emf.common.command.Command semanticCommand = getSemanticCommand(domain, targetOwner, papyrusClipboard);
- if(semanticCommand != null) {
+ if (semanticCommand != null) {
org.eclipse.gef.commands.CompoundCommand compoundCommand = new org.eclipse.gef.commands.CompoundCommand("Association Part Semantic And Graphical paste"); //$NON-NLS-1$
EMFtoGEFCommandWrapper emFtoGEFCommandWrapper = new EMFtoGEFCommandWrapper(semanticCommand);
compoundCommand.add(emFtoGEFCommandWrapper);
@@ -241,22 +246,22 @@ public class PartPasteStrategy implements IPasteStrategy {
@Override
public void prepare(PapyrusClipboard<Object> papyrusClipboard, Collection<EObject> selection) {
Map<Object, IClipboardAdditionalData> mapCopyPartData = new HashMap<Object, IClipboardAdditionalData>();
- for(Iterator<EObject> iterator = papyrusClipboard.iterateOnSource(); iterator.hasNext();) {
+ for (Iterator<EObject> iterator = papyrusClipboard.iterateOnSource(); iterator.hasNext();) {
EObject eObjectSource = iterator.next();
- if(eObjectSource instanceof Element) {
- Element elementSource = (Element)eObjectSource;
+ if (eObjectSource instanceof Element) {
+ Element elementSource = (Element) eObjectSource;
IClipboardAdditionalData clipboardAdditionalData = null;
- if(elementSource instanceof Property && UMLUtil.getStereotypeApplication(elementSource.getOwner(), Block.class) != null) { // is part
- Property propertySource = (Property)elementSource;
+ if (elementSource instanceof Property && UMLUtil.getStereotypeApplication(elementSource.getOwner(), Block.class) != null) { // is part
+ Property propertySource = (Property) elementSource;
Association association = propertySource.getAssociation();
- if (association != null){
+ if (association != null) {
clipboardAdditionalData = new PartAdditionalData(association);
}
- } else if(elementSource instanceof Classifier && UMLUtil.getStereotypeApplication(elementSource, Block.class) != null) {// is Block
- Classifier block = (Classifier)elementSource;
+ } else if (elementSource instanceof Classifier && UMLUtil.getStereotypeApplication(elementSource, Block.class) != null) {// is Block
+ Classifier block = (Classifier) elementSource;
clipboardAdditionalData = new PartBlockAdditionalData(block);
}
- if(clipboardAdditionalData != null) {
+ if (clipboardAdditionalData != null) {
Object copy = papyrusClipboard.getCopyFromSource(eObjectSource);
mapCopyPartData.put(copy, clipboardAdditionalData);
}
@@ -269,6 +274,7 @@ public class PartPasteStrategy implements IPasteStrategy {
/**
* Duplicate the association
+ *
* @param association
* @return
*/
@@ -276,18 +282,19 @@ public class PartPasteStrategy implements IPasteStrategy {
EcoreUtil.Copier copier = new EcoreUtil.Copier();
copier.copy(association);
EObject eObject = copier.get(association);
- return (Association)eObject;
+ return (Association) eObject;
}
/**
* Init the association in the new context
+ *
* @param classifier
* @param property
* @param association
*/
protected void restoreAssociationPartContext(Classifier classifier, Property property, Association association) {
EList<Property> memberEnds = association.getMemberEnds(); // should have only one element
- if (memberEnds != null && !memberEnds.isEmpty()){
+ if (memberEnds != null && !memberEnds.isEmpty()) {
Property blockProperty = memberEnds.get(0);
blockProperty.setType(classifier);
}
@@ -333,7 +340,7 @@ public class PartPasteStrategy implements IPasteStrategy {
public PartBlockAdditionalData(Classifier block) {
this.mapPropertyNameToAssociation = new HashMap<String, Association>();
EList<Property> allAttributes = block.getAllAttributes();
- for(Property property : allAttributes) {
+ for (Property property : allAttributes) {
Association association = property.getAssociation();
Association newAssociation = duplicateAssociation(association);
mapPropertyNameToAssociation.put(property.getName(), newAssociation);
@@ -343,7 +350,7 @@ public class PartPasteStrategy implements IPasteStrategy {
/**
* @param propertyName
- * @return a copy of the association
+ * @return a copy of the association
*/
public Association getDuplicatedAssociationByPropertyName(String propertyName) {
Association association = mapPropertyNameToAssociation.get(propertyName);
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/ConstraintBlockHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/ConstraintBlockHelper.java
index b60d6ba58c9..bb21d0c7240 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/ConstraintBlockHelper.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/ConstraintBlockHelper.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -26,12 +26,12 @@ import org.eclipse.uml2.uml.util.UMLUtil;
public class ConstraintBlockHelper extends ElementHelper {
public static boolean couldBeConstraintParameter(EObject possibleContraintParameter, EObject ownerConstraintBlock) {
- if (!(ownerConstraintBlock instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element)ownerConstraintBlock, ConstraintBlock.class) != null)) {
+ if (!(ownerConstraintBlock instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element) ownerConstraintBlock, ConstraintBlock.class) != null)) {
return false;
}
- return UMLUtil.getStereotypeApplication((Element)possibleContraintParameter, ConstraintProperty.class) == null;
+ return UMLUtil.getStereotypeApplication((Element) possibleContraintParameter, ConstraintProperty.class) == null;
}
-
+
public static boolean isConstraintParameter(Element element, View view) {
if (element instanceof Property) {
Property constraintProperty = (Property) element;
@@ -40,17 +40,17 @@ public class ConstraintBlockHelper extends ElementHelper {
// check for graphics : owned by a constraintProperty
if (view != null) {
View containerView = ViewUtil.getContainerView(view);
- Element containerElement = (Element)containerView.getElement();
+ Element containerElement = (Element) containerView.getElement();
// Owned by a ConstraintProperty
- if (containerElement instanceof Property
- && UMLUtil.getStereotypeApplication(containerElement, ConstraintProperty.class) != null
- && ((Property)containerElement).getType() == ownerConstraintBlock) {
+ if (containerElement instanceof Property
+ && UMLUtil.getStereotypeApplication(containerElement, ConstraintProperty.class) != null
+ && ((Property) containerElement).getType() == ownerConstraintBlock) {
return true;
}
// Owned by a ConstraintBlock
- if (containerElement instanceof org.eclipse.uml2.uml.Class
- && UMLUtil.getStereotypeApplication(containerElement, ConstraintBlock.class) != null
- && containerElement == ownerConstraintBlock) {
+ if (containerElement instanceof org.eclipse.uml2.uml.Class
+ && UMLUtil.getStereotypeApplication(containerElement, ConstraintBlock.class) != null
+ && containerElement == ownerConstraintBlock) {
return true;
}
}
@@ -58,5 +58,5 @@ public class ConstraintBlockHelper extends ElementHelper {
}
return false;
}
-
+
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
index 4486341296e..40a2c7afc50 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -36,9 +36,9 @@ import org.eclipse.uml2.uml.UMLPackage;
/**
* Show Existing Link Helper for SysML. This class provides specific management for SysML Association.
- *
+ *
* @author VL222926
- *
+ *
*/
public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExistingElementHelper {
@@ -48,18 +48,18 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
private ConnectorUtils sysmlConnectorUtils = new ConnectorUtils();
/**
- *
+ *
* Constructor.
- *
+ *
*/
public SysMLCreateOrShowExistingElementHelper() {
super();
}
/**
- *
+ *
* Constructor.
- *
+ *
* @param linkHelper
*/
public SysMLCreateOrShowExistingElementHelper(final ILinkMappingHelper linkHelper) {
@@ -67,7 +67,7 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
}
/**
- *
+ *
* @see org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper#getIElementTypeNameToDisplay(org.eclipse.gmf.runtime.emf.type.core.IElementType)
*
* @param elementType
@@ -75,46 +75,45 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
*/
@Override
protected String getIElementTypeNameToDisplay(final IElementType elementType) {
- if(SysMLElementTypes.ASSOCIATION_NONE.equals(elementType) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(elementType)) {
+ if (SysMLElementTypes.ASSOCIATION_NONE.equals(elementType) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(elementType)) {
return "Association/DirectAssociation"; //$NON-NLS-1$
- } else if(SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(elementType) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(elementType)) {
+ } else if (SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(elementType) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(elementType)) {
return "Composition/DirectComposition"; //$NON-NLS-1$
- } else if(SysMLElementTypes.ASSOCIATION_SHARED.equals(elementType) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(elementType)) {
+ } else if (SysMLElementTypes.ASSOCIATION_SHARED.equals(elementType) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(elementType)) {
return "Aggregation/DirectAggregation"; //$NON-NLS-1$
}
return super.getIElementTypeNameToDisplay(elementType);
}
-
+
/**
- *
- * @see org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper#hasWantedType(org.eclipse.emf.ecore.EObject,
- * org.eclipse.gmf.runtime.emf.type.core.IElementType)
- *
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper#hasWantedType(org.eclipse.emf.ecore.EObject, org.eclipse.gmf.runtime.emf.type.core.IElementType)
+ *
* @param eobject
- * an eobject
+ * an eobject
* @param wantedType
- * the wanted element type
+ * the wanted element type
* @return
* true if the eobject is an instance of the wanted element type.
- *
+ *
* Add test for SysML Association
*/
@Override
protected boolean hasWantedType(final EObject eobject, final IElementType wantedType) {
boolean result = super.hasWantedType(eobject, wantedType);
- if(result) {
- if(eobject instanceof Association) {
- final AggregationKind current = getAssociationAggregationKind((Association)eobject);
- if(current == AggregationKind.NONE_LITERAL) {
- if(SysMLElementTypes.ASSOCIATION_NONE.equals(current) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(wantedType)) {
+ if (result) {
+ if (eobject instanceof Association) {
+ final AggregationKind current = getAssociationAggregationKind((Association) eobject);
+ if (current == AggregationKind.NONE_LITERAL) {
+ if (SysMLElementTypes.ASSOCIATION_NONE.equals(current) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(wantedType)) {
result = true;
}
- } else if(current == AggregationKind.COMPOSITE_LITERAL) {
- if(SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(current) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(wantedType)) {
+ } else if (current == AggregationKind.COMPOSITE_LITERAL) {
+ if (SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(current) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(wantedType)) {
result = true;
}
- } else if(current == AggregationKind.SHARED_LITERAL) {
- if(SysMLElementTypes.ASSOCIATION_SHARED.equals(current) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(wantedType)) {
+ } else if (current == AggregationKind.SHARED_LITERAL) {
+ if (SysMLElementTypes.ASSOCIATION_SHARED.equals(current) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(wantedType)) {
result = true;
}
} else {
@@ -126,18 +125,18 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
}
/**
- *
+ *
* @param association
- * an association
+ * an association
* @return
* the association kind for the association
*/
private static final AggregationKind getAssociationAggregationKind(final Association association) {
final Property source = association.getMemberEnds().get(0);
final Property target = association.getMemberEnds().get(1);
- if(source.getAggregation() == AggregationKind.NONE_LITERAL && target.getAggregation() == AggregationKind.NONE_LITERAL) {
+ if (source.getAggregation() == AggregationKind.NONE_LITERAL && target.getAggregation() == AggregationKind.NONE_LITERAL) {
return AggregationKind.NONE_LITERAL;
- } else if((source.getAggregation() == AggregationKind.COMPOSITE_LITERAL) || (target.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
+ } else if ((source.getAggregation() == AggregationKind.COMPOSITE_LITERAL) || (target.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
return AggregationKind.COMPOSITE_LITERAL;
} else {
return AggregationKind.SHARED_LITERAL;
@@ -147,25 +146,26 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
/**
* @param request
- * the request for the creation
+ * the request for the creation
* @param wantedEClass
* @return
* a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
*/
+ @Override
protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
- if(wantedElementType.getEClass() == UMLPackage.eINSTANCE.getConnector()) {
+ if (wantedElementType.getEClass() == UMLPackage.eINSTANCE.getConnector()) {
final List<EdgeEndsMapper> existingElement = new ArrayList<EdgeEndsMapper>();
- for(final Element current : ((Element)request.getContainer()).getOwnedElements()) {
- if(hasWantedType(current, wantedElementType)) {
+ for (final Element current : ((Element) request.getContainer()).getOwnedElements()) {
+ if (hasWantedType(current, wantedElementType)) {
final Collection<?> sources = this.linkMappingHelper.getSource(current);
final Collection<?> targets = this.linkMappingHelper.getTarget(current);
- if(sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
- //we verify the nestedPath before to propose to restore a connector
- View sourceView = (View)request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW);
- View targetView = (View)request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW);
- boolean canBeDisplayed = this.sysmlConnectorUtils.canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths((Connector)current, sourceView, targetView);
- if(canBeDisplayed) {
+ if (sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
+ // we verify the nestedPath before to propose to restore a connector
+ View sourceView = (View) request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW);
+ View targetView = (View) request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW);
+ boolean canBeDisplayed = ConnectorUtils.canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths((Connector) current, sourceView, targetView);
+ if (canBeDisplayed) {
existingElement.add(new EdgeEndsMapper(current, sources, null, null));
}
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLSelectionTester.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLSelectionTester.java
index 93e96ee7244..3a514c70f76 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLSelectionTester.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLSelectionTester.java
@@ -28,7 +28,7 @@ import org.eclipse.uml2.uml.Package;
* This class is used in order to create test for deciding whether a diagram creation command should be visible or not.
* This property tester assumes that currently active editor is Papyrus, it should be used with care (simultaneously with a test to ensure Papyrus is
* currently opened and active).
- *
+ *
*/
public class SysMLSelectionTester extends PropertyTester {
@@ -46,17 +46,18 @@ public class SysMLSelectionTester extends PropertyTester {
}
/** Test the receiver against the selected property */
+ @Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
// Ensure Papyrus is the active editor
Object currentValue = null;
- if(IS_SYSML_MODEL.equals(property)) {
+ if (IS_SYSML_MODEL.equals(property)) {
currentValue = testSysMLModelNature(receiver);
return (currentValue == expectedValue);
- } else if(IS_SYSML_BLOCKS_MODEL.equals(property)) {
+ } else if (IS_SYSML_BLOCKS_MODEL.equals(property)) {
currentValue = testSysMLBlocksModelNature(receiver);
return (currentValue == expectedValue);
- } else if(IS_SYSML_REQUIREMENTS_MODEL.equals(property)) {
+ } else if (IS_SYSML_REQUIREMENTS_MODEL.equals(property)) {
currentValue = testSysMLRequirementsModelNature(receiver);
return (currentValue == expectedValue);
}
@@ -69,16 +70,16 @@ public class SysMLSelectionTester extends PropertyTester {
boolean isSysMLModel = false;
EObject root = getRoot(receiver);
- if(root instanceof Package) {
+ if (root instanceof Package) {
- return (((Package)root).getAppliedProfile("SysML") != null);
+ return (((Package) root).getAppliedProfile("SysML") != null);
- //FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
+ // FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
//
- // Profile sysml = UMLUtil.getProfile(SysmlPackage.eINSTANCE, root);
- // if(((Package)root).isProfileApplied(sysml)) {
- // isSysMLModel = true;
- // }
+ // Profile sysml = UMLUtil.getProfile(SysmlPackage.eINSTANCE, root);
+ // if(((Package)root).isProfileApplied(sysml)) {
+ // isSysMLModel = true;
+ // }
}
return isSysMLModel;
@@ -89,14 +90,14 @@ public class SysMLSelectionTester extends PropertyTester {
boolean isSysMLModel = false;
EObject root = getRoot(receiver);
- if(root instanceof Package) {
- return (((Package)root).getAppliedProfile("SysML::Requirements") != null);
-
- //FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
- // Profile sysml = UMLUtil.getProfile(RequirementsPackage.eINSTANCE, root);
- // if(((Package)root).isProfileApplied(sysml)) {
- // isSysMLModel = true;
- // }
+ if (root instanceof Package) {
+ return (((Package) root).getAppliedProfile("SysML::Requirements") != null);
+
+ // FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
+ // Profile sysml = UMLUtil.getProfile(RequirementsPackage.eINSTANCE, root);
+ // if(((Package)root).isProfileApplied(sysml)) {
+ // isSysMLModel = true;
+ // }
}
return isSysMLModel;
@@ -107,13 +108,13 @@ public class SysMLSelectionTester extends PropertyTester {
boolean isSysMLModel = false;
EObject root = getRoot(receiver);
- if(root instanceof Package) {
- return (((Package)root).getAppliedProfile("SysML::Blocks") != null);
- //FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
- // Profile sysml = UMLUtil.getProfile(BlocksPackage.eINSTANCE, root);
- // if(((Package)root).isProfileApplied(sysml)) {
- // isSysMLModel = true;
- // }
+ if (root instanceof Package) {
+ return (((Package) root).getAppliedProfile("SysML::Blocks") != null);
+ // FIX: UMLUtil.getProfile() loads the profile into the resource set. This is not desired.
+ // Profile sysml = UMLUtil.getProfile(BlocksPackage.eINSTANCE, root);
+ // if(((Package)root).isProfileApplied(sysml)) {
+ // isSysMLModel = true;
+ // }
}
return isSysMLModel;
@@ -123,20 +124,20 @@ public class SysMLSelectionTester extends PropertyTester {
private EObject getRoot(Object receiver) {
EObject root = null;
- if(receiver instanceof ISelection) {
- ISelection selection = (ISelection)receiver;
- if(selection.isEmpty()) {
+ if (receiver instanceof ISelection) {
+ ISelection selection = (ISelection) receiver;
+ if (selection.isEmpty()) {
return null;
}
try {
ServiceUtilsForSelection serviceUtils = ServiceUtilsForSelection.getInstance();
- UmlModel openedModel = (UmlModel)serviceUtils.getModelSet(selection).getModel(UmlModel.MODEL_ID);
- if(openedModel != null) {
+ UmlModel openedModel = (UmlModel) serviceUtils.getModelSet(selection).getModel(UmlModel.MODEL_ID);
+ if (openedModel != null) {
root = openedModel.lookupRoot();
}
} catch (ServiceException e) {
- //Ignored: The selection cannot be used to retrieve the ServicesRegistry
+ // Ignored: The selection cannot be used to retrieve the ServicesRegistry
} catch (NotFoundException e) {
Activator.log.error(e);
}

Back to the top