From 5f8f9ebf62e0b88208e2de510bc7f8edfaac0966 Mon Sep 17 00:00:00 2001 From: Axel Richard Date: Mon, 17 Feb 2014 11:34:24 +0100 Subject: [418163] Manage display and merge of UML Stereotype Properties Manage display and merge of Stereotype Attribute & Reference changes Bug: 418163 Change-Id: I52fa6a0fb1f2c5566a8a16f57c0ac280a0701601 --- .../icons/full/obj16/StereotypeAttributeChange.gif | Bin 0 -> 129 bytes .../plugin.properties | 1 + .../StereotypeAttributeChangeItemProvider.java | 125 ++++++++++ .../StereotypePropertyChangeItemProvider.java | 150 ------------ .../UMLCompareItemProviderAdapterFactory.java | 23 +- ...tereotypeAttributeChangeCustomItemProvider.java | 89 +++++++ ...tereotypeReferenceChangeCustomItemProvider.java | 69 ++++++ ...UMLCompareCustomItemProviderAdapterFactory.java | 42 ++++ .../META-INF/MANIFEST.MF | 3 +- .../org.eclipse.emf.compare.uml2.rcp.ui/plugin.xml | 20 ++ ...reotypeManyStructuralFeatureChangeAccessor.java | 141 +++++++++++ ...otypeSingleStructuralFeatureChangeAccessor.java | 77 ++++++ ...UMLStereotypeStringAttributeChangeAccessor.java | 131 ++++++++++ ...ereotypeManyAttributeChangeAccessorFactory.java | 81 +++++++ ...ereotypeManyReferenceChangeAccessorFactory.java | 81 +++++++ ...eotypeSingleAttributeChangeAccessorFactory.java | 82 +++++++ ...eotypeSingleReferenceChangeAccessorFactory.java | 81 +++++++ ...eotypeStringAttributeChangeAccessorFactory.java | 101 ++++++++ .../emf/compare/uml2/tests/AbstractUMLTest.java | 41 +++- .../tests/stereotypes/DynamicStereotypeTest.java | 86 ++++++- .../tests/stereotypes/StaticStereotypeTest.java | 47 +++- .../data/dynamic/DynamicStereotypeInputData.java | 12 + .../stereotypes/data/dynamic/a11/ancestor.uml | 18 ++ .../tests/stereotypes/data/dynamic/a11/left.uml | 18 ++ .../tests/stereotypes/data/dynamic/a11/right.uml | 18 ++ .../META-INF/MANIFEST.MF | 2 + .../model/uml2compare.ecore | 4 +- .../model/uml2compare.genmodel | 4 +- .../uml2/internal/StereotypeAttributeChange.java | 25 ++ .../uml2/internal/StereotypePropertyChange.java | 58 ----- .../compare/uml2/internal/UMLCompareFactory.java | 6 +- .../compare/uml2/internal/UMLComparePackage.java | 86 +++---- .../impl/StereotypeAttributeChangeImpl.java | 49 ++++ .../impl/StereotypePropertyChangeImpl.java | 152 ------------ .../uml2/internal/impl/UMLCompareFactoryImpl.java | 13 +- .../uml2/internal/impl/UMLComparePackageImpl.java | 30 +-- .../internal/util/UMLCompareAdapterFactory.java | 233 ++++++++---------- .../uml2/internal/util/UMLCompareSwitch.java | 24 +- .../postprocessor/AbstractUMLChangeFactory.java | 7 +- .../internal/postprocessor/UMLPostProcessor.java | 4 +- .../extension/UMLExtensionFactoryRegistry.java | 10 +- .../UMLStereotypeApplicationChangeFactory.java | 267 --------------------- .../UMLStereotypeApplicationChangeFactory.java | 267 +++++++++++++++++++++ .../UMLStereotypeAttributeChangeFactory.java | 155 ++++++++++++ .../UMLStereotypeReferenceChangeFactory.java | 155 ++++++++++++ .../emf/compare/merge/AttributeChangeMerger.java | 18 +- .../emf/compare/merge/ReferenceChangeMerger.java | 6 +- .../eclipse/emf/compare/utils/ReferenceUtil.java | 2 +- 48 files changed, 2185 insertions(+), 929 deletions(-) create mode 100644 plugins/org.eclipse.emf.compare.uml2.edit/icons/full/obj16/StereotypeAttributeChange.gif create mode 100644 plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypeAttributeChangeItemProvider.java delete mode 100644 plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypePropertyChangeItemProvider.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeAttributeChangeCustomItemProvider.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeReferenceChangeCustomItemProvider.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeManyStructuralFeatureChangeAccessor.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeSingleStructuralFeatureChangeAccessor.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeStringAttributeChangeAccessor.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyAttributeChangeAccessorFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyReferenceChangeAccessorFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleAttributeChangeAccessorFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleReferenceChangeAccessorFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeStringAttributeChangeAccessorFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/ancestor.uml create mode 100644 plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/left.uml create mode 100644 plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/right.uml create mode 100644 plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypeAttributeChange.java delete mode 100644 plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypePropertyChange.java create mode 100644 plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypeAttributeChangeImpl.java delete mode 100644 plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypePropertyChangeImpl.java delete mode 100644 plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLStereotypeApplicationChangeFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java create mode 100644 plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/icons/full/obj16/StereotypeAttributeChange.gif b/plugins/org.eclipse.emf.compare.uml2.edit/icons/full/obj16/StereotypeAttributeChange.gif new file mode 100644 index 000000000..a26660ec2 Binary files /dev/null and b/plugins/org.eclipse.emf.compare.uml2.edit/icons/full/obj16/StereotypeAttributeChange.gif differ diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/plugin.properties b/plugins/org.eclipse.emf.compare.uml2.edit/plugin.properties index 4855cd48e..32b12ea2b 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit/plugin.properties +++ b/plugins/org.eclipse.emf.compare.uml2.edit/plugin.properties @@ -161,3 +161,4 @@ _UI_UMLDiff_discriminant_feature = Discriminant _UI_IncludeChange_type = Include Change _UI_UMLDiff_eReference_feature = EReference _UI_DirectedRelationshipChange_type = Directed Relationship Change +_UI_StereotypeAttributeChange_type = Stereotype Attribute Change diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypeAttributeChangeItemProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypeAttributeChangeItemProvider.java new file mode 100644 index 000000000..e754f72f9 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypeAttributeChangeItemProvider.java @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2012 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.emf.compare.uml2.internal.provider; + + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.compare.DifferenceKind; + +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; + +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemColorProvider; +import org.eclipse.emf.edit.provider.IItemFontProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; + +/** + * This is the item provider adapter for a {@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange} object. + * + * + * @generated + */ +public class StereotypeAttributeChangeItemProvider + extends UMLDiffItemProvider + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource, + IItemColorProvider, + IItemFontProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public StereotypeAttributeChangeItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + } + return itemPropertyDescriptors; + } + + /** + * This returns StereotypeAttributeChange.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/StereotypeAttributeChange")); //$NON-NLS-1$ + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + DifferenceKind labelValue = ((StereotypeAttributeChange)object).getKind(); + String label = labelValue == null ? null : labelValue.toString(); + return label == null || label.length() == 0 ? + getString("_UI_StereotypeAttributeChange_type") : //$NON-NLS-1$ + getString("_UI_StereotypeAttributeChange_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypePropertyChangeItemProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypePropertyChangeItemProvider.java deleted file mode 100644 index 347c2eccb..000000000 --- a/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/StereotypePropertyChangeItemProvider.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (c) 2012 Obeo. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - */ -package org.eclipse.emf.compare.uml2.internal.provider; - - -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.compare.DifferenceKind; - -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; -import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; - -import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; -import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; -import org.eclipse.emf.edit.provider.IItemColorProvider; -import org.eclipse.emf.edit.provider.IItemFontProvider; -import org.eclipse.emf.edit.provider.IItemLabelProvider; -import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; -import org.eclipse.emf.edit.provider.IItemPropertySource; -import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; -import org.eclipse.emf.edit.provider.ITreeItemContentProvider; - -/** - * This is the item provider adapter for a {@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange} object. - * - * - * @generated - */ -public class StereotypePropertyChangeItemProvider - extends UMLDiffItemProvider - implements - IEditingDomainItemProvider, - IStructuredItemContentProvider, - ITreeItemContentProvider, - IItemLabelProvider, - IItemPropertySource, - IItemColorProvider, - IItemFontProvider { - /** - * This constructs an instance from a factory and a notifier. - * - * - * @generated - */ - public StereotypePropertyChangeItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * This returns the property descriptors for the adapted class. - * - * - * @generated - */ - @Override - public List getPropertyDescriptors(Object object) { - if (itemPropertyDescriptors == null) { - super.getPropertyDescriptors(object); - - addStereotypePropertyDescriptor(object); - } - return itemPropertyDescriptors; - } - - /** - * This adds a property descriptor for the Stereotype feature. - * - * - * @generated - */ - protected void addStereotypePropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_StereotypePropertyChange_stereotype_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_StereotypePropertyChange_stereotype_feature", "_UI_StereotypePropertyChange_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - UMLComparePackage.Literals.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE, - true, - false, - true, - null, - null, - null)); - } - - /** - * This returns StereotypePropertyChange.gif. - * - * - * @generated - */ - @Override - public Object getImage(Object object) { - return overlayImage(object, getResourceLocator().getImage("full/obj16/StereotypePropertyChange")); //$NON-NLS-1$ - } - - /** - * This returns the label text for the adapted class. - * - * - * @generated - */ - @Override - public String getText(Object object) { - DifferenceKind labelValue = ((StereotypePropertyChange)object).getKind(); - String label = labelValue == null ? null : labelValue.toString(); - return label == null || label.length() == 0 ? - getString("_UI_StereotypePropertyChange_type") : //$NON-NLS-1$ - getString("_UI_StereotypePropertyChange_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * This handles model notifications by calling {@link #updateChildren} to update any cached - * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. - * - * - * @generated - */ - @Override - public void notifyChanged(Notification notification) { - updateChildren(notification); - super.notifyChanged(notification); - } - - /** - * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children - * that can be created under this object. - * - * - * @generated - */ - @Override - protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { - super.collectNewChildDescriptors(newChildDescriptors, object); - } - -} diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/UMLCompareItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/UMLCompareItemProviderAdapterFactory.java index 685527e00..f98d32180 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/UMLCompareItemProviderAdapterFactory.java +++ b/plugins/org.eclipse.emf.compare.uml2.edit/src-gen/org/eclipse/emf/compare/uml2/internal/provider/UMLCompareItemProviderAdapterFactory.java @@ -217,25 +217,26 @@ public class UMLCompareItemProviderAdapterFactory extends UMLCompareAdapterFacto } /** - * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange} instances. - * + * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange} instances. + * + * * @generated */ - protected StereotypePropertyChangeItemProvider stereotypePropertyChangeItemProvider; + protected StereotypeAttributeChangeItemProvider stereotypeAttributeChangeItemProvider; /** - * This creates an adapter for a {@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange}. - * + * This creates an adapter for a {@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange}. + * + * * @generated */ @Override - public Adapter createStereotypePropertyChangeAdapter() { - if (stereotypePropertyChangeItemProvider == null) { - stereotypePropertyChangeItemProvider = new StereotypePropertyChangeItemProvider(this); + public Adapter createStereotypeAttributeChangeAdapter() { + if (stereotypeAttributeChangeItemProvider == null) { + stereotypeAttributeChangeItemProvider = new StereotypeAttributeChangeItemProvider(this); } - return stereotypePropertyChangeItemProvider; + return stereotypeAttributeChangeItemProvider; } /** @@ -428,7 +429,7 @@ public class UMLCompareItemProviderAdapterFactory extends UMLCompareAdapterFacto if (executionSpecificationChangeItemProvider != null) executionSpecificationChangeItemProvider.dispose(); if (intervalConstraintChangeItemProvider != null) intervalConstraintChangeItemProvider.dispose(); if (messageChangeItemProvider != null) messageChangeItemProvider.dispose(); - if (stereotypePropertyChangeItemProvider != null) stereotypePropertyChangeItemProvider.dispose(); + if (stereotypeAttributeChangeItemProvider != null) stereotypeAttributeChangeItemProvider.dispose(); if (stereotypeApplicationChangeItemProvider != null) stereotypeApplicationChangeItemProvider.dispose(); if (stereotypeReferenceChangeItemProvider != null) stereotypeReferenceChangeItemProvider.dispose(); if (profileApplicationChangeItemProvider != null) profileApplicationChangeItemProvider.dispose(); diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeAttributeChangeCustomItemProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeAttributeChangeCustomItemProvider.java new file mode 100644 index 000000000..371e35cb7 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeAttributeChangeCustomItemProvider.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.internal.provider.custom; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.DifferenceKind; +import org.eclipse.emf.compare.provider.ExtendedAdapterFactoryItemDelegator; +import org.eclipse.emf.compare.provider.utils.ComposedStyledString; +import org.eclipse.emf.compare.provider.utils.IStyledString; +import org.eclipse.emf.compare.provider.utils.IStyledString.Style; +import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.NamedElement; + +/** + * Item Provider for Stereotype Property Change. + * + * @author Axel Richard + */ +public class StereotypeAttributeChangeCustomItemProvider extends UMLDiffCustomItemProvider { + + /** The item delegator to reuse root adapter factory (if any). */ + private final ExtendedAdapterFactoryItemDelegator itemDelegator; + + /** + * This constructs an instance from a factory and a notifier. + * + * @param adapterFactory + * the adapter factory to use. + */ + public StereotypeAttributeChangeCustomItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + itemDelegator = new ExtendedAdapterFactoryItemDelegator(getRootAdapterFactory()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object) + */ + @Override + public IStyledString.IComposedStyledString getStyledText(Object object) { + final UMLDiff umlDiff = (UMLDiff)object; + + EObject discriminant = umlDiff.getDiscriminant(); + + final ComposedStyledString stereotypeText = new ComposedStyledString(); + final String prefix = "Stereotype Property "; + if (discriminant instanceof NamedElement) { + stereotypeText.append(prefix + ((NamedElement)discriminant).getName() + ' '); + } else if (discriminant instanceof EAttribute) { + stereotypeText.append(prefix + ((EAttribute)discriminant).getName() + ' '); + } else { + // Can't really do more + stereotypeText.append(prefix); + } + + final String action; + switch (umlDiff.getKind()) { + case ADD: + action = "add"; //$NON-NLS-1$ + break; + case DELETE: + action = "remove"; //$NON-NLS-1$ + break; + case CHANGE: + action = "changed"; //$NON-NLS-1$ + break; + case MOVE: + action = "moved"; //$NON-NLS-1$ + break; + default: + throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$ + + " value: " + umlDiff.getKind()); //$NON-NLS-1$ + } + + return stereotypeText.append(" [stereotype attribute " + action + "]", Style.DECORATIONS_STYLER); + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeReferenceChangeCustomItemProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeReferenceChangeCustomItemProvider.java new file mode 100644 index 000000000..1e86a0ec2 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/StereotypeReferenceChangeCustomItemProvider.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.internal.provider.custom; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.provider.ExtendedAdapterFactoryItemDelegator; +import org.eclipse.emf.compare.provider.utils.ComposedStyledString; +import org.eclipse.emf.compare.provider.utils.IStyledString; +import org.eclipse.emf.compare.provider.utils.IStyledString.Style; +import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.uml2.uml.NamedElement; + +/** + * Item Provider for Stereotype Property Change. + * + * @author Axel Richard + */ +public class StereotypeReferenceChangeCustomItemProvider extends UMLDiffCustomItemProvider { + + /** The item delegator to reuse root adapter factory (if any). */ + private final ExtendedAdapterFactoryItemDelegator itemDelegator; + + /** + * This constructs an instance from a factory and a notifier. + * + * @param adapterFactory + * the adapter factory to use. + */ + public StereotypeReferenceChangeCustomItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + itemDelegator = new ExtendedAdapterFactoryItemDelegator(getRootAdapterFactory()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object) + */ + @Override + public IStyledString.IComposedStyledString getStyledText(Object object) { + final UMLDiff umlDiff = (UMLDiff)object; + + EObject discriminant = umlDiff.getDiscriminant(); + + final ComposedStyledString stereotypeText = new ComposedStyledString(); + final String prefix = "Stereotype Property "; + if (discriminant instanceof NamedElement) { + stereotypeText.append(prefix + ((NamedElement)discriminant).getName() + ' '); + } else if (discriminant instanceof EReference) { + stereotypeText.append(prefix + ((EReference)discriminant).getName() + ' '); + } else { + // Can't really do more + stereotypeText.append(prefix); + } + + return stereotypeText.append(" [stereotype reference changed]", Style.DECORATIONS_STYLER); + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/UMLCompareCustomItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/UMLCompareCustomItemProviderAdapterFactory.java index c5221e9ac..ea28c9a83 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/UMLCompareCustomItemProviderAdapterFactory.java +++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/internal/provider/custom/UMLCompareCustomItemProviderAdapterFactory.java @@ -56,6 +56,18 @@ public class UMLCompareCustomItemProviderAdapterFactory extends UMLCompareAdapte */ private StereotypeApplicationChangeCustomItemProvider stereotypeApplicationChangeExtendedItemProvider; + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange} instances. + */ + private StereotypeAttributeChangeCustomItemProvider stereotypeAttributeChangeExtendedItemProvider; + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange} instances. + */ + private StereotypeReferenceChangeCustomItemProvider stereotypeReferenceChangeExtendedItemProvider; + /** * This keeps track of the one adapter used for all {@link org.eclipse.emf.compare.uml2.internal.UMLDiff} * instances. @@ -85,6 +97,36 @@ public class UMLCompareCustomItemProviderAdapterFactory extends UMLCompareAdapte return stereotypeApplicationChangeExtendedItemProvider; } + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.util.UMLCompareAdapterFactory#createStereotypeAttributeChangeAdapter() + */ + @Override + public Adapter createStereotypeAttributeChangeAdapter() { + if (stereotypeAttributeChangeExtendedItemProvider == null) { + stereotypeAttributeChangeExtendedItemProvider = new StereotypeAttributeChangeCustomItemProvider( + this); + } + + return stereotypeAttributeChangeExtendedItemProvider; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.util.UMLCompareAdapterFactory#createStereotypeReferenceChangeAdapter() + */ + @Override + public Adapter createStereotypeReferenceChangeAdapter() { + if (stereotypeReferenceChangeExtendedItemProvider == null) { + stereotypeReferenceChangeExtendedItemProvider = new StereotypeReferenceChangeCustomItemProvider( + this); + } + + return stereotypeReferenceChangeExtendedItemProvider; + } + /** * {@inheritDoc} * diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF index 14d2d9e80..8599add75 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.emf.compare.uml2.rcp.ui;singleton:=true Bundle-Version: 2.2.0.qualifier Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: org.eclipse.emf.compare.uml2.edit;bundle-version="2.0.1", +Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="2.5.0", + org.eclipse.emf.compare.uml2.edit;bundle-version="2.0.1", org.eclipse.emf.compare;bundle-version="2.0.1", org.eclipse.swt;bundle-version="3.5.0", org.eclipse.emf.compare.rcp.ui;bundle-version="2.0.1", diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/plugin.xml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/plugin.xml index fa4218ead..70865e6fa 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/plugin.xml +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/plugin.xml @@ -7,6 +7,26 @@ class="org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory.UMLStereotypeApplicationChangeFeatureAccessorFactory" ranking="25"> + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeManyStructuralFeatureChangeAccessor.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeManyStructuralFeatureChangeAccessor.java new file mode 100644 index 000000000..c3b727d42 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeManyStructuralFeatureChangeAccessor.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor; + +import static com.google.common.collect.Iterables.filter; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.Match; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.ManyStructuralFeatureAccessorImpl; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * Case of stereotype many structural feature (attribute/reference) changes. + * + * @author Axel Richard + */ +public class UMLStereotypeManyStructuralFeatureChangeAccessor extends ManyStructuralFeatureAccessorImpl { + + /** + * Creates a specialized accessor for the stereotype application differences. + * + * @param adapterFactory + * The adapter factory used by the accessor. + * @param diff + * The diff for which we need an accessor. + * @param side + * The side on which this accessor will be used. + */ + public UMLStereotypeManyStructuralFeatureChangeAccessor(AdapterFactory adapterFactory, UMLDiff diff, + MergeViewerSide side) { + super(adapterFactory, diff, side); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.AbstractStructuralFeatureAccessor#getAffectedFeature(org.eclipse.emf.compare.Diff) + */ + @Override + protected ImmutableList computeDifferences() { + Match match = getInitialDiff().getMatch(); + List siblingDifferences = match.getDifferences(); + EStructuralFeature affectedFeature = getAffectedFeature(getInitialDiff()); + return ImmutableList.copyOf(filter(siblingDifferences, onFeature(getStructuralFeature().getName(), + affectedFeature))); + } + + /** + * This can be used to check that a given {@code affectedFeature} matches the given {@code featureName}. + * + * @param featureName + * Name of the feature on which we expect a change. + * @param affectedFeature + * The affected feature. + * @return The created predicate. + */ + private static Predicate onFeature(final String featureName, + final EStructuralFeature affectedFeature) { + return new Predicate() { + public boolean apply(Diff input) { + return featureName.equals(affectedFeature.getName()); + } + }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.AbstractStructuralFeatureAccessor#getAffectedFeature(org.eclipse.emf.compare.Diff) + */ + @Override + protected EStructuralFeature getAffectedFeature(Diff diff) { + return (EStructuralFeature)((UMLDiff)diff).getDiscriminant(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeManyStructuralFeatureChangeAccessor#getEObject(org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.IMergeViewer.MergeViewerSide) + */ + @Override + public EObject getEObject(MergeViewerSide side) { + Diff refined = getInitialDiff().getRefinedBy().get(0); + final EObject eObject; + switch (side) { + case ANCESTOR: + eObject = refined.getMatch().getOrigin(); + break; + case LEFT: + eObject = refined.getMatch().getLeft(); + break; + case RIGHT: + eObject = refined.getMatch().getRight(); + break; + default: + throw new IllegalStateException(); + } + return eObject; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.ManyStructuralFeatureAccessorImpl#getValueFromDiff(org.eclipse.emf.compare.Diff, + * org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.IMergeViewer.MergeViewerSide) + */ + @Override + protected Object getValueFromDiff(Diff diff, MergeViewerSide side) { + Diff refined = diff.getRefinedBy().get(0); + return super.getValueFromDiff(refined, side); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.ManyStructuralFeatureAccessorImpl#findInsertionIndex(org.eclipse.emf.compare.Diff, + * boolean) + */ + @Override + protected int findInsertionIndex(Diff diff, boolean rightToLeft) { + Diff refined = diff.getRefinedBy().get(0); + return super.findInsertionIndex(refined, rightToLeft); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeSingleStructuralFeatureChangeAccessor.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeSingleStructuralFeatureChangeAccessor.java new file mode 100644 index 000000000..bea9a966b --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeSingleStructuralFeatureChangeAccessor.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.SingleStructuralFeatureAccessorImpl; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * Case of stereotype single structural feature (attribute/reference) changes. + * + * @author Axel Richard + */ +public class UMLStereotypeSingleStructuralFeatureChangeAccessor extends SingleStructuralFeatureAccessorImpl { + + /** + * Creates a specialized accessor for the stereotype application differences. + * + * @param adapterFactory + * The adapter factory used by the accessor. + * @param diff + * The diff for which we need an accessor. + * @param side + * The side on which this accessor will be used. + */ + public UMLStereotypeSingleStructuralFeatureChangeAccessor(AdapterFactory adapterFactory, UMLDiff diff, + MergeViewerSide side) { + super(adapterFactory, diff, side); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.AbstractStructuralFeatureAccessor#getAffectedFeature(org.eclipse.emf.compare.Diff) + */ + @Override + protected EStructuralFeature getAffectedFeature(Diff diff) { + return (EStructuralFeature)((UMLDiff)diff).getDiscriminant(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeSingleStructuralFeatureChangeAccessor#getEObject(org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.IMergeViewer.MergeViewerSide) + */ + @Override + public EObject getEObject(MergeViewerSide side) { + Diff refined = getInitialDiff().getRefinedBy().get(0); + final EObject eObject; + switch (side) { + case ANCESTOR: + eObject = refined.getMatch().getOrigin(); + break; + case LEFT: + eObject = refined.getMatch().getLeft(); + break; + case RIGHT: + eObject = refined.getMatch().getRight(); + break; + default: + throw new IllegalStateException(); + } + return eObject; + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeStringAttributeChangeAccessor.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeStringAttributeChangeAccessor.java new file mode 100644 index 000000000..2c032b688 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/UMLStereotypeStringAttributeChangeAccessor.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.compare.Comparison; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.IStreamContentAccessor; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.TypeConstants; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.utils.ReferenceUtil; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.provider.EcoreEditPlugin; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.swt.graphics.Image; + +/** + * Case of stereotype string attribute changes. + * + * @author Axel Richard + */ +public class UMLStereotypeStringAttributeChangeAccessor implements ITypedElement, IStreamContentAccessor { + + /** The EObject to get the value of the EAttribute from. */ + protected final EObject fEObject; + + /** The EAttribute to retrieve from the wrapped EObject. */ + protected final EAttribute fAttribute; + + /** The comparison object. */ + protected final Comparison fComparison; + + /** + * Constructor. + * + * @param eObject + * the EObject to get the value of the EAttribute from. + * @param propertyChange + * the {@link StereotypeAttributeChange} concerned by the accessor. + */ + public UMLStereotypeStringAttributeChangeAccessor(EObject eObject, + StereotypeAttributeChange propertyChange) { + this.fEObject = eObject; + this.fAttribute = (EAttribute)propertyChange.getDiscriminant(); + this.fComparison = propertyChange.getMatch().getComparison(); + } + + /** + * Returns the comparison object. + * + * @return the fComparison + */ + public Comparison getComparison() { + return fComparison; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.compare.IStreamContentAccessor#getContents() + */ + public InputStream getContents() throws CoreException { + Object value = ReferenceUtil.safeEGet(getEObject(), getEAtribute()); + String stringValue = EcoreUtil.convertToString(getEAtribute().getEAttributeType(), value); + // Assume that the platform locale is appropriate. + if (stringValue != null) { + return new ByteArrayInputStream(stringValue.getBytes()); + } else { + return new ByteArrayInputStream(new byte[0]); + } + } + + /** + * Returns the EObject to get the value of the EAttribute from. + * + * @return the fEObject + */ + protected final EObject getEObject() { + return fEObject; + } + + /** + * Returns the EAttribute to retrieve from the wrapped EObject. + * + * @return the fEAttribute + */ + protected final EAttribute getEAtribute() { + return fAttribute; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.wrapper.compare.ITypedElement#getName() + */ + public String getName() { + return this.getClass().getName(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.wrapper.compare.ITypedElement#getImage() + */ + public Image getImage() { + return ExtendedImageRegistry.getInstance().getImage( + EcoreEditPlugin.getPlugin().getImage("full/obj16/EAttribute")); //$NON-NLS-1$ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.wrapper.compare.ITypedElement#getType() + */ + public String getType() { + return TypeConstants.TYPE_ETEXT_DIFF; + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyAttributeChangeAccessorFactory.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyAttributeChangeAccessorFactory.java new file mode 100644 index 000000000..12005a188 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyAttributeChangeAccessorFactory.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.ManyStructuralFeatureAccessorFactory; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeManyStructuralFeatureChangeAccessor; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; + +/** + * This will be in charge of creating the accessor for stereotype many attribute changes. + * + * @author Axel Richard + */ +public class UMLStereotypeManyAttributeChangeAccessorFactory extends ManyStructuralFeatureAccessorFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#isFactoryFor(java.lang.Object) + */ + @Override + public boolean isFactoryFor(Object target) { + if (target instanceof StereotypeAttributeChange) { + EObject discriminant = ((StereotypeAttributeChange)target).getDiscriminant(); + if (discriminant instanceof EAttribute) { + EAttribute attribute = (EAttribute)discriminant; + return attribute.isMany(); + } + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createLeft(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createLeft(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.LEFT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createRight(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createRight(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.RIGHT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createAncestor(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createAncestor(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.ANCESTOR); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyReferenceChangeAccessorFactory.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyReferenceChangeAccessorFactory.java new file mode 100644 index 000000000..941734662 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeManyReferenceChangeAccessorFactory.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.ManyStructuralFeatureAccessorFactory; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeManyStructuralFeatureChangeAccessor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; + +/** + * This will be in charge of creating the accessor for stereotype many reference changes. + * + * @author Axel Richard + */ +public class UMLStereotypeManyReferenceChangeAccessorFactory extends ManyStructuralFeatureAccessorFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#isFactoryFor(java.lang.Object) + */ + @Override + public boolean isFactoryFor(Object target) { + if (target instanceof StereotypeReferenceChange) { + EObject discriminant = ((StereotypeReferenceChange)target).getDiscriminant(); + if (discriminant instanceof EReference) { + EReference ref = (EReference)discriminant; + return ref.isMany(); + } + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createLeft(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createLeft(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.LEFT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createRight(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createRight(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.RIGHT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createAncestor(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createAncestor(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeManyStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.ANCESTOR); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleAttributeChangeAccessorFactory.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleAttributeChangeAccessorFactory.java new file mode 100644 index 000000000..3f0df8d3c --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleAttributeChangeAccessorFactory.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.SingleStructuralFeatureAccessorFactory; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeSingleStructuralFeatureChangeAccessor; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; + +/** + * This will be in charge of creating the accessor for stereotype single attribute changes. + * + * @author Axel Richard + */ +public class UMLStereotypeSingleAttributeChangeAccessorFactory extends SingleStructuralFeatureAccessorFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#isFactoryFor(java.lang.Object) + */ + @Override + public boolean isFactoryFor(Object target) { + if (target instanceof StereotypeAttributeChange) { + EObject discriminant = ((StereotypeAttributeChange)target).getDiscriminant(); + if (discriminant instanceof EAttribute) { + EAttribute attribute = (EAttribute)discriminant; + return !(attribute.getEAttributeType().getInstanceClass() == String.class) + && !attribute.isMany(); + } + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createLeft(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createLeft(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.LEFT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createRight(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createRight(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.RIGHT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createAncestor(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createAncestor(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeAttributeChange)target, MergeViewerSide.ANCESTOR); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleReferenceChangeAccessorFactory.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleReferenceChangeAccessorFactory.java new file mode 100644 index 000000000..b09a29fff --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeSingleReferenceChangeAccessorFactory.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.SingleStructuralFeatureAccessorFactory; +import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide; +import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeSingleStructuralFeatureChangeAccessor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; + +/** + * This will be in charge of creating the accessor for stereotype single reference changes. + * + * @author Axel Richard + */ +public class UMLStereotypeSingleReferenceChangeAccessorFactory extends SingleStructuralFeatureAccessorFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#isFactoryFor(java.lang.Object) + */ + @Override + public boolean isFactoryFor(Object target) { + if (target instanceof StereotypeReferenceChange) { + EObject discriminant = ((StereotypeReferenceChange)target).getDiscriminant(); + if (discriminant instanceof EReference) { + EReference ref = (EReference)discriminant; + return !ref.isMany(); + } + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createLeft(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createLeft(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.LEFT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createRight(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createRight(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.RIGHT); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createAncestor(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createAncestor(AdapterFactory adapterFactory, Object target) { + return new UMLStereotypeSingleStructuralFeatureChangeAccessor(adapterFactory, + (StereotypeReferenceChange)target, MergeViewerSide.ANCESTOR); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeStringAttributeChangeAccessorFactory.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeStringAttributeChangeAccessorFactory.java new file mode 100644 index 000000000..23e07785d --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/src/org/eclipse/emf/compare/uml2/rcp/ui/internal/accessor/factory/UMLStereotypeStringAttributeChangeAccessorFactory.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.rcp.ui.contentmergeviewer.accessor.legacy.ITypedElement; +import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.StringAttributeChangeAccessorFactory; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.UMLStereotypeStringAttributeChangeAccessor; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; + +/** + * This will be in charge of creating the accessor for stereotype property changes. + * + * @author Axel Richard + */ +public class UMLStereotypeStringAttributeChangeAccessorFactory extends StringAttributeChangeAccessorFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#isFactoryFor(java.lang.Object) + */ + @Override + public boolean isFactoryFor(Object target) { + if (target instanceof StereotypeAttributeChange) { + EObject discriminant = ((StereotypeAttributeChange)target).getDiscriminant(); + if (discriminant instanceof EAttribute) { + EAttribute attribute = (EAttribute)discriminant; + return attribute.getEAttributeType().getInstanceClass() == String.class + && !attribute.isMany(); + } + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createLeft(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createLeft(AdapterFactory adapterFactory, Object target) { + StereotypeAttributeChange change = (StereotypeAttributeChange)target; + Diff refined = change.getRefinedBy().get(0); + EObject left = refined.getMatch().getLeft(); + if (left != null) { + return new UMLStereotypeStringAttributeChangeAccessor(left, (StereotypeAttributeChange)target); + } else { + return null; + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createRight(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createRight(AdapterFactory adapterFactory, Object target) { + StereotypeAttributeChange change = (StereotypeAttributeChange)target; + Diff refined = change.getRefinedBy().get(0); + EObject right = refined.getMatch().getRight(); + if (right != null) { + return new UMLStereotypeStringAttributeChangeAccessor(right, (StereotypeAttributeChange)target); + } else { + return null; + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.accessor.IAccessorFactory#createAncestor(org.eclipse.emf.common.notify.AdapterFactory, + * java.lang.Object) + */ + @Override + public ITypedElement createAncestor(AdapterFactory adapterFactory, Object target) { + StereotypeAttributeChange change = (StereotypeAttributeChange)target; + Diff refined = change.getRefinedBy().get(0); + EObject origin = refined.getMatch().getOrigin(); + if (origin != null) { + return new UMLStereotypeStringAttributeChangeAccessor(origin, (StereotypeAttributeChange)target); + } else { + return null; + } + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java index 8a1a8d35e..17d9a53ca 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java @@ -10,6 +10,8 @@ */ package org.eclipse.emf.compare.uml2.tests; +import static com.google.common.collect.Iterators.all; +import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasConflict; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -28,6 +30,7 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.compare.AttributeChange; import org.eclipse.emf.compare.ComparePackage; import org.eclipse.emf.compare.Comparison; +import org.eclipse.emf.compare.ConflictKind; import org.eclipse.emf.compare.Diff; import org.eclipse.emf.compare.EMFCompare; import org.eclipse.emf.compare.EMFCompare.Builder; @@ -201,25 +204,45 @@ public abstract class AbstractUMLTest { protected abstract AbstractUMLInputData getInput(); protected void testMergeLeftToRight(Notifier left, Notifier right, Notifier origin) { + testMergeLeftToRight(left, right, origin, false); + } + + protected void testMergeRightToLeft(Notifier left, Notifier right, Notifier origin) { + testMergeRightToLeft(left, right, origin, false); + } + + protected void testMergeLeftToRight(Notifier left, Notifier right, Notifier origin, boolean pseudoAllowed) { final IComparisonScope scope = new DefaultComparisonScope(left, right, origin); final Comparison comparisonBefore = getCompare().compare(scope); - EList differences = comparisonBefore.getDifferences(); + EList differencesBefore = comparisonBefore.getDifferences(); final IBatchMerger merger = new BatchMerger(mergerRegistry); - merger.copyAllLeftToRight(differences, new BasicMonitor()); + merger.copyAllLeftToRight(differencesBefore, new BasicMonitor()); final Comparison comparisonAfter = getCompare().compare(scope); - assertTrue("Comparison#getDifferences() must be empty after copyAllLeftToRight", comparisonAfter - .getDifferences().isEmpty()); + EList differencesAfter = comparisonAfter.getDifferences(); + final boolean diffs; + if (pseudoAllowed) { + diffs = all(differencesAfter.iterator(), hasConflict(ConflictKind.PSEUDO)); + } else { + diffs = differencesAfter.isEmpty(); + } + assertTrue("Comparison#getDifferences() must be empty after copyAllLeftToRight", diffs); } - protected void testMergeRightToLeft(Notifier left, Notifier right, Notifier origin) { + protected void testMergeRightToLeft(Notifier left, Notifier right, Notifier origin, boolean pseudoAllowed) { final IComparisonScope scope = new DefaultComparisonScope(left, right, origin); final Comparison comparisonBefore = getCompare().compare(scope); - EList differences = comparisonBefore.getDifferences(); + EList differencesBefore = comparisonBefore.getDifferences(); final IBatchMerger merger = new BatchMerger(mergerRegistry); - merger.copyAllRightToLeft(differences, new BasicMonitor()); + merger.copyAllRightToLeft(differencesBefore, new BasicMonitor()); final Comparison comparisonAfter = getCompare().compare(scope); - assertTrue("Comparison#getDifferences() must be empty after copyAllRightToLeft", comparisonAfter - .getDifferences().isEmpty()); + EList differencesAfter = comparisonAfter.getDifferences(); + final boolean diffs; + if (pseudoAllowed) { + diffs = all(differencesAfter.iterator(), hasConflict(ConflictKind.PSEUDO)); + } else { + diffs = differencesAfter.isEmpty(); + } + assertTrue("Comparison#getDifferences() must be empty after copyAllRightToLeft", diffs); } protected void testIntersections(Comparison comparison) { diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypeTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypeTest.java index df9b0639a..68eeb6a68 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypeTest.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypeTest.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.uml2.tests.stereotypes; import static com.google.common.base.Predicates.and; @@ -14,6 +24,7 @@ import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueNameMatche import com.google.common.base.Predicate; import com.google.common.collect.Iterators; +import com.google.common.collect.UnmodifiableIterator; import java.io.IOException; import java.util.List; @@ -26,6 +37,8 @@ import org.eclipse.emf.compare.ReferenceChange; import org.eclipse.emf.compare.ResourceAttachmentChange; import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; import org.eclipse.emf.compare.uml2.tests.AbstractDynamicProfileTest; import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; import org.eclipse.emf.compare.uml2.tests.stereotypes.data.dynamic.DynamicStereotypeInputData; @@ -519,6 +532,19 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { testMergeLeftToRight(left, right, left); } + @Test + public void testA110UseCase3way() throws IOException { + final Resource left = input.getA11Left(); + final Resource right = input.getA11Right(); + final Resource ancestor = input.getA11Ancestor(); + + final Comparison comparison = compare(left, right, ancestor); + testAB11(comparison); + + testMergeRightToLeft(left, right, ancestor, true); + testMergeLeftToRight(left, right, ancestor, true); + } + private void testAB1(TestKind kind, final Comparison comparison) { final List differences = comparison.getDifferences(); @@ -864,8 +890,8 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { private void testAB5(TestKind kind, final Comparison comparison) { final List differences = comparison.getDifferences(); - // We should have no less and no more than 3 differences - assertSame(Integer.valueOf(3), Integer.valueOf(differences.size())); + // We should have no less and no more than 4 differences + assertSame(Integer.valueOf(4), Integer.valueOf(differences.size())); Predicate changeAttributeDescription1 = null; Predicate changeAttributeDescription2 = null; @@ -877,15 +903,23 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { final Diff changeAttribute1 = Iterators.find(differences.iterator(), changeAttributeDescription1); final Diff changeAttribute2 = Iterators.find(differences.iterator(), changeAttributeDescription2); - final Diff changeUMLStereotypeApplication = Iterators.find(differences.iterator(), and( - instanceOf(StereotypeApplicationChange.class), ofKind(DifferenceKind.CHANGE))); + final UnmodifiableIterator changeUMLStereotypeProperties = Iterators.filter(differences + .iterator(), and(instanceOf(StereotypeAttributeChange.class), ofKind(DifferenceKind.CHANGE))); + + assertTrue(changeUMLStereotypeProperties.hasNext()); + final Diff changeUMLStereotypeProperty1 = changeUMLStereotypeProperties.next(); + assertTrue(changeUMLStereotypeProperties.hasNext()); + final Diff changeUMLStereotypeProperty2 = changeUMLStereotypeProperties.next(); + assertNotNull(changeAttribute1); assertNotNull(changeAttribute2); - assertNotNull(changeUMLStereotypeApplication); + assertNotNull(changeUMLStereotypeProperty1); + assertNotNull(changeUMLStereotypeProperty2); - assertSame(Integer.valueOf(2), Integer.valueOf(changeUMLStereotypeApplication.getRefinedBy().size())); - assertTrue(changeUMLStereotypeApplication.getRefinedBy().contains(changeAttribute1)); - assertTrue(changeUMLStereotypeApplication.getRefinedBy().contains(changeAttribute2)); + assertSame(Integer.valueOf(1), Integer.valueOf(changeUMLStereotypeProperty1.getRefinedBy().size())); + assertTrue(changeUMLStereotypeProperty1.getRefinedBy().contains(changeAttribute1)); + assertSame(Integer.valueOf(1), Integer.valueOf(changeUMLStereotypeProperty2.getRefinedBy().size())); + assertTrue(changeUMLStereotypeProperty2.getRefinedBy().contains(changeAttribute2)); testIntersections(comparison); @@ -907,7 +941,7 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { addStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.DELETE), onFeature("manyValuedReference")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff addStereotypeRef = Iterators.find(differences.iterator(), addStereotypeRefDescription); @@ -935,7 +969,7 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { moveStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.MOVE), onFeature("manyValuedReference")); - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff moveStereotypeRef = Iterators.find(differences.iterator(), moveStereotypeRefDescription); @@ -970,7 +1004,7 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { ofKind(DifferenceKind.CHANGE), onFeature("singleValuedReference"), valueNameMatches("class1")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), @@ -999,7 +1033,7 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { changeStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.CHANGE), onFeature("singleValuedReference"), valueNameMatches("class0")); - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), @@ -1033,7 +1067,33 @@ public class DynamicStereotypeTest extends AbstractDynamicProfileTest { ofKind(DifferenceKind.CHANGE), onFeature("singleValuedAttribute"), valueIs("oldValue")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeAttributeChange.class), + ofKind(DifferenceKind.CHANGE)); + + final Diff changeStereotypeRef = Iterators.find(differences.iterator(), + changeStereotypeRefDescription); + final Diff changeUMLStereotype = Iterators.find(differences.iterator(), + changeUMLStereotypeDescription); + + assertNotNull(changeStereotypeRef); + assertNotNull(changeUMLStereotype); + + assertSame(Integer.valueOf(1), Integer.valueOf(changeUMLStereotype.getRefinedBy().size())); + assertTrue(changeUMLStereotype.getRefinedBy().contains(changeStereotypeRef)); + + testIntersections(comparison); + } + + private void testAB11(final Comparison comparison) { + final List differences = comparison.getDifferences(); + // We should have no less and no more than 2 differences + assertSame(Integer.valueOf(2), Integer.valueOf(differences.size())); + + Predicate changeStereotypeRefDescription = null; + Predicate changeUMLStereotypeDescription = null; + + changeStereotypeRefDescription = and(instanceOf(AttributeChange.class), ofKind(DifferenceKind.CHANGE)); + changeUMLStereotypeDescription = and(instanceOf(StereotypeAttributeChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypeTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypeTest.java index a1283fa4e..dad4413a1 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypeTest.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypeTest.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.uml2.tests.stereotypes; import static com.google.common.base.Predicates.and; @@ -14,6 +24,7 @@ import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueNameMatche import com.google.common.base.Predicate; import com.google.common.collect.Iterators; +import com.google.common.collect.UnmodifiableIterator; import java.io.IOException; import java.util.List; @@ -26,6 +37,8 @@ import org.eclipse.emf.compare.ReferenceChange; import org.eclipse.emf.compare.ResourceAttachmentChange; import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; import org.eclipse.emf.compare.uml2.tests.AbstractStaticProfileTest; import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; import org.eclipse.emf.compare.uml2.tests.stereotypes.data.static_.StaticStereotypeInputData; @@ -1021,8 +1034,8 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { private void testAB5(TestKind kind, final Comparison comparison) { final List differences = comparison.getDifferences(); - // We should have no less and no more than 3 differences - assertSame(Integer.valueOf(3), Integer.valueOf(differences.size())); + // We should have no less and no more than 4 differences + assertSame(Integer.valueOf(4), Integer.valueOf(differences.size())); Predicate changeAttributeDescription1 = null; Predicate changeAttributeDescription2 = null; @@ -1034,15 +1047,23 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { final Diff changeAttribute1 = Iterators.find(differences.iterator(), changeAttributeDescription1); final Diff changeAttribute2 = Iterators.find(differences.iterator(), changeAttributeDescription2); - final Diff changeUMLStereotypeApplication = Iterators.find(differences.iterator(), and( - instanceOf(StereotypeApplicationChange.class), ofKind(DifferenceKind.CHANGE))); + final UnmodifiableIterator changeUMLStereotypeProperties = Iterators.filter(differences + .iterator(), and(instanceOf(StereotypeAttributeChange.class), ofKind(DifferenceKind.CHANGE))); + + assertTrue(changeUMLStereotypeProperties.hasNext()); + final Diff changeUMLStereotypeProperty1 = changeUMLStereotypeProperties.next(); + assertTrue(changeUMLStereotypeProperties.hasNext()); + final Diff changeUMLStereotypeProperty2 = changeUMLStereotypeProperties.next(); + assertNotNull(changeAttribute1); assertNotNull(changeAttribute2); - assertNotNull(changeUMLStereotypeApplication); + assertNotNull(changeUMLStereotypeProperty1); + assertNotNull(changeUMLStereotypeProperty2); - assertSame(Integer.valueOf(2), Integer.valueOf(changeUMLStereotypeApplication.getRefinedBy().size())); - assertTrue(changeUMLStereotypeApplication.getRefinedBy().contains(changeAttribute1)); - assertTrue(changeUMLStereotypeApplication.getRefinedBy().contains(changeAttribute2)); + assertSame(Integer.valueOf(1), Integer.valueOf(changeUMLStereotypeProperty1.getRefinedBy().size())); + assertTrue(changeUMLStereotypeProperty1.getRefinedBy().contains(changeAttribute1)); + assertSame(Integer.valueOf(1), Integer.valueOf(changeUMLStereotypeProperty2.getRefinedBy().size())); + assertTrue(changeUMLStereotypeProperty2.getRefinedBy().contains(changeAttribute2)); testIntersections(comparison); @@ -1064,7 +1085,7 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { addStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.DELETE), onFeature("manyValuedReference")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff addStereotypeRef = Iterators.find(differences.iterator(), addStereotypeRefDescription); @@ -1091,7 +1112,7 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { moveStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.MOVE), onFeature("manyValuedReference")); - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff moveStereotypeRef = Iterators.find(differences.iterator(), moveStereotypeRefDescription); @@ -1125,7 +1146,7 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { ofKind(DifferenceKind.CHANGE), onFeature("singleValuedReference"), valueNameMatches("class1")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), @@ -1154,7 +1175,7 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { changeStereotypeRefDescription = and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.CHANGE), onFeature("singleValuedReference"), valueNameMatches("class0")); - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeReferenceChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), @@ -1188,7 +1209,7 @@ public class StaticStereotypeTest extends AbstractStaticProfileTest { ofKind(DifferenceKind.CHANGE), onFeature("singleValuedAttribute"), valueIs("oldValue")); } - changeUMLStereotypeDescription = and(instanceOf(StereotypeApplicationChange.class), + changeUMLStereotypeDescription = and(instanceOf(StereotypeAttributeChange.class), ofKind(DifferenceKind.CHANGE)); final Diff changeStereotypeRef = Iterators.find(differences.iterator(), diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java index 6c616f5c1..0e1a3f909 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java @@ -87,4 +87,16 @@ public class DynamicStereotypeInputData extends AbstractUMLInputData { return loadFromClassLoader("a10/right.uml"); //$NON-NLS-1$ } + public Resource getA11Left() throws IOException { + return loadFromClassLoader("a11/left.uml"); //$NON-NLS-1$ + } + + public Resource getA11Right() throws IOException { + return loadFromClassLoader("a11/right.uml"); //$NON-NLS-1$ + } + + public Resource getA11Ancestor() throws IOException { + return loadFromClassLoader("a11/ancestor.uml"); //$NON-NLS-1$ + } + } diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/ancestor.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/ancestor.uml new file mode 100644 index 000000000..3a2ea9cfb --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/ancestor.uml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/left.uml new file mode 100644 index 000000000..3a2ea9cfb --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/left.uml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/right.uml new file mode 100644 index 000000000..2b0c44e45 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a11/right.uml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF index 0e5f4c67b..2a63edfea 100644 --- a/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF @@ -32,8 +32,10 @@ Export-Package: org.eclipse.emf.compare.uml2.internal; org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.extension.profile;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.extension.sequence;x-internal:=true, + org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.extension.usecase;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.util;x-internal:=true, + org.eclipse.emf.compare.uml2.internal.spec;x-internal:=true, org.eclipse.emf.compare.uml2.internal.util; x-friends:="org.eclipse.emf.compare.uml2.edit, org.eclipse.emf.compare.uml2.rcp, diff --git a/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.ecore b/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.ecore index 6634ae1eb..ecc899b2a 100644 --- a/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.ecore +++ b/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.ecore @@ -7,9 +7,7 @@ - - - + diff --git a/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.genmodel b/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.genmodel index c9af0a670..24206ae06 100644 --- a/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.genmodel +++ b/plugins/org.eclipse.emf.compare.uml2/model/uml2compare.genmodel @@ -18,9 +18,7 @@ - - - + diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypeAttributeChange.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypeAttributeChange.java new file mode 100644 index 000000000..a9c924458 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypeAttributeChange.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2012 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.emf.compare.uml2.internal; + + +/** + * + * A representation of the model object 'Stereotype Attribute Change'. + * + * + * + * @see org.eclipse.emf.compare.uml2.internal.UMLComparePackage#getStereotypeAttributeChange() + * @model + * @generated + */ +public interface StereotypeAttributeChange extends UMLDiff { +} // StereotypeAttributeChange diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypePropertyChange.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypePropertyChange.java deleted file mode 100644 index 21a4a1549..000000000 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/StereotypePropertyChange.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2012 Obeo. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - */ -package org.eclipse.emf.compare.uml2.internal; - -import org.eclipse.uml2.uml.Stereotype; - -/** - * - * A representation of the model object 'Stereotype Property Change'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange#getStereotype Stereotype}
  • - *
- *

- * - * @see org.eclipse.emf.compare.uml2.internal.UMLComparePackage#getStereotypePropertyChange() - * @model - * @generated - */ -public interface StereotypePropertyChange extends UMLDiff { - /** - * Returns the value of the 'Stereotype' reference. - * - *

- * If the meaning of the 'Stereotype' reference isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Stereotype' reference. - * @see #setStereotype(Stereotype) - * @see org.eclipse.emf.compare.uml2.internal.UMLComparePackage#getStereotypePropertyChange_Stereotype() - * @model - * @generated - */ - Stereotype getStereotype(); - - /** - * Sets the value of the '{@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange#getStereotype Stereotype}' reference. - * - * - * @param value the new value of the 'Stereotype' reference. - * @see #getStereotype() - * @generated - */ - void setStereotype(Stereotype value); - -} // StereotypePropertyChange diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLCompareFactory.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLCompareFactory.java index ca5ebe371..ca5e46779 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLCompareFactory.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLCompareFactory.java @@ -84,13 +84,13 @@ public interface UMLCompareFactory extends EFactory { MessageChange createMessageChange(); /** - * Returns a new object of class 'Stereotype Property Change'. + * Returns a new object of class 'Stereotype Attribute Change'. * * - * @return a new object of class 'Stereotype Property Change'. + * @return a new object of class 'Stereotype Attribute Change'. * @generated */ - StereotypePropertyChange createStereotypePropertyChange(); + StereotypeAttributeChange createStereotypeAttributeChange(); /** * Returns a new object of class 'Stereotype Application Change'. diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLComparePackage.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLComparePackage.java index 8f4ee7fa3..86a79684d 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLComparePackage.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/UMLComparePackage.java @@ -1142,14 +1142,14 @@ public interface UMLComparePackage extends EPackage { int MESSAGE_CHANGE_FEATURE_COUNT = UML_DIFF_FEATURE_COUNT + 0; /** - * The meta object id for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypePropertyChangeImpl Stereotype Property Change}' class. + * The meta object id for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypeAttributeChangeImpl Stereotype Attribute Change}' class. * * - * @see org.eclipse.emf.compare.uml2.internal.impl.StereotypePropertyChangeImpl - * @see org.eclipse.emf.compare.uml2.internal.impl.UMLComparePackageImpl#getStereotypePropertyChange() + * @see org.eclipse.emf.compare.uml2.internal.impl.StereotypeAttributeChangeImpl + * @see org.eclipse.emf.compare.uml2.internal.impl.UMLComparePackageImpl#getStereotypeAttributeChange() * @generated */ - int STEREOTYPE_PROPERTY_CHANGE = 6; + int STEREOTYPE_ATTRIBUTE_CHANGE = 6; /** * The feature id for the 'Match' container reference. @@ -1158,7 +1158,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__MATCH = UML_DIFF__MATCH; + int STEREOTYPE_ATTRIBUTE_CHANGE__MATCH = UML_DIFF__MATCH; /** * The feature id for the 'Requires' reference list. @@ -1167,7 +1167,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__REQUIRES = UML_DIFF__REQUIRES; + int STEREOTYPE_ATTRIBUTE_CHANGE__REQUIRES = UML_DIFF__REQUIRES; /** * The feature id for the 'Required By' reference list. @@ -1176,7 +1176,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__REQUIRED_BY = UML_DIFF__REQUIRED_BY; + int STEREOTYPE_ATTRIBUTE_CHANGE__REQUIRED_BY = UML_DIFF__REQUIRED_BY; /** * The feature id for the 'Implies' reference list. @@ -1185,7 +1185,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__IMPLIES = UML_DIFF__IMPLIES; + int STEREOTYPE_ATTRIBUTE_CHANGE__IMPLIES = UML_DIFF__IMPLIES; /** * The feature id for the 'Implied By' reference list. @@ -1194,7 +1194,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__IMPLIED_BY = UML_DIFF__IMPLIED_BY; + int STEREOTYPE_ATTRIBUTE_CHANGE__IMPLIED_BY = UML_DIFF__IMPLIED_BY; /** * The feature id for the 'Refines' reference list. @@ -1203,7 +1203,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__REFINES = UML_DIFF__REFINES; + int STEREOTYPE_ATTRIBUTE_CHANGE__REFINES = UML_DIFF__REFINES; /** * The feature id for the 'Refined By' reference list. @@ -1212,7 +1212,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__REFINED_BY = UML_DIFF__REFINED_BY; + int STEREOTYPE_ATTRIBUTE_CHANGE__REFINED_BY = UML_DIFF__REFINED_BY; /** * The feature id for the 'Prime Refining' reference. @@ -1221,7 +1221,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__PRIME_REFINING = UML_DIFF__PRIME_REFINING; + int STEREOTYPE_ATTRIBUTE_CHANGE__PRIME_REFINING = UML_DIFF__PRIME_REFINING; /** * The feature id for the 'Kind' attribute. @@ -1230,7 +1230,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__KIND = UML_DIFF__KIND; + int STEREOTYPE_ATTRIBUTE_CHANGE__KIND = UML_DIFF__KIND; /** * The feature id for the 'Source' attribute. @@ -1239,7 +1239,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__SOURCE = UML_DIFF__SOURCE; + int STEREOTYPE_ATTRIBUTE_CHANGE__SOURCE = UML_DIFF__SOURCE; /** * The feature id for the 'State' attribute. @@ -1248,7 +1248,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__STATE = UML_DIFF__STATE; + int STEREOTYPE_ATTRIBUTE_CHANGE__STATE = UML_DIFF__STATE; /** * The feature id for the 'Equivalence' reference. @@ -1257,7 +1257,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__EQUIVALENCE = UML_DIFF__EQUIVALENCE; + int STEREOTYPE_ATTRIBUTE_CHANGE__EQUIVALENCE = UML_DIFF__EQUIVALENCE; /** * The feature id for the 'Conflict' reference. @@ -1266,7 +1266,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__CONFLICT = UML_DIFF__CONFLICT; + int STEREOTYPE_ATTRIBUTE_CHANGE__CONFLICT = UML_DIFF__CONFLICT; /** * The feature id for the 'Discriminant' reference. @@ -1275,7 +1275,7 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__DISCRIMINANT = UML_DIFF__DISCRIMINANT; + int STEREOTYPE_ATTRIBUTE_CHANGE__DISCRIMINANT = UML_DIFF__DISCRIMINANT; /** * The feature id for the 'EReference' reference. @@ -1284,25 +1284,16 @@ public interface UMLComparePackage extends EPackage { * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__EREFERENCE = UML_DIFF__EREFERENCE; + int STEREOTYPE_ATTRIBUTE_CHANGE__EREFERENCE = UML_DIFF__EREFERENCE; /** - * The feature id for the 'Stereotype' reference. + * The number of structural features of the 'Stereotype Attribute Change' class. * * * @generated * @ordered */ - int STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE = UML_DIFF_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'Stereotype Property Change' class. - * - * - * @generated - * @ordered - */ - int STEREOTYPE_PROPERTY_CHANGE_FEATURE_COUNT = UML_DIFF_FEATURE_COUNT + 1; + int STEREOTYPE_ATTRIBUTE_CHANGE_FEATURE_COUNT = UML_DIFF_FEATURE_COUNT + 0; /** * The meta object id for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypeApplicationChangeImpl Stereotype Application Change}' class. @@ -2001,25 +1992,14 @@ public interface UMLComparePackage extends EPackage { EClass getMessageChange(); /** - * Returns the meta object for class '{@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange Stereotype Property Change}'. - * - * - * @return the meta object for class 'Stereotype Property Change'. - * @see org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange - * @generated - */ - EClass getStereotypePropertyChange(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange#getStereotype Stereotype}'. + * Returns the meta object for class '{@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange Stereotype Attribute Change}'. * * - * @return the meta object for the reference 'Stereotype'. - * @see org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange#getStereotype() - * @see #getStereotypePropertyChange() + * @return the meta object for class 'Stereotype Attribute Change'. + * @see org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange * @generated */ - EReference getStereotypePropertyChange_Stereotype(); + EClass getStereotypeAttributeChange(); /** * Returns the meta object for class '{@link org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange Stereotype Application Change}'. @@ -2200,22 +2180,14 @@ public interface UMLComparePackage extends EPackage { EClass MESSAGE_CHANGE = eINSTANCE.getMessageChange(); /** - * The meta object literal for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypePropertyChangeImpl Stereotype Property Change}' class. - * - * - * @see org.eclipse.emf.compare.uml2.internal.impl.StereotypePropertyChangeImpl - * @see org.eclipse.emf.compare.uml2.internal.impl.UMLComparePackageImpl#getStereotypePropertyChange() - * @generated - */ - EClass STEREOTYPE_PROPERTY_CHANGE = eINSTANCE.getStereotypePropertyChange(); - - /** - * The meta object literal for the 'Stereotype' reference feature. + * The meta object literal for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypeAttributeChangeImpl Stereotype Attribute Change}' class. * * + * @see org.eclipse.emf.compare.uml2.internal.impl.StereotypeAttributeChangeImpl + * @see org.eclipse.emf.compare.uml2.internal.impl.UMLComparePackageImpl#getStereotypeAttributeChange() * @generated */ - EReference STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE = eINSTANCE.getStereotypePropertyChange_Stereotype(); + EClass STEREOTYPE_ATTRIBUTE_CHANGE = eINSTANCE.getStereotypeAttributeChange(); /** * The meta object literal for the '{@link org.eclipse.emf.compare.uml2.internal.impl.StereotypeApplicationChangeImpl Stereotype Application Change}' class. diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypeAttributeChangeImpl.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypeAttributeChangeImpl.java new file mode 100644 index 000000000..9bb55cbd6 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypeAttributeChangeImpl.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2012 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.emf.compare.uml2.internal.impl; + +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; + +import org.eclipse.emf.compare.uml2.internal.spec.UMLDiffSpec; + +import org.eclipse.emf.ecore.EClass; + +/** + * + * An implementation of the model object 'Stereotype Attribute Change'. + * + *

+ *

+ * + * @generated + */ +public class StereotypeAttributeChangeImpl extends UMLDiffSpec implements StereotypeAttributeChange { + /** + * + * + * @generated + */ + protected StereotypeAttributeChangeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return UMLComparePackage.Literals.STEREOTYPE_ATTRIBUTE_CHANGE; + } + +} //StereotypeAttributeChangeImpl diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypePropertyChangeImpl.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypePropertyChangeImpl.java deleted file mode 100644 index 9be1750fe..000000000 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/StereotypePropertyChangeImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright (c) 2012 Obeo. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - */ -package org.eclipse.emf.compare.uml2.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; -import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; -import org.eclipse.emf.compare.uml2.internal.spec.UMLDiffSpec; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.uml2.uml.Stereotype; - -/** - * An implementation of the model object 'Stereotype Property Change'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.emf.compare.uml2.internal.impl.StereotypePropertyChangeImpl#getStereotype Stereotype}
  • - *
- *

- * - * @generated - */ -public class StereotypePropertyChangeImpl extends UMLDiffSpec implements StereotypePropertyChange { - /** - * The cached value of the '{@link #getStereotype() Stereotype}' reference. - * - * @see #getStereotype() - * @generated - * @ordered - */ - protected Stereotype stereotype; - - /** - * - * @generated - */ - protected StereotypePropertyChangeImpl() { - super(); - } - - /** - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return UMLComparePackage.Literals.STEREOTYPE_PROPERTY_CHANGE; - } - - /** - * - * @generated - */ - public Stereotype getStereotype() { - if (stereotype != null && stereotype.eIsProxy()) { - InternalEObject oldStereotype = (InternalEObject)stereotype; - stereotype = (Stereotype)eResolveProxy(oldStereotype); - if (stereotype != oldStereotype) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE, oldStereotype, stereotype)); - } - } - return stereotype; - } - - /** - * - * @generated - */ - public Stereotype basicGetStereotype() { - return stereotype; - } - - /** - * - * @generated - */ - public void setStereotype(Stereotype newStereotype) { - Stereotype oldStereotype = stereotype; - stereotype = newStereotype; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE, oldStereotype, stereotype)); - } - - /** - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE: - if (resolve) return getStereotype(); - return basicGetStereotype(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE: - setStereotype((Stereotype)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE: - setStereotype((Stereotype)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE: - return stereotype != null; - } - return super.eIsSet(featureID); - } - -} // StereotypePropertyChangeImpl diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLCompareFactoryImpl.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLCompareFactoryImpl.java index a5539c935..e92bbca97 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLCompareFactoryImpl.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLCompareFactoryImpl.java @@ -19,7 +19,7 @@ import org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange; import org.eclipse.emf.compare.uml2.internal.MessageChange; import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; @@ -74,7 +74,7 @@ public class UMLCompareFactoryImpl extends EFactoryImpl implements UMLCompareFac case UMLComparePackage.EXECUTION_SPECIFICATION_CHANGE: return createExecutionSpecificationChange(); case UMLComparePackage.INTERVAL_CONSTRAINT_CHANGE: return createIntervalConstraintChange(); case UMLComparePackage.MESSAGE_CHANGE: return createMessageChange(); - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE: return createStereotypePropertyChange(); + case UMLComparePackage.STEREOTYPE_ATTRIBUTE_CHANGE: return createStereotypeAttributeChange(); case UMLComparePackage.STEREOTYPE_APPLICATION_CHANGE: return createStereotypeApplicationChange(); case UMLComparePackage.STEREOTYPE_REFERENCE_CHANGE: return createStereotypeReferenceChange(); case UMLComparePackage.PROFILE_APPLICATION_CHANGE: return createProfileApplicationChange(); @@ -139,12 +139,13 @@ public class UMLCompareFactoryImpl extends EFactoryImpl implements UMLCompareFac } /** - * + * + * * @generated */ - public StereotypePropertyChange createStereotypePropertyChange() { - StereotypePropertyChangeImpl stereotypePropertyChange = new StereotypePropertyChangeImpl(); - return stereotypePropertyChange; + public StereotypeAttributeChange createStereotypeAttributeChange() { + StereotypeAttributeChangeImpl stereotypeAttributeChange = new StereotypeAttributeChangeImpl(); + return stereotypeAttributeChange; } /** diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLComparePackageImpl.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLComparePackageImpl.java index dea695358..463a82a86 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLComparePackageImpl.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/impl/UMLComparePackageImpl.java @@ -20,7 +20,7 @@ import org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange; import org.eclipse.emf.compare.uml2.internal.MessageChange; import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; @@ -74,10 +74,11 @@ public class UMLComparePackageImpl extends EPackageImpl implements UMLComparePac private EClass messageChangeEClass = null; /** - * + * + * * @generated */ - private EClass stereotypePropertyChangeEClass = null; + private EClass stereotypeAttributeChangeEClass = null; /** * @@ -220,19 +221,12 @@ public class UMLComparePackageImpl extends EPackageImpl implements UMLComparePac } /** - * - * @generated - */ - public EClass getStereotypePropertyChange() { - return stereotypePropertyChangeEClass; - } - - /** - * + * + * * @generated */ - public EReference getStereotypePropertyChange_Stereotype() { - return (EReference)stereotypePropertyChangeEClass.getEStructuralFeatures().get(0); + public EClass getStereotypeAttributeChange() { + return stereotypeAttributeChangeEClass; } /** @@ -344,8 +338,7 @@ public class UMLComparePackageImpl extends EPackageImpl implements UMLComparePac messageChangeEClass = createEClass(MESSAGE_CHANGE); - stereotypePropertyChangeEClass = createEClass(STEREOTYPE_PROPERTY_CHANGE); - createEReference(stereotypePropertyChangeEClass, STEREOTYPE_PROPERTY_CHANGE__STEREOTYPE); + stereotypeAttributeChangeEClass = createEClass(STEREOTYPE_ATTRIBUTE_CHANGE); stereotypeApplicationChangeEClass = createEClass(STEREOTYPE_APPLICATION_CHANGE); createEReference(stereotypeApplicationChangeEClass, STEREOTYPE_APPLICATION_CHANGE__STEREOTYPE); @@ -399,7 +392,7 @@ public class UMLComparePackageImpl extends EPackageImpl implements UMLComparePac executionSpecificationChangeEClass.getESuperTypes().add(this.getUMLDiff()); intervalConstraintChangeEClass.getESuperTypes().add(this.getUMLDiff()); messageChangeEClass.getESuperTypes().add(this.getUMLDiff()); - stereotypePropertyChangeEClass.getESuperTypes().add(this.getUMLDiff()); + stereotypeAttributeChangeEClass.getESuperTypes().add(this.getUMLDiff()); stereotypeApplicationChangeEClass.getESuperTypes().add(this.getUMLDiff()); stereotypeReferenceChangeEClass.getESuperTypes().add(this.getUMLDiff()); profileApplicationChangeEClass.getESuperTypes().add(this.getUMLDiff()); @@ -419,8 +412,7 @@ public class UMLComparePackageImpl extends EPackageImpl implements UMLComparePac initEClass(messageChangeEClass, MessageChange.class, "MessageChange", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEClass(stereotypePropertyChangeEClass, StereotypePropertyChange.class, "StereotypePropertyChange", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getStereotypePropertyChange_Stereotype(), theUMLPackage.getStereotype(), null, "stereotype", null, 0, 1, StereotypePropertyChange.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEClass(stereotypeAttributeChangeEClass, StereotypeAttributeChange.class, "StereotypeAttributeChange", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEClass(stereotypeApplicationChangeEClass, StereotypeApplicationChange.class, "StereotypeApplicationChange", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference(getStereotypeApplicationChange_Stereotype(), theUMLPackage.getStereotype(), null, "stereotype", null, 0, 1, StereotypeApplicationChange.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareAdapterFactory.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareAdapterFactory.java index bf6ddc36a..33cb1abac 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareAdapterFactory.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareAdapterFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012, 2014 Obeo. + * Copyright (c) 2012, 2013 Obeo. * 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 @@ -14,39 +14,26 @@ import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; import org.eclipse.emf.compare.Diff; -import org.eclipse.emf.compare.uml2.internal.AssociationChange; -import org.eclipse.emf.compare.uml2.internal.DirectedRelationshipChange; -import org.eclipse.emf.compare.uml2.internal.ExecutionSpecificationChange; -import org.eclipse.emf.compare.uml2.internal.ExtendChange; -import org.eclipse.emf.compare.uml2.internal.GeneralizationSetChange; -import org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange; -import org.eclipse.emf.compare.uml2.internal.MessageChange; -import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; -import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; -import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; -import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.compare.uml2.internal.*; import org.eclipse.emf.ecore.EObject; /** * The Adapter Factory for the model. It provides an adapter * createXXX method for each class of the model. - * * @see org.eclipse.emf.compare.uml2.internal.UMLComparePackage * @generated */ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { /** - * The cached model package. - * + * The cached model package. + * * @generated */ protected static UMLComparePackage modelPackage; /** - * Creates an instance of the adapter factory. - * + * Creates an instance of the adapter factory. + * * @generated */ public UMLCompareAdapterFactory() { @@ -56,10 +43,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Returns whether this factory is applicable for the type of the object. This + * Returns whether this factory is applicable for the type of the object. + * This * implementation returns true if the object is either the model's package or is an instance * object of the model. - * * @return whether this factory is applicable for the type of the object. * @generated */ @@ -75,88 +62,74 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * The switch that delegates to the createXXX methods. - * * @generated */ protected UMLCompareSwitch modelSwitch = new UMLCompareSwitch() { - @Override - public Adapter caseAssociationChange(AssociationChange object) { - return createAssociationChangeAdapter(); - } - - @Override - public Adapter caseExtendChange(ExtendChange object) { - return createExtendChangeAdapter(); - } - - @Override - public Adapter caseGeneralizationSetChange(GeneralizationSetChange object) { - return createGeneralizationSetChangeAdapter(); - } - - @Override - public Adapter caseExecutionSpecificationChange(ExecutionSpecificationChange object) { - return createExecutionSpecificationChangeAdapter(); - } - - @Override - public Adapter caseIntervalConstraintChange(IntervalConstraintChange object) { - return createIntervalConstraintChangeAdapter(); - } - - @Override - public Adapter caseMessageChange(MessageChange object) { - return createMessageChangeAdapter(); - } - - @Override - public Adapter caseStereotypePropertyChange(StereotypePropertyChange object) { - return createStereotypePropertyChangeAdapter(); - } - - @Override - public Adapter caseStereotypeApplicationChange(StereotypeApplicationChange object) { - return createStereotypeApplicationChangeAdapter(); - } - - @Override - public Adapter caseStereotypeReferenceChange(StereotypeReferenceChange object) { - return createStereotypeReferenceChangeAdapter(); - } - - @Override - public Adapter caseProfileApplicationChange(ProfileApplicationChange object) { - return createProfileApplicationChangeAdapter(); - } - - @Override - public Adapter caseDirectedRelationshipChange(DirectedRelationshipChange object) { - return createDirectedRelationshipChangeAdapter(); - } - - @Override - public Adapter caseUMLDiff(UMLDiff object) { - return createUMLDiffAdapter(); - } - - @Override - public Adapter caseDiff(Diff object) { - return createDiffAdapter(); - } - - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; + @Override + public Adapter caseAssociationChange(AssociationChange object) { + return createAssociationChangeAdapter(); + } + @Override + public Adapter caseExtendChange(ExtendChange object) { + return createExtendChangeAdapter(); + } + @Override + public Adapter caseGeneralizationSetChange(GeneralizationSetChange object) { + return createGeneralizationSetChangeAdapter(); + } + @Override + public Adapter caseExecutionSpecificationChange(ExecutionSpecificationChange object) { + return createExecutionSpecificationChangeAdapter(); + } + @Override + public Adapter caseIntervalConstraintChange(IntervalConstraintChange object) { + return createIntervalConstraintChangeAdapter(); + } + @Override + public Adapter caseMessageChange(MessageChange object) { + return createMessageChangeAdapter(); + } + @Override + public Adapter caseStereotypeAttributeChange(StereotypeAttributeChange object) { + return createStereotypeAttributeChangeAdapter(); + } + @Override + public Adapter caseStereotypeApplicationChange(StereotypeApplicationChange object) { + return createStereotypeApplicationChangeAdapter(); + } + @Override + public Adapter caseStereotypeReferenceChange(StereotypeReferenceChange object) { + return createStereotypeReferenceChangeAdapter(); + } + @Override + public Adapter caseProfileApplicationChange(ProfileApplicationChange object) { + return createProfileApplicationChangeAdapter(); + } + @Override + public Adapter caseDirectedRelationshipChange(DirectedRelationshipChange object) { + return createDirectedRelationshipChangeAdapter(); + } + @Override + public Adapter caseUMLDiff(UMLDiff object) { + return createUMLDiffAdapter(); + } + @Override + public Adapter caseDiff(Diff object) { + return createDiffAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; /** - * Creates an adapter for the target. - * - * @param target - * the object to adapt. + * Creates an adapter for the target. + * + * @param target the object to adapt. * @return the adapter for the target. * @generated */ @@ -180,11 +153,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.ExtendChange Extend Change}'. This default implementation returns null so that we can easily ignore cases; it's useful to ignore * a case when inheritance will catch all the cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.ExtendChange * @generated @@ -194,12 +166,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.GeneralizationSetChange - * Generalization Set Change}'. This default implementation returns null + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.GeneralizationSetChange Generalization Set Change}'. + * This default implementation returns null * so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the * cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.GeneralizationSetChange * @generated @@ -209,12 +179,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.ExecutionSpecificationChange - * Execution Specification Change}'. This default implementation returns + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.ExecutionSpecificationChange Execution Specification Change}'. + * This default implementation returns * null so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all * the cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.ExecutionSpecificationChange * @generated @@ -224,12 +192,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange - * Interval Constraint Change}'. This default implementation returns null + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange Interval Constraint Change}'. + * This default implementation returns null * so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the * cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange * @generated @@ -253,27 +219,23 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange - * Stereotype Property Change}'. This default implementation returns null + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange Stereotype Attribute Change}'. + * This default implementation returns null * so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the * cases anyway. - * * @return the new adapter. - * @see org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange + * @see org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange * @generated */ - public Adapter createStereotypePropertyChangeAdapter() { + public Adapter createStereotypeAttributeChangeAdapter() { return null; } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange - * Stereotype Application Change}'. This default implementation returns + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange Stereotype Application Change}'. + * This default implementation returns * null so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all * the cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange * @generated @@ -283,12 +245,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange - * Stereotype Reference Change}'. This default implementation returns + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange Stereotype Reference Change}'. + * This default implementation returns * null so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all * the cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange * @generated @@ -298,12 +258,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange - * Profile Application Change}'. This default implementation returns null + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange Profile Application Change}'. + * This default implementation returns null * so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the * cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange * @generated @@ -313,12 +271,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class ' - * {@link org.eclipse.emf.compare.uml2.internal.DirectedRelationshipChange - * Directed Relationship Change}'. This default implementation returns + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.DirectedRelationshipChange Directed Relationship Change}'. + * This default implementation returns * null so that we can easily ignore cases; it's useful to ignore a case when inheritance will catch all * the cases anyway. - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.DirectedRelationshipChange * @generated @@ -328,11 +284,10 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.UMLDiff - * UML Diff}'. This default implementation returns null so that we can + * Creates a new adapter for an object of class '{@link org.eclipse.emf.compare.uml2.internal.UMLDiff UML Diff}'. + * This default implementation returns null so that we can * easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. * - * * @return the new adapter. * @see org.eclipse.emf.compare.uml2.internal.UMLDiff * @generated @@ -355,9 +310,9 @@ public class UMLCompareAdapterFactory extends AdapterFactoryImpl { } /** - * Creates a new adapter for the default case. This default implementation returns + * Creates a new adapter for the default case. + * This default implementation returns * null. - * * @return the new adapter. * @generated */ diff --git a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareSwitch.java b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareSwitch.java index e16264d7b..97481b91e 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareSwitch.java +++ b/plugins/org.eclipse.emf.compare.uml2/src-gen/org/eclipse/emf/compare/uml2/internal/util/UMLCompareSwitch.java @@ -22,7 +22,7 @@ import org.eclipse.emf.compare.uml2.internal.IntervalConstraintChange; import org.eclipse.emf.compare.uml2.internal.MessageChange; import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypePropertyChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; import org.eclipse.emf.compare.uml2.internal.UMLComparePackage; import org.eclipse.emf.compare.uml2.internal.UMLDiff; @@ -141,11 +141,11 @@ public class UMLCompareSwitch { if (result == null) result = defaultCase(theEObject); return result; } - case UMLComparePackage.STEREOTYPE_PROPERTY_CHANGE: { - StereotypePropertyChange stereotypePropertyChange = (StereotypePropertyChange)theEObject; - T result = caseStereotypePropertyChange(stereotypePropertyChange); - if (result == null) result = caseUMLDiff(stereotypePropertyChange); - if (result == null) result = caseDiff(stereotypePropertyChange); + case UMLComparePackage.STEREOTYPE_ATTRIBUTE_CHANGE: { + StereotypeAttributeChange stereotypeAttributeChange = (StereotypeAttributeChange)theEObject; + T result = caseStereotypeAttributeChange(stereotypeAttributeChange); + if (result == null) result = caseUMLDiff(stereotypeAttributeChange); + if (result == null) result = caseDiff(stereotypeAttributeChange); if (result == null) result = defaultCase(theEObject); return result; } @@ -277,15 +277,17 @@ public class UMLCompareSwitch { } /** - * Returns the result of interpreting the object as an instance of 'Stereotype Property Change'. - * This implementation returns null; returning a non-null result will terminate - * the switch. + * Returns the result of interpreting the object as an instance of 'Stereotype Attribute Change'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Stereotype Property Change'. + * @return the result of interpreting the object as an instance of 'Stereotype Attribute Change'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ - public T caseStereotypePropertyChange(StereotypePropertyChange object) { + public T caseStereotypeAttributeChange(StereotypeAttributeChange object) { return null; } diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java index f7632e8ec..e6b74e9bc 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java @@ -556,7 +556,7 @@ public abstract class AbstractUMLChangeFactory extends AbstractChangeFactory { * The difference. * @return True if it is related to a CHANGE in an ADD/DELETE. */ - private boolean isChangeOnAddOrDelete(Diff input) { + protected boolean isChangeOnAddOrDelete(Diff input) { if (getRelatedExtensionKind(input) == DifferenceKind.CHANGE) { final Comparison comparison = input.getMatch().getComparison(); final EObject discriminant = getDiscriminant(input); @@ -581,8 +581,9 @@ public abstract class AbstractUMLChangeFactory extends AbstractChangeFactory { */ private boolean isChangeOnAddOrDelete(Diff input, final Comparison comparison, final EObject discriminant) { boolean result = false; - if (Iterables.any(comparison.getMatch(discriminant).getDifferences(), - instanceOf(ResourceAttachmentChange.class))) { + Match match = comparison.getMatch(discriminant); + if (match != null + && Iterables.any(match.getDifferences(), instanceOf(ResourceAttachmentChange.class))) { result = true; } if (!result) { diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java index 5b8042a50..5773d9867 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java @@ -18,8 +18,8 @@ import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import java.util.Collection; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -245,7 +245,7 @@ public class UMLPostProcessor implements IPostProcessor { final Map, IChangeFactory> mapUml2ExtensionFactories = UMLExtensionFactoryRegistry .createExtensionFactories(); - uml2ExtensionFactories = new HashSet(mapUml2ExtensionFactories.values()); + uml2ExtensionFactories = new LinkedHashSet(mapUml2ExtensionFactories.values()); // Creation of the UML difference extensions for (Diff diff : comparison.getDifferences()) { diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLExtensionFactoryRegistry.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLExtensionFactoryRegistry.java index 2ed01b213..9f19a0d90 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLExtensionFactoryRegistry.java +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLExtensionFactoryRegistry.java @@ -12,7 +12,7 @@ package org.eclipse.emf.compare.uml2.internal.postprocessor.extension; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -21,10 +21,12 @@ import org.eclipse.emf.compare.internal.postprocessor.factories.IChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz.UMLAssociationChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz.UMLGeneralizationSetChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.profile.UMLProfileApplicationChangeFactory; -import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.profile.UMLStereotypeApplicationChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.sequence.UMLExecutionSpecificationChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.sequence.UMLIntervalConstraintChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.sequence.UMLMessageChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype.UMLStereotypeApplicationChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype.UMLStereotypeAttributeChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype.UMLStereotypeReferenceChangeFactory; import org.eclipse.emf.compare.uml2.internal.postprocessor.extension.usecase.UMLExtendChangeFactory; /** @@ -48,7 +50,7 @@ public final class UMLExtensionFactoryRegistry { * @return an unmodifiable set of all {@link IDiffExtensionFactory}. */ public static Map, IChangeFactory> createExtensionFactories() { - final Map, IChangeFactory> dataset = new HashMap, IChangeFactory>(); + final Map, IChangeFactory> dataset = new LinkedHashMap, IChangeFactory>(); List factories = new ArrayList(); factories.add(new UMLAssociationChangeFactory()); @@ -59,6 +61,8 @@ public final class UMLExtensionFactoryRegistry { factories.add(new UMLExecutionSpecificationChangeFactory()); factories.add(new UMLIntervalConstraintChangeFactory()); factories.add(new UMLProfileApplicationChangeFactory()); + factories.add(new UMLStereotypeAttributeChangeFactory()); + factories.add(new UMLStereotypeReferenceChangeFactory()); factories.add(new UMLStereotypeApplicationChangeFactory()); for (IChangeFactory iDiffExtensionFactory : factories) { diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLStereotypeApplicationChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLStereotypeApplicationChangeFactory.java deleted file mode 100644 index 3fbd17a7a..000000000 --- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLStereotypeApplicationChangeFactory.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Obeo. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.profile; - -import static com.google.common.base.Predicates.instanceOf; - -import com.google.common.collect.Iterables; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.emf.compare.AttributeChange; -import org.eclipse.emf.compare.Comparison; -import org.eclipse.emf.compare.Diff; -import org.eclipse.emf.compare.DifferenceKind; -import org.eclipse.emf.compare.Match; -import org.eclipse.emf.compare.ReferenceChange; -import org.eclipse.emf.compare.ResourceAttachmentChange; -import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; -import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; -import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; -import org.eclipse.emf.compare.uml2.internal.UMLDiff; -import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory; -import org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil; -import org.eclipse.emf.compare.utils.MatchUtil; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature.Setting; -import org.eclipse.emf.ecore.util.EcoreSwitch; -import org.eclipse.emf.ecore.util.Switch; -import org.eclipse.uml2.common.util.UML2Util; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Profile; -import org.eclipse.uml2.uml.ProfileApplication; -import org.eclipse.uml2.uml.Stereotype; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.util.UMLUtil; - -/** - * Factory for stereotype application changes. - * - * @author Cedric Notot - */ -public class UMLStereotypeApplicationChangeFactory extends AbstractUMLChangeFactory { - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#getExtensionKind() - */ - @Override - public Class getExtensionKind() { - return StereotypeApplicationChange.class; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#createExtension() - */ - @Override - public UMLDiff createExtension() { - return UMLCompareFactory.eINSTANCE.createStereotypeApplicationChange(); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) - */ - @Override - protected EObject getDiscriminant(Diff input) { - return Iterables.find(getDiscriminants(input), instanceOf(EObject.class), null); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminantsGetter() - */ - @Override - protected Switch> getDiscriminantsGetter() { - return new EcoreSwitch>() { - @Override - public Set defaultCase(EObject object) { - Set result = new HashSet(); - if (object.eContainer() == null) { - result.add(object); - } else { - return defaultCaseForDiscriminantsGetter(this, object); - } - return result; - } - }; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#setRefiningChanges(org.eclipse.emf.compare.Diff, - * org.eclipse.emf.compare.DifferenceKind, org.eclipse.emf.compare.Diff) - */ - @Override - public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { - super.setRefiningChanges(extension, extensionKind, refiningDiff); - - EObject discriminant = getDiscriminant(refiningDiff); - - if (discriminant != null) { - final Iterator changes = refiningDiff.getMatch().getComparison().getMatch(discriminant) - .getDifferences().iterator(); - while (changes.hasNext()) { - final Diff diff = changes.next(); - if (diff instanceof AttributeChange || diff instanceof ReferenceChange - || diff instanceof ResourceAttachmentChange) { - extension.getRefinedBy().add(diff); - } - } - } - - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.AttributeChange) - */ - @Override - protected boolean isRelatedToAnExtensionChange(AttributeChange input) { - return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.ReferenceChange) - */ - @Override - protected boolean isRelatedToAnExtensionChange(ReferenceChange input) { - return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionAdd(org.eclipse.emf.compare.ReferenceChange) - */ - @Override - protected boolean isRelatedToAnExtensionAdd(ReferenceChange input) { - // do nothing - return false; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionDelete(org.eclipse.emf.compare.ReferenceChange) - */ - @Override - protected boolean isRelatedToAnExtensionDelete(ReferenceChange input) { - // do nothing - return false; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionAdd(org.eclipse.emf.compare.ResourceAttachmentChange) - */ - @Override - protected boolean isRelatedToAnExtensionAdd(ResourceAttachmentChange input) { - return input.getKind() == DifferenceKind.ADD - && UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), - input)) != null; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionDelete(org.eclipse.emf.compare.ResourceAttachmentChange) - */ - @Override - protected boolean isRelatedToAnExtensionDelete(ResourceAttachmentChange input) { - return input.getKind() == DifferenceKind.DELETE - && UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), - input)) != null; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#fillRequiredDifferences(org.eclipse.emf.compare.Comparison, - * org.eclipse.emf.compare.Diff) - */ - @Override - public void fillRequiredDifferences(Comparison comparison, Diff extension) { - super.fillRequiredDifferences(comparison, extension); - if (!(extension instanceof StereotypeApplicationChange)) { - return; - } - final StereotypeApplicationChange stereotypeApplicationChange = (StereotypeApplicationChange)extension; - if (stereotypeApplicationChange.getKind() == DifferenceKind.ADD) { - final Stereotype stereotype = UMLUtil - .getStereotype(stereotypeApplicationChange.getDiscriminant()); - if (stereotype != null) { - // FIXME this is not the place to set this, it should be done at creation time. - stereotypeApplicationChange.setStereotype(stereotype); - final Profile profile = stereotype.getProfile(); - fillRequirements(comparison, stereotypeApplicationChange, profile); - } - } - } - - /** - * It fills the requirements of the given stereotype application change from the profile related to the - * stereotype application. - * - * @param comparison - * the comparison. - * @param stereotypeApplicationChange - * The stereotype application to set. - * @param profile - * The profile related to the stereotype application. - */ - private void fillRequirements(Comparison comparison, - final StereotypeApplicationChange stereotypeApplicationChange, final Profile profile) { - final Iterator settings = UML2Util.getInverseReferences(profile).iterator(); - while (settings.hasNext()) { - final Setting setting = settings.next(); - if (setting.getEStructuralFeature() == UMLPackage.Literals.PROFILE_APPLICATION__APPLIED_PROFILE) { - final ProfileApplication profileApplication = (ProfileApplication)setting.getEObject(); - for (Diff diff : comparison.getDifferences(profileApplication)) { - if (diff instanceof ProfileApplicationChange && diff.getKind() == DifferenceKind.ADD) { - stereotypeApplicationChange.getRequires().add(diff); - } - } - } - } - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getParentMatch(org.eclipse.emf.compare.Diff) - */ - @Override - public Match getParentMatch(Diff input) { - final EObject discriminant = getDiscriminant(input); - if (discriminant != null) { - final Element element = UMLCompareUtil.getBaseElement(discriminant); - final Match match = input.getMatch().getComparison().getMatch(element); - if (match != null) { - return match; - } - } - return super.getParentMatch(input); - } - -} diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java new file mode 100644 index 000000000..663b81607 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype; + +import static com.google.common.base.Predicates.instanceOf; + +import com.google.common.collect.Iterables; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.eclipse.emf.compare.AttributeChange; +import org.eclipse.emf.compare.Comparison; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.DifferenceKind; +import org.eclipse.emf.compare.Match; +import org.eclipse.emf.compare.ReferenceChange; +import org.eclipse.emf.compare.ResourceAttachmentChange; +import org.eclipse.emf.compare.uml2.internal.ProfileApplicationChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange; +import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; +import org.eclipse.emf.compare.uml2.internal.UMLDiff; +import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil; +import org.eclipse.emf.compare.utils.MatchUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.util.EcoreSwitch; +import org.eclipse.emf.ecore.util.Switch; +import org.eclipse.uml2.common.util.UML2Util; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.ProfileApplication; +import org.eclipse.uml2.uml.Stereotype; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.util.UMLUtil; + +/** + * Factory for stereotype application changes. + * + * @author Cedric Notot + */ +public class UMLStereotypeApplicationChangeFactory extends AbstractUMLChangeFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#getExtensionKind() + */ + @Override + public Class getExtensionKind() { + return StereotypeApplicationChange.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#createExtension() + */ + @Override + public UMLDiff createExtension() { + return UMLCompareFactory.eINSTANCE.createStereotypeApplicationChange(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) + */ + @Override + protected EObject getDiscriminant(Diff input) { + return Iterables.find(getDiscriminants(input), instanceOf(EObject.class), null); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminantsGetter() + */ + @Override + protected Switch> getDiscriminantsGetter() { + return new EcoreSwitch>() { + @Override + public Set defaultCase(EObject object) { + Set result = new HashSet(); + if (object.eContainer() == null) { + result.add(object); + } else { + return defaultCaseForDiscriminantsGetter(this, object); + } + return result; + } + }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#setRefiningChanges(org.eclipse.emf.compare.Diff, + * org.eclipse.emf.compare.DifferenceKind, org.eclipse.emf.compare.Diff) + */ + @Override + public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { + super.setRefiningChanges(extension, extensionKind, refiningDiff); + + EObject discriminant = getDiscriminant(refiningDiff); + + if (discriminant != null) { + final Iterator changes = refiningDiff.getMatch().getComparison().getMatch(discriminant) + .getDifferences().iterator(); + while (changes.hasNext()) { + final Diff diff = changes.next(); + if (diff instanceof AttributeChange || diff instanceof ReferenceChange + || diff instanceof ResourceAttachmentChange) { + extension.getRefinedBy().add(diff); + } + } + } + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.AttributeChange) + */ + @Override + protected boolean isRelatedToAnExtensionChange(AttributeChange input) { + return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.ReferenceChange) + */ + @Override + protected boolean isRelatedToAnExtensionChange(ReferenceChange input) { + return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionAdd(org.eclipse.emf.compare.ReferenceChange) + */ + @Override + protected boolean isRelatedToAnExtensionAdd(ReferenceChange input) { + // do nothing + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#isRelatedToAnExtensionDelete(org.eclipse.emf.compare.ReferenceChange) + */ + @Override + protected boolean isRelatedToAnExtensionDelete(ReferenceChange input) { + // do nothing + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionAdd(org.eclipse.emf.compare.ResourceAttachmentChange) + */ + @Override + protected boolean isRelatedToAnExtensionAdd(ResourceAttachmentChange input) { + return input.getKind() == DifferenceKind.ADD + && UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), + input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionDelete(org.eclipse.emf.compare.ResourceAttachmentChange) + */ + @Override + protected boolean isRelatedToAnExtensionDelete(ResourceAttachmentChange input) { + return input.getKind() == DifferenceKind.DELETE + && UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), + input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#fillRequiredDifferences(org.eclipse.emf.compare.Comparison, + * org.eclipse.emf.compare.Diff) + */ + @Override + public void fillRequiredDifferences(Comparison comparison, Diff extension) { + super.fillRequiredDifferences(comparison, extension); + if (!(extension instanceof StereotypeApplicationChange)) { + return; + } + final StereotypeApplicationChange stereotypeApplicationChange = (StereotypeApplicationChange)extension; + if (stereotypeApplicationChange.getKind() == DifferenceKind.ADD) { + final Stereotype stereotype = UMLUtil + .getStereotype(stereotypeApplicationChange.getDiscriminant()); + if (stereotype != null) { + // FIXME this is not the place to set this, it should be done at creation time. + stereotypeApplicationChange.setStereotype(stereotype); + final Profile profile = stereotype.getProfile(); + fillRequirements(comparison, stereotypeApplicationChange, profile); + } + } + } + + /** + * It fills the requirements of the given stereotype application change from the profile related to the + * stereotype application. + * + * @param comparison + * the comparison. + * @param stereotypeApplicationChange + * The stereotype application to set. + * @param profile + * The profile related to the stereotype application. + */ + private void fillRequirements(Comparison comparison, + final StereotypeApplicationChange stereotypeApplicationChange, final Profile profile) { + final Iterator settings = UML2Util.getInverseReferences(profile).iterator(); + while (settings.hasNext()) { + final Setting setting = settings.next(); + if (setting.getEStructuralFeature() == UMLPackage.Literals.PROFILE_APPLICATION__APPLIED_PROFILE) { + final ProfileApplication profileApplication = (ProfileApplication)setting.getEObject(); + for (Diff diff : comparison.getDifferences(profileApplication)) { + if (diff instanceof ProfileApplicationChange && diff.getKind() == DifferenceKind.ADD) { + stereotypeApplicationChange.getRequires().add(diff); + } + } + } + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getParentMatch(org.eclipse.emf.compare.Diff) + */ + @Override + public Match getParentMatch(Diff input) { + final EObject discriminant = getDiscriminant(input); + if (discriminant != null) { + final Element element = UMLCompareUtil.getBaseElement(discriminant); + final Match match = input.getMatch().getComparison().getMatch(element); + if (match != null) { + return match; + } + } + return super.getParentMatch(input); + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java new file mode 100644 index 000000000..d7f4cd78e --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype; + +import static com.google.common.base.Predicates.instanceOf; + +import com.google.common.collect.Iterables; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.compare.AttributeChange; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.DifferenceKind; +import org.eclipse.emf.compare.Match; +import org.eclipse.emf.compare.uml2.internal.StereotypeAttributeChange; +import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil; +import org.eclipse.emf.compare.utils.MatchUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreSwitch; +import org.eclipse.emf.ecore.util.Switch; +import org.eclipse.uml2.uml.Element; + +/** + * Factory for stereotype string property changes. + * + * @author Axel Richard + */ +public class UMLStereotypeAttributeChangeFactory extends AbstractUMLChangeFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#handles(org.eclipse.emf.compare.Diff) + */ + @Override + public boolean handles(Diff input) { + if (input instanceof AttributeChange) { + return super.handles(input); + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminantsGetter() + */ + @Override + protected Switch> getDiscriminantsGetter() { + return new EcoreSwitch>() { + @Override + public Set defaultCase(EObject object) { + Set result = new HashSet(); + if (object.eContainer() == null) { + result.add(object); + } else { + return defaultCaseForDiscriminantsGetter(this, object); + } + return result; + } + }; + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse + * .emf.compare.Diff) + */ + @Override + protected EObject getDiscriminant(Diff input) { + final EObject discriminant; + if (input instanceof AttributeChange) { + discriminant = ((AttributeChange)input).getAttribute(); + } else { + discriminant = Iterables.find(getDiscriminants(input), instanceOf(EObject.class), null); + } + return discriminant; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#createExtension() + */ + @Override + public Diff createExtension() { + return UMLCompareFactory.eINSTANCE.createStereotypeAttributeChange(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#getExtensionKind() + */ + @Override + public Class getExtensionKind() { + return StereotypeAttributeChange.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.AttributeChange) + */ + @Override + protected boolean isRelatedToAnExtensionChange(AttributeChange input) { + return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#setRefiningChanges(org.eclipse.emf.compare.Diff, + * org.eclipse.emf.compare.DifferenceKind, org.eclipse.emf.compare.Diff) + */ + @Override + public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { + extension.getRefinedBy().add(refiningDiff); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getParentMatch(org.eclipse.emf.compare.Diff) + */ + @Override + public Match getParentMatch(Diff input) { + Match match = input.getMatch(); + if (match != null) { + EObject object = match.getLeft(); + if (object == null) { + object = match.getRight(); + } + if (object == null) { + object = match.getOrigin(); + } + final Element element = UMLCompareUtil.getBaseElement(object); + match = match.getComparison().getMatch(element); + } + return match; + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java new file mode 100644 index 000000000..c4415d3ef --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2013 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype; + +import static com.google.common.base.Predicates.instanceOf; + +import com.google.common.collect.Iterables; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.DifferenceKind; +import org.eclipse.emf.compare.Match; +import org.eclipse.emf.compare.ReferenceChange; +import org.eclipse.emf.compare.uml2.internal.StereotypeReferenceChange; +import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory; +import org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil; +import org.eclipse.emf.compare.utils.MatchUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreSwitch; +import org.eclipse.emf.ecore.util.Switch; +import org.eclipse.uml2.uml.Element; + +/** + * Factory for stereotype reference changes. + * + * @author Axel Richard + */ +public class UMLStereotypeReferenceChangeFactory extends AbstractUMLChangeFactory { + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#handles(org.eclipse.emf.compare.Diff) + */ + @Override + public boolean handles(Diff input) { + if (input instanceof ReferenceChange) { + return super.handles(input); + } + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminantsGetter() + */ + @Override + protected Switch> getDiscriminantsGetter() { + return new EcoreSwitch>() { + @Override + public Set defaultCase(EObject object) { + Set result = new HashSet(); + if (object.eContainer() == null) { + result.add(object); + } else { + return defaultCaseForDiscriminantsGetter(this, object); + } + return result; + } + }; + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse + * .emf.compare.Diff) + */ + @Override + protected EObject getDiscriminant(Diff input) { + final EObject discriminant; + if (input instanceof ReferenceChange) { + discriminant = ((ReferenceChange)input).getReference(); + } else { + discriminant = Iterables.find(getDiscriminants(input), instanceOf(EObject.class), null); + } + return discriminant; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#createExtension() + */ + @Override + public Diff createExtension() { + return UMLCompareFactory.eINSTANCE.createStereotypeReferenceChange(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#getExtensionKind() + */ + @Override + public Class getExtensionKind() { + return StereotypeReferenceChange.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#isRelatedToAnExtensionChange(org.eclipse.emf.compare.ReferenceChange) + */ + @Override + protected boolean isRelatedToAnExtensionChange(ReferenceChange input) { + return UMLCompareUtil.getBaseElement(MatchUtil.getContainer(input.getMatch().getComparison(), input)) != null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#setRefiningChanges(org.eclipse.emf.compare.Diff, + * org.eclipse.emf.compare.DifferenceKind, org.eclipse.emf.compare.Diff) + */ + @Override + public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) { + extension.getRefinedBy().add(refiningDiff); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getParentMatch(org.eclipse.emf.compare.Diff) + */ + @Override + public Match getParentMatch(Diff input) { + Match match = input.getMatch(); + if (match != null) { + EObject object = match.getLeft(); + if (object == null) { + object = match.getRight(); + } + if (object == null) { + object = match.getOrigin(); + } + final Element element = UMLCompareUtil.getBaseElement(object); + match = match.getComparison().getMatch(element); + } + return match; + } +} diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AttributeChangeMerger.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AttributeChangeMerger.java index 896537cc9..308577d78 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AttributeChangeMerger.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AttributeChangeMerger.java @@ -23,8 +23,12 @@ import org.eclipse.emf.compare.Diff; import org.eclipse.emf.compare.DifferenceSource; import org.eclipse.emf.compare.Match; import org.eclipse.emf.compare.internal.utils.DiffUtil; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.DynamicEObjectImpl; /** * This specific implementation of {@link AbstractMerger} will be used to merge attribute changes. @@ -355,8 +359,18 @@ public class AttributeChangeMerger extends AbstractMerger { } else { originContainer = match.getLeft(); } - - final Object targetValue = safeEGet(originContainer, attribute); + + final Object targetValue; + final Object value = safeEGet(originContainer, attribute); + + // Case of change of EnumLiteral of an attribute of a DynamicEObject : we need to retrieve the + // EnumLiteral instance of the target which is not the same than the source. + if (expectedContainer instanceof DynamicEObjectImpl && value instanceof EEnumLiteral) { + targetValue = ((EEnum)((EEnumLiteral)safeEGet(expectedContainer, attribute)).eContainer()) + .getEEnumLiteral(((ENamedElement)value).getName()); + } else { + targetValue = value; + } // Though not the "default value", we consider that an empty string is an unset attribute. final Object defaultValue = attribute.getDefaultValue(); diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/ReferenceChangeMerger.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/ReferenceChangeMerger.java index aa833b797..56b1c00b4 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/ReferenceChangeMerger.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/ReferenceChangeMerger.java @@ -86,7 +86,7 @@ public class ReferenceChangeMerger extends AbstractMerger { container = referenceChange.getMatch().getRight(); } // Is it an unset? - if (container != null) { + if (container != null) { final EObject leftValue = (EObject)safeEGet(container, referenceChange.getReference()); if (leftValue == null) { // Value has been unset in the right, and we are merging towards right. @@ -137,7 +137,7 @@ public class ReferenceChangeMerger extends AbstractMerger { } else { container = referenceChange.getMatch().getRight(); } - // Is it an unset? + // Is it an unset? if (container != null) { final EObject leftValue = (EObject)safeEGet(container, referenceChange.getReference()); if (leftValue == null) { @@ -500,7 +500,7 @@ public class ReferenceChangeMerger extends AbstractMerger { if (originContainer == null || !safeEIsSet(targetContainer, reference) || !safeEIsSet(originContainer, reference)) { - targetContainer.eUnset(reference); + targetContainer.eUnset(reference); } else { final EObject originalValue = (EObject)safeEGet(originContainer, reference); final Match valueMatch = match.getComparison().getMatch(originalValue); diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/ReferenceUtil.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/ReferenceUtil.java index 18c05b375..a73496963 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/ReferenceUtil.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/ReferenceUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Obeo. + * Copyright (c) 2012, 2014 Obeo. * 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 -- cgit v1.2.3