Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 236962 Details for
Bug 297816
[SysML Parametric Diagram] Papyrus shall provide a parametric diagram editor.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Parametric diaram v2.3
02-Enhanced-Association-creation-in-BDD-with-Constraint.patch (text/plain), 25.52 KB, created by
Régis Chevrel
on 2013-10-28 11:24:08 EDT
(
hide
)
Description:
Parametric diaram v2.3
Filename:
MIME Type:
Creator:
Régis Chevrel
Created:
2013-10-28 11:24:08 EDT
Size:
25.52 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.papyrus.sysml.diagram.parametric >diff --git src/org/eclipse/papyrus/sysml/diagram/parametric/commands/switchrepresentation/SwitchConstraintPropertyRepresentationCommand.java src/org/eclipse/papyrus/sysml/diagram/parametric/commands/switchrepresentation/SwitchConstraintPropertyRepresentationCommand.java >index a292903..ac6a016 100644 >--- src/org/eclipse/papyrus/sysml/diagram/parametric/commands/switchrepresentation/SwitchConstraintPropertyRepresentationCommand.java >+++ src/org/eclipse/papyrus/sysml/diagram/parametric/commands/switchrepresentation/SwitchConstraintPropertyRepresentationCommand.java >@@ -18,7 +18,6 @@ > import org.eclipse.gef.commands.Command; > import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; > import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; > import org.eclipse.gmf.runtime.notation.NotationFactory; > import org.eclipse.gmf.runtime.notation.NotationPackage; > import org.eclipse.gmf.runtime.notation.StringValueStyle; >@@ -73,8 +72,10 @@ > structureCompartment.setVisible(true); > } > else { >- structureCompartment = ViewService.getInstance().createNode(null, (View)editPart.getModel(), SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID, ViewUtil.APPEND, true, new PreferencesHint("org.eclipse.papyrus.sysml.diagram.parametric")); >- structureCompartment.setElement(editPart.resolveSemanticElement()); >+ structureCompartment = ViewService.createNode((View)editPart.getModel(), SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID, new PreferencesHint("org.eclipse.papyrus.sysml.diagram.parametric")); >+ if (structureCompartment != null) { >+ structureCompartment.setElement(editPart.resolveSemanticElement()); >+ } > } > > // add the << constraint >> tag >#P org.eclipse.papyrus.sysml.service.types >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java >index 20281e5..6fb4e8e 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java >@@ -13,6 +13,7 @@ > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; > import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; > > /** > * Edit helper advice for {@link Association} with "aggregation = composition" (used for creation purpose only). >@@ -31,7 +32,7 @@ > * </pre> > */ > @Override >- protected void addTargetInModel(Property targetEnd, Classifier owner, Classifier sourceType, Association association) { >+ protected void addTargetInModel(Property targetEnd, Classifier owner, Type sourceType, Association association) { > association.getOwnedEnds().add(targetEnd); > } > } >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java >index 030d2d6..ae723f7 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java >@@ -13,7 +13,6 @@ > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; > import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.Type; > > /** > * Edit helper advice for {@link Association} with "aggregation = composition" and navigable in one way (used for creation purpose only). >@@ -33,11 +32,7 @@ > * </pre> > */ > @Override >- protected Property createSourceProperty(Type targetType) { >- >- Property sourceProperty = super.createSourceProperty(targetType); >+ protected void configureSourceProperty(Property sourceProperty) { > sourceProperty.setIsComposite(true); >- >- return sourceProperty; > } > } >\ No newline at end of file >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java >index 0fb14ee..e9cd6d9 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java >@@ -13,6 +13,7 @@ > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; > import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; > > /** > * Edit helper advice for {@link Association} with "aggregation = none" and navigable in one way (used for creation purpose only). >@@ -31,7 +32,7 @@ > * </pre> > */ > @Override >- protected void addTargetInModel(Property targetEnd, Classifier owner, Classifier sourceType, Association association) { >+ protected void addTargetInModel(Property targetEnd, Classifier owner, Type sourceType, Association association) { > association.getOwnedEnds().add(targetEnd); > } > } >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java >index 025ba13..0f69b4d 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java >@@ -13,22 +13,31 @@ > *****************************************************************************/ > package org.eclipse.papyrus.sysml.service.types.helper.advice; > >+import java.util.List; >+ > import org.eclipse.core.commands.ExecutionException; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; > import org.eclipse.gmf.runtime.common.core.command.CommandResult; > 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.commands.ConfigureElementCommand; > 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.SetRequest; >+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; > import org.eclipse.papyrus.sysml.service.types.Activator; > import org.eclipse.papyrus.uml.service.types.utils.ClassifierUtils; >+import org.eclipse.papyrus.uml.service.types.utils.NamedElementHelper; > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; >+import org.eclipse.uml2.uml.Element; > import org.eclipse.uml2.uml.Property; > import org.eclipse.uml2.uml.Type; > import org.eclipse.uml2.uml.UMLFactory; >+import org.eclipse.uml2.uml.UMLPackage; > > /** > * Edit helper advice for {@link Association} with "aggregation = none" (used for creation purpose only). >@@ -66,39 +75,73 @@ > } > > /** >- * Creates a new source {@link Property} from the targetType. >+ * Creates a new {@link Property} from the propertyType in the propertyContainer > * >- * @param targetType >+ * @param propertyContainer >+ * the container of the {@link Property} >+ * @param propertyType > * the type of the {@link Property} > * @return the new {@link Property} >- */ >- protected Property createSourceProperty(Type targetType) { >- >- Property sourceProperty = UMLFactory.eINSTANCE.createProperty(); >- sourceProperty.setType(targetType); >- sourceProperty.setName(targetType.getName().toLowerCase()); >- >- return sourceProperty; >- } >- >- /** >- * Creates a new target {@link Property} from the sourceType. >- * >- * @param sourceType >- * the type of the {@link Property} >- * @return the new {@link Property} >- */ >- protected Property createTargetProperty(Type sourceType) { >- >- Property targetProperty = UMLFactory.eINSTANCE.createProperty(); >- targetProperty.setType(sourceType); >- targetProperty.setName(sourceType.getName().toLowerCase()); >- >+ * @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; >+ } >+ >+ protected void setPropertyType(Property property, Type propertyType, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { >+ // Set type using all AdviceHelper (use ServiceEdit instead of manually set) >+ SetRequest request = new SetRequest(property, UMLPackage.eINSTANCE.getTypedElement_Type(), propertyType); >+ request.setEditingDomain(editingDomain); >+ IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(property); >+ ICommand editCommand = commandProvider.getEditCommand(request); >+ editCommand.execute(progressMonitor, info); >+ } >+ >+ private void setPropertyName(Property property) { >+ String baseName = property.getType().getName().toLowerCase(); >+ Element owner = property.getOwner(); >+ if (owner instanceof Classifier) { >+ List<Property> ownedAttributes = ClassifierUtils.getOwnedAttributes((Classifier)owner); >+ String defaultNameWithIncrementFromBase = NamedElementHelper.getDefaultNameWithIncrementFromBase( >+ property.getType().getName().toLowerCase(), ownedAttributes, "_"); >+ property.setName(defaultNameWithIncrementFromBase); >+ } >+ else { >+ // default >+ property.setName(baseName); >+ } >+ } > > /** >- * Add the source {@link Property} in the correct container. >+ * This method has to be specialized by subclasses (AggregationKind) >+ * @param sourceProperty >+ * The property to configure >+ */ >+ protected void configureSourceProperty(Property sourceProperty) { >+ // do nothing >+ } >+ >+ /** >+ * This method has to be specialized by subclasses (AggregationKind) >+ * @param sourceProperty >+ * The property to configure >+ */ >+ protected void configureTargetProperty(Property targetProperty) { >+ // do nothing >+ } >+ >+ /** >+ * This method has to be specialized by subclasses (owner) > * > * @param sourceEnd > * the semantic end >@@ -110,16 +153,16 @@ > * the association > * @throws UnsupportedOperationException > */ >- protected void addSourceInModel(final Property sourceEnd, Classifier owner, Classifier targetType, Association association) throws UnsupportedOperationException { >- boolean added = ClassifierUtils.addOwnedAttribute(owner, sourceEnd); >- >+ protected void addSourceInModel(final Property sourceEnd, Classifier owner, Type targetType, Association association) throws UnsupportedOperationException { >+ // set the container in order to allow Stereotype appliance >+ boolean added = ClassifierUtils.addOwnedAttribute(owner, sourceEnd); > if(!added) { > throw new UnsupportedOperationException("Cannot add a Property on Classifier " + owner.getQualifiedName()); > } > } > > /** >- * Add the source {@link Property} in the correct container. >+ * This method has to be specialized by subclasses (owner) > * > * @param targetEnd > * the semantic end >@@ -131,9 +174,9 @@ > * the association > * @throws UnsupportedOperationException > */ >- protected void addTargetInModel(Property targetEnd, Classifier owner, Classifier sourceType, Association association) { >- boolean added = ClassifierUtils.addOwnedAttribute(owner, targetEnd); >- >+ protected void addTargetInModel(Property targetEnd, Classifier owner, Type sourceType, Association association) { >+ // set the container in order to allow Stereotype appliance >+ boolean added = ClassifierUtils.addOwnedAttribute(owner, targetEnd); > if(!added) { > throw new UnsupportedOperationException("Cannot add a Property on Classifier " + owner.getQualifiedName()); > } >@@ -162,18 +205,22 @@ > > protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { > >- // Create source and target ends >- Property sourceEnd = createSourceProperty(targetType); >- Property targetEnd = createTargetProperty(sourceType); >- >- // Add association ends references >- association.getMemberEnds().add(sourceEnd); >- association.getMemberEnds().add(targetEnd); >- >- // Add end properties in the model > try { >- addSourceInModel(sourceEnd, sourceType, targetType, association); >- addTargetInModel(targetEnd, targetType, sourceType, association); >+ Property targetProperty = UMLFactory.eINSTANCE.createProperty(); >+ Property sourceProperty = UMLFactory.eINSTANCE.createProperty(); >+ >+ // TODO: problem with SysML. Link are inversed. A -> B => memberEnd={a, b} instead of {b, a}. >+ // Problem seems to come from cached derivedFeature /endTypes >+ // So we force to set memberEnd in this order before doing anything with the created properties >+ association.getMemberEnds().add(targetProperty); >+ association.getMemberEnds().add(sourceProperty); >+ >+ // Create source and target ends >+ createTargetProperty(targetProperty, sourceType, targetType, association, request.getEditingDomain(), progressMonitor, info); >+ configureSourceProperty(targetProperty); >+ createSourceProperty(sourceProperty, targetType, sourceType, association, request.getEditingDomain(), progressMonitor, info); >+ configureTargetProperty(sourceProperty); >+ > } catch (Exception e) { > Activator.log.error(e); > return CommandResult.newCancelledCommandResult(); >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java >index f724ef0..b2a121d 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java >@@ -13,6 +13,7 @@ > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; > import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; > > /** > * Edit helper advice for {@link Association} with "aggregation = shared" and navigable in one way (used for creation purpose only). >@@ -31,7 +32,7 @@ > * </pre> > */ > @Override >- protected void addTargetInModel(Property targetEnd, Classifier owner, Classifier sourceType, Association association) { >+ protected void addTargetInModel(Property targetEnd, Classifier owner, Type sourceType, Association association) { > association.getOwnedEnds().add(targetEnd); > } > } >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java >index 828a487..76afbbc 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java >@@ -14,7 +14,6 @@ > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.Classifier; > import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.Type; > > /** > * Edit helper advice for {@link Association} with "aggregation = shared" (used for creation purpose only). >@@ -34,11 +33,7 @@ > * </pre> > */ > @Override >- protected Property createSourceProperty(Type targetType) { >- >- Property sourceProperty = super.createSourceProperty(targetType); >+ protected void configureSourceProperty(Property sourceProperty) { > sourceProperty.setAggregation(AggregationKind.SHARED_LITERAL); >- >- return sourceProperty; > } > } >\ No newline at end of file >diff --git src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java >index b68ab61..fd24bbb 100644 >--- src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java >+++ src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java >@@ -104,9 +104,12 @@ > // 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, add the association >+ // 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())) { > > ICommand addAssociationCommand = getCreatePartAssociationCommand((org.eclipse.uml2.uml.Class)propertyToEdit.eContainer(), propertyToEdit, (org.eclipse.uml2.uml.Class)request.getValue()); >@@ -132,7 +135,7 @@ > // 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())) { >+ if (!((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches((Type) request.getValue()) && propertyToEdit.getType() != null) { > ICommand destroyCommand = getDestroyPartAssociationCommand(relatedAssociation, propertyToEdit); > gmfCommand = CompositeCommand.compose(gmfCommand, destroyCommand); > >@@ -165,18 +168,20 @@ > > Association relatedAssociation = setProperty.getAssociation(); // Should not be null, test before calling method. > >- // 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); >+ 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); >+ } > } > > return null; >#P org.eclipse.papyrus.uml.service.types >diff --git src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java >index 1ccdceb..a6c5e36 100644 >--- src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java >+++ src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java >@@ -14,6 +14,9 @@ > *****************************************************************************/ > package org.eclipse.papyrus.uml.service.types.utils; > >+import java.util.ArrayList; >+import java.util.List; >+ > import org.eclipse.emf.ecore.EObject; > import org.eclipse.uml2.uml.Artifact; > import org.eclipse.uml2.uml.Class; >@@ -41,6 +44,20 @@ > */ > public static boolean addOwnedAttribute(Classifier classifier, Property property) { > AddOwnedAttributeSwitch classifierSwitch = new AddOwnedAttributeSwitch(property); >+ return classifierSwitch.doSwitch(classifier); >+ } >+ >+ /** >+ * This method provides a switch to ease the addition of a new Property in a Classifier. >+ * >+ * @param classifier >+ * the parent classifier. >+ * @param property >+ * the contained property. >+ * @return false if the addition fails. >+ */ >+ public static List<Property> getOwnedAttributes(Classifier classifier) { >+ GetOwnedAttributesSwitch classifierSwitch = new GetOwnedAttributesSwitch(); > return classifierSwitch.doSwitch(classifier); > } > >@@ -98,4 +115,50 @@ > return Boolean.FALSE; > } > }; >+ >+ /** >+ * Switch implementation for Property addition. >+ */ >+ private static class GetOwnedAttributesSwitch extends UMLSwitch<List<Property>> { >+ >+ public GetOwnedAttributesSwitch() { >+ super(); >+ } >+ >+ @Override >+ public List<Property> caseArtifact(Artifact object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> caseDataType(DataType object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> caseInterface(Interface object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> caseSignal(Signal object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> caseStructuredClassifier(StructuredClassifier object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> caseClass(Class object) { >+ return object.getOwnedAttributes(); >+ } >+ >+ @Override >+ public List<Property> defaultCase(EObject object) { >+ return new ArrayList<Property>(); >+ } >+ }; >+ > } >diff --git src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java >index b728c97..b32eb58 100644 >--- src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java >+++ src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java >@@ -115,15 +115,21 @@ > this.baseString = baseString; > } > >- @SuppressWarnings("rawtypes") >- public static String getDefaultNameWithIncrementFromBase(String base, Collection contents) { >- return getDefaultNameWithIncrementFromBase(base, contents, null); >+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents) { >+ return getDefaultNameWithIncrementFromBase(base, contents, null, ""); >+ } >+ >+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, String separator) { >+ return getDefaultNameWithIncrementFromBase(base, contents, null, separator); > } > >- @SuppressWarnings("rawtypes") >- public static String getDefaultNameWithIncrementFromBase(String base, Collection contents, EObject elementToRename) { >- // Not change the name if elementToRename already present in the contents collection >- if (contents.contains(elementToRename)) { >+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename) { >+ return getDefaultNameWithIncrementFromBase(base, contents, elementToRename, ""); >+ } >+ >+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename, String separator) { >+ // Not change the name if elementToRename already present in the contents collection and already have a name >+ if (contents.contains(elementToRename) && EMFCoreUtil.getName(elementToRename) != null) { > if (elementToRename instanceof ENamedElement) { > return ((ENamedElement)elementToRename).getName(); > } >@@ -136,7 +142,7 @@ > if("property".equalsIgnoreCase(base)) { > base = "Attribute"; > } >- int nextNumber = 1; >+ int nextNumber = 0; > > for(Object o : contents) { > if(o instanceof EObject && o != elementToRename) { >@@ -157,6 +163,6 @@ > } > } > >- return base + nextNumber; >+ return nextNumber > 0 ? base + separator + nextNumber : base; > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 297816
:
233707
|
234574
|
234575
|
234689
|
236075
|
236536
|
236961
| 236962