Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfesenko2011-03-08 15:46:32 +0000
committertfesenko2011-03-08 15:46:32 +0000
commite745a8d908de5b28761f44c892886d70e04c6aff (patch)
tree5c24968287c182c778c458c740934710d4eecf72 /extraplugins/compare
parent67c3abe452809693e14891857e25f2e8dfb63497 (diff)
downloadorg.eclipse.papyrus-e745a8d908de5b28761f44c892886d70e04c6aff.tar.gz
org.eclipse.papyrus-e745a8d908de5b28761f44c892886d70e04c6aff.tar.xz
org.eclipse.papyrus-e745a8d908de5b28761f44c892886d70e04c6aff.zip
Extract UI to the dedicated plugin
Diffstat (limited to 'extraplugins/compare')
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/META-INF/MANIFEST.MF17
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/Activator.java23
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/PapyrusLabelProvider.java132
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/action/CompareTwoElementsAction.java176
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/ElementContentMergeContentProvider.java62
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewer.java131
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewerCreator.java30
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLAdapterFactory.java41
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLModelContentMergeTabFolder.java93
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/ModelContentMergeDiffTabContentProvider.java128
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/UMLModelContentMergeDiffTab.java63
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/Match2ElementsWithDiff.java157
-rw-r--r--extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/UMLPropertyContentProvider.java90
13 files changed, 1140 insertions, 3 deletions
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/META-INF/MANIFEST.MF b/extraplugins/compare/org.eclipse.papyrus.compare.ui/META-INF/MANIFEST.MF
index 23891660bce..9c287088856 100644
--- a/extraplugins/compare/org.eclipse.papyrus.compare.ui/META-INF/MANIFEST.MF
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/META-INF/MANIFEST.MF
@@ -6,6 +6,21 @@ Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.papyrus.compare.ui.Activator
Bundle-Vendor: CEA LIST
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.eclipse.compare;bundle-version="3.5.200",
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.papyrus.compare;bundle-version="0.7.1",
+ org.eclipse.emf.compare.diff;bundle-version="1.1.1",
+ org.eclipse.emf.compare;bundle-version="1.1.1",
+ org.eclipse.emf.compare.ui;bundle-version="1.1.1",
+ org.eclipse.emf.compare.match;bundle-version="1.1.1",
+ org.eclipse.emf.edit;bundle-version="2.7.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.custom.core;bundle-version="0.1.0",
+ org.eclipse.team.ui;bundle-version="3.5.200",
+ org.eclipse.uml2.uml;bundle-version="3.1.100",
+ org.eclipse.uml2.uml.edit;bundle-version="3.1.100",
+ org.eclipse.emf.edit.ui;bundle-version="2.6.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/Activator.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/Activator.java
index 710d94cd9a1..1ce1cf4a743 100644
--- a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/Activator.java
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/Activator.java
@@ -1,5 +1,7 @@
package org.eclipse.papyrus.compare.ui;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -13,7 +15,7 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
-
+
/**
* The constructor
*/
@@ -22,6 +24,7 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@@ -31,6 +34,7 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -40,11 +44,26 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
+ public static void logError(Throwable e) {
+ logError("Unexpected error: ", e);
+ }
+
+ public static void logError(String message, Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ getDefault().getLog().log(status);
+ }
+
+ public static void logInfo(String message) {
+ IStatus status = new Status(IStatus.INFO, PLUGIN_ID, message);
+ getDefault().getLog().log(status);
+ }
+
+
}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/PapyrusLabelProvider.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/PapyrusLabelProvider.java
new file mode 100644
index 00000000000..9f86936b3b1
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/PapyrusLabelProvider.java
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.AppearanceConfiguration;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.papyrus.compare.Activator;
+import org.eclipse.swt.graphics.Image;
+
+
+public class PapyrusLabelProvider extends CustomizableModelLabelProvider {
+
+
+ private AppearanceConfiguration configuration;
+
+ /**
+ * Constructor.
+ *
+ * @param customizationManager
+ */
+ public PapyrusLabelProvider(CustomizationManager customizationManager) {
+ super(customizationManager);
+ configuration = getAppearanceConfiguration(customizationManager);
+ }
+
+ public PapyrusLabelProvider() {
+ this(initCustomizationManager());
+ }
+
+ private static CustomizationManager initCustomizationManager() {
+ CustomizationManager manager = new CustomizationManager();
+ try {
+ List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
+ for(MetamodelView metamodelView : registryDefaultCustomizations) {
+ manager.registerCustomization(metamodelView);
+ }
+ manager.loadCustomizations();
+
+ } catch (Throwable e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$
+ }
+ manager.setShowFullQualifiedNames(false);
+ manager.setShowURI(true);
+ manager.setShowDerivedLinks(false);
+ return manager;
+ }
+
+ private AppearanceConfiguration getAppearanceConfiguration(CustomizationManager customizationManager2) {
+ Method getApperanceConfigurationMethod;
+ try {
+ getApperanceConfigurationMethod = CustomizationManager.class.getDeclaredMethod("getAppearanceConfiguration"); //$NON-NLS-1$
+ if(getApperanceConfigurationMethod != null) {
+ getApperanceConfigurationMethod.setAccessible(true);
+ return (AppearanceConfiguration)getApperanceConfigurationMethod.invoke(customizationManager2);
+ }
+ } catch (SecurityException e) {
+ Activator.logError(e);
+ } catch (NoSuchMethodException e) {
+ Activator.logError(e);
+ } catch (IllegalArgumentException e) {
+ Activator.logError(e);
+ } catch (IllegalAccessException e) {
+ Activator.logError(e);
+ } catch (InvocationTargetException e) {
+ Activator.logError(e);
+ }
+ return new AppearanceConfiguration(null); // default one.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ if(element == null) {
+ return ""; //$NON-NLS-1$
+ }
+ if(element instanceof EObject) {
+ ITreeElement treeElement = getTreeElement((EObject)element);
+ return super.getText(treeElement);
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if(element == null) {
+ return null;
+ }
+ if(element instanceof EObject) {
+ ITreeElement treeElement = getTreeElement((EObject)element);
+ return super.getImage(treeElement);
+ }
+ return super.getImage(element);
+ }
+
+
+ /**
+ * @param eObject
+ * @return
+ */
+ private ITreeElement getTreeElement(EObject eObject) {
+ if(eObject == null) {
+ return null;
+ }
+ return new ModelElementItem(eObject, getTreeElement(eObject.eContainer()), configuration);
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/action/CompareTwoElementsAction.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/action/CompareTwoElementsAction.java
new file mode 100644
index 00000000000..67a5385afdf
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/action/CompareTwoElementsAction.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.action;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.compare.EMFCompareException;
+import org.eclipse.emf.compare.diff.metamodel.AbstractDiffExtension;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.DiffFactory;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.service.DiffService;
+import org.eclipse.emf.compare.match.MatchOptions;
+import org.eclipse.emf.compare.match.engine.GenericMatchScopeProvider;
+import org.eclipse.emf.compare.match.engine.IMatchEngine;
+import org.eclipse.emf.compare.match.metamodel.MatchModel;
+import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput;
+import org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewer;
+import org.eclipse.emf.compare.util.EMFCompareMap;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.compare.diff.extension.UMLStyledStructureLabelProvider;
+import org.eclipse.papyrus.compare.element.ElementContentDiffEngine;
+import org.eclipse.papyrus.compare.element.ElementContentMatchEngine;
+import org.eclipse.papyrus.compare.ui.Activator;
+import org.eclipse.papyrus.compare.ui.PapyrusLabelProvider;
+import org.eclipse.papyrus.compare.ui.viewer.content.ElementContentMergeContentProvider;
+import org.eclipse.papyrus.compare.ui.viewer.content.UMLModelContentMergeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.ui.PlatformUI;
+
+public class CompareTwoElementsAction extends TeamAction {
+
+ protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
+
+ Object[] selectedElements = getSelection().toArray();
+ if(selectedElements.length != 2) {
+ Activator.logInfo("Cannot compare elements: 2 elements should be selected, but only " + selectedElements.length + " is selected");
+ return;
+ }
+
+ EObject left = getElementFor(selectedElements[0]);
+ EObject right = getElementFor(selectedElements[1]);
+ if(left == null) {
+ Activator.logInfo("Cannot compare elements: left element is null");
+ return;
+ }
+
+ if(right == null) {
+ Activator.logInfo("Cannot compare elements: right element is null");
+ return;
+ }
+
+ ComparisonResourceSnapshot snapshot = doContentCompare(left, right);
+ openInCompare(snapshot);
+ }
+
+ public boolean isEnabled() {
+ Object[] selectedElements = getSelection().toArray();
+ if(selectedElements.length != 2) {
+ return false;
+ }
+ EObject left = getElementFor(selectedElements[0]);
+ EObject right = getElementFor(selectedElements[1]);
+ return left != null && right != null;
+ }
+
+ private void openInCompare(ComparisonSnapshot snapshot) {
+ CompareUI.openCompareEditor(new ModelCompareEditorInput(snapshot) {
+
+ @Override
+ protected ModelContentMergeViewer createMergeViewer(CompareViewerPane pane, CompareConfiguration config) {
+ return new UMLModelContentMergeViewer(pane, config) {
+ @Override
+ protected IMergeViewerContentProvider createMergeViewerContentProvider() {
+ return new ElementContentMergeContentProvider(configuration);
+ }
+ };
+ }
+
+ @Override
+ public Control createOutlineContents(Composite parent, int direction) {
+ Control result = super.createOutlineContents(parent, direction);
+ structureMergeViewer.setLabelProvider(new UMLStyledStructureLabelProvider(new PapyrusLabelProvider()));
+ return result;
+ }
+
+ });
+ }
+
+ protected ComparisonResourceSnapshot doContentCompare(final EObject left, final EObject right) {
+ final ComparisonResourceSnapshot snapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
+
+ try {
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) throws InterruptedException {
+ final MatchModel match = contentMatch(left, right, monitor);
+ final DiffModel diff = contentDiff(left, right, match);
+
+ snapshot.setDiff(diff);
+ snapshot.setMatch(match);
+ }
+
+ });
+ } catch (final InterruptedException e) {
+ Activator.logError(e);
+ } catch (final EMFCompareException e) {
+ Activator.logError(e);
+ } catch (final InvocationTargetException e) {
+ Activator.logError(e);
+ }
+ return snapshot;
+ }
+
+ protected DiffModel contentDiff(final EObject left, final EObject right, final MatchModel match) {
+ ElementContentDiffEngine engine = new ElementContentDiffEngine(left, right);
+ final DiffModel diff = engine.doDiff(match);
+ final Collection<AbstractDiffExtension> extensions = DiffService.getCorrespondingDiffExtensions(match);
+ for(final AbstractDiffExtension ext : extensions) {
+ if(ext != null) {
+ ext.visit(diff);
+ }
+ }
+
+ engine.reset();
+ return diff;
+ }
+
+ protected MatchModel contentMatch(final EObject left, final EObject right, IProgressMonitor monitor) throws InterruptedException {
+ final Map<String, Object> options = new EMFCompareMap<String, Object>();
+ options.put(MatchOptions.OPTION_PROGRESS_MONITOR, monitor);
+ options.put(MatchOptions.OPTION_MATCH_SCOPE_PROVIDER, new GenericMatchScopeProvider(left.eResource(), right.eResource()));
+ options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
+ options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
+
+ final IMatchEngine matchEngine = new ElementContentMatchEngine(left, right);
+ final MatchModel match = matchEngine.contentMatch(left, right, options);
+ return match;
+ }
+
+ protected EObject getElementFor(Object object) {
+ if(object instanceof IAdaptable) {
+ return (EObject)((IAdaptable)object).getAdapter(EObject.class);
+ }
+
+ if(object instanceof EObject) {
+ return (EObject)object;
+ }
+ return null;
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/ElementContentMergeContentProvider.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/ElementContentMergeContentProvider.java
new file mode 100644
index 00000000000..46dfdd3492c
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/ElementContentMergeContentProvider.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
+import org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeContentProvider;
+import org.eclipse.papyrus.compare.diff.metamodel.uml_diff_extension.CompareTwoElementsDiffModel;
+
+
+public class ElementContentMergeContentProvider extends ModelContentMergeContentProvider {
+
+ public ElementContentMergeContentProvider(CompareConfiguration cc) {
+ super(cc);
+ }
+
+ @Override
+ public Object getLeftContent(Object element) {
+ if(element instanceof ModelCompareInput) {
+ // if we compared a complete resource set, we should display the different resources
+ final Object diff = ((ModelCompareInput)element).getDiff();
+ if(diff instanceof CompareTwoElementsDiffModel) {
+ return new RootObject(((CompareTwoElementsDiffModel)diff).getLeftRoots().get(0));
+ }
+ }
+ return super.getLeftContent(element);
+ }
+
+ @Override
+ public Object getRightContent(Object element) {
+ if(element instanceof ModelCompareInput) {
+ // if we compared a complete resource set, we should display the different resources
+ final Object diff = ((ModelCompareInput)element).getDiff();
+ if(diff instanceof CompareTwoElementsDiffModel) {
+ return new RootObject(((CompareTwoElementsDiffModel)diff).getRightRoots().get(0));
+ }
+ }
+ return super.getRightContent(element);
+ }
+
+ public static class RootObject {
+
+ public final Object object;
+
+ public RootObject(Object object) {
+ this.object = object;
+ }
+ }
+
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewer.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewer.java
new file mode 100644
index 00000000000..389c319a96b
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewer.java
@@ -0,0 +1,131 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.ui.ICompareEditorPartListener;
+import org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewer;
+import org.eclipse.emf.compare.ui.viewer.content.part.ModelContentMergeTabFolder;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.compare.Activator;
+import org.eclipse.papyrus.compare.ui.viewer.content.part.UMLModelContentMergeTabFolder;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class UMLModelContentMergeViewer extends ModelContentMergeViewer {
+
+ private static final String VIEWER_SETTINGS_GROUP = "viewer";//$NON-NLS-1$
+
+ private static final String SHOW_ALL_PRORPERTIES_IMAGE_PATH = "/icons/show_all_properties.gif"; //$NON-NLS-1$
+
+ private IAction myShowAllProperties;
+
+ private ICompareEditorPartListener myPropertyTabSelectionListener;
+
+ private UMLModelContentMergeTabFolder myLeftPart;
+
+ public UMLModelContentMergeViewer(Composite parent, CompareConfiguration config) {
+ super(parent, config);
+ }
+
+ @Override
+ protected ModelContentMergeTabFolder createModelContentMergeTabFolder(Composite composite, int side) {
+ return new UMLModelContentMergeTabFolder(this, composite, side);
+ }
+
+ @Override
+ protected void createControls(Composite composite) {
+ super.createControls(composite);
+ myPropertyTabSelectionListener = new PropertyTabSelectionListener();
+ leftPart.addCompareEditorPartListener(myPropertyTabSelectionListener);
+ rightPart.addCompareEditorPartListener(myPropertyTabSelectionListener);
+ ancestorPart.addCompareEditorPartListener(myPropertyTabSelectionListener);
+ myLeftPart = (UMLModelContentMergeTabFolder)leftPart;
+ }
+
+ @Override
+ protected void createToolItems(ToolBarManager tbm) {
+ super.createToolItems(tbm);
+ tbm.add(new Separator(VIEWER_SETTINGS_GROUP));
+ myShowAllProperties = new Action("Show All Properties", IAction.AS_CHECK_BOX) {
+
+ @Override
+ public void run() {
+ showAllProperties();
+ }
+ };
+ boolean isEnabled = isPropertyTab(myLeftPart.getSelectedTab());
+ myShowAllProperties.setEnabled(isEnabled);
+ myShowAllProperties.setEnabled(false);
+ myShowAllProperties.setToolTipText("Show All Properties of the Element");
+ myShowAllProperties.setImageDescriptor(ImageDescriptor.createFromImage(Activator.getImage(SHOW_ALL_PRORPERTIES_IMAGE_PATH)));
+
+ final ActionContributionItem showAllPropertiesContribution = new ActionContributionItem(myShowAllProperties);
+ showAllPropertiesContribution.setVisible(true);
+ tbm.appendToGroup(VIEWER_SETTINGS_GROUP, showAllPropertiesContribution); //$NON-NLS-1$
+ }
+
+ protected void showAllProperties() {
+ setSelection(new ArrayList<DiffElement>(currentSelection));
+ }
+
+ protected void propertyTabSelected(boolean isActive) {
+ if(isActive) {
+ myShowAllProperties.setEnabled(true);
+ } else {
+ myShowAllProperties.setEnabled(false);
+ }
+ }
+
+ private boolean isPropertyTab(int index) {
+ return myLeftPart.isPropertyTab(index);
+ }
+
+ public boolean isShowAllProperties() {
+ return myShowAllProperties.isChecked();
+ }
+
+ public List<DiffElement> getCurrentSelection() {
+ return currentSelection;
+ }
+
+ /**
+ * Bug 338414 - [UML Compare] Filter only changes properties in the Merge Property Viewer
+ */
+ private class PropertyTabSelectionListener implements ICompareEditorPartListener {
+
+ public void selectedTabChanged(int newIndex) {
+ UMLModelContentMergeViewer.this.propertyTabSelected(isPropertyTab(newIndex));
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ // do nothing
+ }
+
+ public void updateCenter() {
+ // do nothing
+ }
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewerCreator.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewerCreator.java
new file mode 100644
index 00000000000..bb362a325ef
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/UMLModelContentMergeViewerCreator.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class UMLModelContentMergeViewerCreator implements IViewerCreator {
+ /**
+ * {@inheritDoc}
+ */
+ public Viewer createViewer(Composite parent, CompareConfiguration config) {
+ return new UMLModelContentMergeViewer(parent, config);
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLAdapterFactory.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLAdapterFactory.java
new file mode 100644
index 00000000000..71442c992e8
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLAdapterFactory.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+import org.eclipse.uml2.uml.edit.providers.UMLReflectiveItemProviderAdapterFactory;
+import org.eclipse.uml2.uml.edit.providers.UMLResourceItemProviderAdapterFactory;
+
+
+public class UMLAdapterFactory extends ComposedAdapterFactory {
+
+ private final static List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
+ static {
+ factories.add(new UMLResourceItemProviderAdapterFactory());
+ factories.add(new UMLItemProviderAdapterFactory());
+ factories.add(new EcoreItemProviderAdapterFactory());
+ factories.add(new UMLReflectiveItemProviderAdapterFactory());
+ }
+
+ public UMLAdapterFactory() {
+ super(factories);
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLModelContentMergeTabFolder.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLModelContentMergeTabFolder.java
new file mode 100644
index 00000000000..c5c82efb043
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/UMLModelContentMergeTabFolder.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part;
+
+import org.eclipse.emf.compare.match.metamodel.Match2Elements;
+import org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewer;
+import org.eclipse.emf.compare.ui.viewer.content.part.IModelContentMergeViewerTab;
+import org.eclipse.emf.compare.ui.viewer.content.part.ModelContentMergeTabFolder;
+import org.eclipse.emf.compare.ui.viewer.content.part.property.ModelContentMergePropertyTab;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.papyrus.compare.UMLCompareUtils;
+import org.eclipse.papyrus.compare.ui.PapyrusLabelProvider;
+import org.eclipse.papyrus.compare.ui.viewer.content.ElementContentMergeContentProvider.RootObject;
+import org.eclipse.papyrus.compare.ui.viewer.content.UMLModelContentMergeViewer;
+import org.eclipse.papyrus.compare.ui.viewer.content.part.diff.UMLModelContentMergeDiffTab;
+import org.eclipse.papyrus.compare.ui.viewer.content.part.property.Match2ElementsWithDiff;
+import org.eclipse.papyrus.compare.ui.viewer.content.part.property.UMLPropertyContentProvider;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class UMLModelContentMergeTabFolder extends ModelContentMergeTabFolder {
+
+ protected final UMLModelContentMergeViewer myUMLViewer;
+
+ public UMLModelContentMergeTabFolder(ModelContentMergeViewer viewer, Composite composite, int side) {
+ super(viewer, composite, side);
+ myUMLViewer = (UMLModelContentMergeViewer)viewer;
+ }
+
+ @Override
+ protected IModelContentMergeViewerTab createModelContentMergeDiffTab(Composite parent) {
+ UMLModelContentMergeDiffTab diffTab = new UMLModelContentMergeDiffTab(parent, partSide, this);
+ diffTab.setContentProvider(createDiffTabContentProvider());
+ diffTab.setLabelProvider(new PapyrusLabelProvider());
+ return diffTab;
+
+ }
+
+ @Override
+ protected IModelContentMergeViewerTab createModelContentMergeViewerTab(Composite parent) {
+ ModelContentMergePropertyTab propertyTab = new ModelContentMergePropertyTab(parent, partSide, this);
+ propertyTab.setContentProvider(new UMLPropertyContentProvider());
+ return propertyTab;
+ }
+
+ protected IContentProvider createDiffTabContentProvider() {
+ ComposedAdapterFactory adapterFactory = new UMLAdapterFactory();
+ AdapterFactoryContentProvider result = new AdapterFactoryContentProvider(adapterFactory) {
+
+ @Override
+ public Object[] getElements(Object object) {
+ if(object instanceof RootObject) {
+ return new Object[]{ ((RootObject)object).object };
+ }
+ return super.getElements(object);
+ }
+ };
+
+ return result;
+ }
+
+ protected EObject findMatchFromElement(EObject element) {
+ EObject matchElement = super.findMatchFromElement(element);
+ if(!myUMLViewer.isShowAllProperties() && matchElement instanceof Match2Elements) {
+ return new Match2ElementsWithDiff((Match2Elements)matchElement, myUMLViewer.getCurrentSelection().get(0));
+ }
+ return matchElement;
+ }
+
+ public int getSelectedTab() {
+ return tabFolder.getSelectionIndex();
+ }
+
+ public boolean isPropertyTab(int index) {
+ final IModelContentMergeViewerTab currentTab = tabs.get(index);
+ return (currentTab == getPropertyPart());
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/ModelContentMergeDiffTabContentProvider.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/ModelContentMergeDiffTabContentProvider.java
new file mode 100644
index 00000000000..60ba1b36007
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/ModelContentMergeDiffTabContentProvider.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part.diff;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.ui.TypedElementWrapper;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.papyrus.compare.UMLCompareUtils;
+import org.eclipse.uml2.uml.Element;
+
+
+public class ModelContentMergeDiffTabContentProvider extends AdapterFactoryContentProvider {
+
+
+ /**
+ * Default constructor. Delegates to the super implementation.
+ *
+ * @param factory
+ * Factory to get labels and icons from.
+ */
+ public ModelContentMergeDiffTabContentProvider(AdapterFactory factory) {
+ super(factory);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#getElements(java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object[] getElements(Object object) {
+ // overwritten to ensure contents of ResourceSets, List<Resource>, and Resource are correclty
+ // returned.
+ Object[] result = null;
+ if(object instanceof ResourceSet) {
+ final List<Resource> resources = ((ResourceSet)object).getResources();
+ final List<Resource> elements = new ArrayList<Resource>(resources.size());
+ for(final Resource resource : resources) {
+ if(resource.getContents().isEmpty() || !(resource.getContents().get(0) instanceof ComparisonSnapshot)) {
+ elements.add(resource);
+ }
+ }
+ result = elements.toArray();
+ } else if(object instanceof TypedElementWrapper) {
+ result = new Object[]{ ((EObject)object).eResource(), };
+ } else if(object instanceof List) {
+ // we may also display a list of resources
+ result = ((List)object).toArray();
+ } else if(object instanceof Resource) {
+ // return contents of resource
+ return filterStereotypeApplications((Resource)object);
+ } else {
+ result = super.getElements(object);
+ }
+ return result;
+ }
+
+ private Object[] filterStereotypeApplications(Resource object) {
+ EList<EObject> contents = object.getContents();
+ List<EObject> result = new ArrayList<EObject>();
+ for(int i = 0; i < contents.size(); i++) {
+ EObject next = contents.get(i);
+ if(!UMLCompareUtils.isStereotypeApplication(next)) {
+ result.add(next);
+ }
+ }
+ return result.toArray(new Object[result.size()]);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object object) {
+ if(object instanceof Resource) {
+ // return ((Resource)object).getContents().toArray();
+ return new Object[]{ ((Resource)object).getContents().get(0) };
+ }
+ ArrayList<Object> result = new ArrayList<Object>();
+ result.addAll(Arrays.asList(super.getChildren(object)));
+ result.addAll(getStereotypeApplications(object));
+ return result.toArray(new Object[result.size()]);
+ }
+
+ private List<EObject> getStereotypeApplications(Object eObject) {
+ if(eObject instanceof Element) {
+ return ((Element)eObject).getStereotypeApplications();
+ }
+ return Collections.emptyList();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ return getChildren(object).length > 0;
+ }
+
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/UMLModelContentMergeDiffTab.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/UMLModelContentMergeDiffTab.java
new file mode 100644
index 00000000000..7c20b148b4c
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/diff/UMLModelContentMergeDiffTab.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part.diff;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.compare.ui.viewer.content.part.ModelContentMergeTabFolder;
+import org.eclipse.emf.compare.ui.viewer.content.part.diff.ModelContentMergeDiffTab;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.compare.UMLCompareUtils;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+
+public class UMLModelContentMergeDiffTab extends ModelContentMergeDiffTab {
+
+
+ public UMLModelContentMergeDiffTab(Composite parentComposite, int side, ModelContentMergeTabFolder parentFolder) {
+ super(parentComposite, side, parentFolder);
+ }
+
+ @Override
+ protected void setSelectionToWidget(List l, boolean reveal) {
+ // tfesenko filter stereotype applications
+ List result = new ArrayList();
+ for(Object next : l) {
+ if(next instanceof EObject && UMLCompareUtils.isStereotypeApplication((EObject)next)) {
+ EObject stereotypeApplication = (EObject)next;
+ result.add(UMLUtil.getBaseElement(stereotypeApplication));
+ } else {
+ result.add(next);
+ }
+ }
+ super.setSelectionToWidget(result, reveal);
+ }
+
+ @Override
+ public void setReflectiveInput(Object object) {
+ // tfesenko 336361 - [UML Compare] Compare two elements: show right element as root
+ if (object instanceof EObject) {
+ clearCaches();
+ // tfesenko default implementation sets object.eResource here
+ setInput(object);
+ setupCaches();
+ needsRedraw = true;
+ }
+ super.setReflectiveInput(object);
+ }
+
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/Match2ElementsWithDiff.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/Match2ElementsWithDiff.java
new file mode 100644
index 00000000000..b130493a208
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/Match2ElementsWithDiff.java
@@ -0,0 +1,157 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part.property;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.match.metamodel.Match2Elements;
+import org.eclipse.emf.compare.match.metamodel.MatchElement;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+
+
+public class Match2ElementsWithDiff implements Match2Elements {
+
+ private Match2Elements myDelegate;
+
+ private DiffElement myDiffElement;
+
+ public Match2ElementsWithDiff(Match2Elements delegate, DiffElement diffElement) {
+ myDelegate = delegate;
+ myDiffElement = diffElement;
+ }
+
+ public DiffElement getDiffElement() {
+ return myDiffElement;
+ }
+
+ @Override
+ public String toString() {
+ return myDelegate.toString() + " " + (myDiffElement == null ? "" : myDiffElement.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public double getSimilarity() {
+ return myDelegate.getSimilarity();
+ }
+
+ public EList<MatchElement> getSubMatchElements() {
+ return myDelegate.getSubMatchElements();
+ }
+
+ public void setSimilarity(double value) {
+ myDelegate.setSimilarity(value);
+ }
+
+ public EClass eClass() {
+ return myDelegate.eClass();
+ }
+
+ public Resource eResource() {
+ return myDelegate.eResource();
+ }
+
+ public EObject eContainer() {
+ return myDelegate;
+ }
+
+ public EStructuralFeature eContainingFeature() {
+ return myDelegate.eContainingFeature();
+ }
+
+ public EReference eContainmentFeature() {
+ return myDelegate.eContainmentFeature();
+ }
+
+ public EList<EObject> eContents() {
+ return myDelegate.eContents();
+ }
+
+ public TreeIterator<EObject> eAllContents() {
+ return myDelegate.eAllContents();
+ }
+
+ public boolean eIsProxy() {
+ return myDelegate.eIsProxy();
+ }
+
+ public EList<EObject> eCrossReferences() {
+ return myDelegate.eCrossReferences();
+ }
+
+ public Object eGet(EStructuralFeature feature) {
+ return myDelegate.eGet(feature);
+ }
+
+ public Object eGet(EStructuralFeature feature, boolean resolve) {
+ return myDelegate.eGet(feature, resolve);
+ }
+
+ public void eSet(EStructuralFeature feature, Object newValue) {
+ myDelegate.eSet(feature, newValue);
+ }
+
+ public boolean eIsSet(EStructuralFeature feature) {
+ return myDelegate.eIsSet(feature);
+ }
+
+ public void eUnset(EStructuralFeature feature) {
+ myDelegate.eUnset(feature);
+ }
+
+ public Object eInvoke(EOperation operation, EList<?> arguments) throws InvocationTargetException {
+ return myDelegate.eInvoke(operation, arguments);
+ }
+
+ public EList<Adapter> eAdapters() {
+ return myDelegate.eAdapters();
+ }
+
+ public boolean eDeliver() {
+ return myDelegate.eDeliver();
+ }
+
+ public void eSetDeliver(boolean deliver) {
+ myDelegate.eSetDeliver(deliver);
+ }
+
+ public void eNotify(Notification notification) {
+ myDelegate.eNotify(notification);
+ }
+
+ public EObject getLeftElement() {
+ return myDelegate.getLeftElement();
+ }
+
+ public EObject getRightElement() {
+ return myDelegate.getRightElement();
+ }
+
+ public void setLeftElement(EObject value) {
+ myDelegate.setLeftElement(value);
+ }
+
+ public void setRightElement(EObject value) {
+ myDelegate.setRightElement(value);
+ }
+
+}
diff --git a/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/UMLPropertyContentProvider.java b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/UMLPropertyContentProvider.java
new file mode 100644
index 00000000000..a532a321f04
--- /dev/null
+++ b/extraplugins/compare/org.eclipse.papyrus.compare.ui/src/org/eclipse/papyrus/compare/ui/viewer/content/part/property/UMLPropertyContentProvider.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.compare.ui.viewer.content.part.property;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChange;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChange;
+import org.eclipse.emf.compare.ui.viewer.content.part.property.PropertyContentProvider;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public class UMLPropertyContentProvider extends PropertyContentProvider {
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ Object[] elements = super.getElements(inputElement);
+ if(inputElement instanceof Match2ElementsWithDiff) {
+ DiffElement diffElement = ((Match2ElementsWithDiff)inputElement).getDiffElement();
+ return findRowsForFeatures(elements, getChangedFeatures(diffElement));
+ }
+ return elements;
+ }
+
+ protected Object[] findRowsForFeatures(Object[] propertyRows, EStructuralFeature[] features) {
+ List<Object> result = new ArrayList<Object>();
+ for (EStructuralFeature feature : features) {
+ Object row = findPropertyRowFor(propertyRows, feature);
+ if(row != null) {
+ result.add(row);
+ }
+ }
+ return result.toArray(new Object[result.size()]);
+ }
+
+ private EStructuralFeature[] getChangedFeatures(DiffElement diffElement) {
+ if(diffElement instanceof AttributeChange) {
+ EStructuralFeature feature = ((AttributeChange)diffElement).getAttribute();
+ return new EStructuralFeature[]{feature};
+ }
+ if(diffElement instanceof ReferenceChange) {
+ EStructuralFeature feature = ((ReferenceChange)diffElement).getReference();
+ return new EStructuralFeature[]{feature};
+ }
+ if(diffElement instanceof DiffGroup) {
+ EList<DiffElement> children = ((DiffGroup)diffElement).getSubDiffElements();
+ List<EStructuralFeature> result = new ArrayList<EStructuralFeature>();
+ for (DiffElement child: children) {
+ result.addAll(Arrays.asList(getChangedFeatures(child)));
+ }
+ return result.toArray(new EStructuralFeature[result.size()]);
+ }
+ return new EStructuralFeature[0];
+ }
+
+
+ private Object findPropertyRowFor(Object[] propertyRows, EStructuralFeature feature) {
+ for(Object nextRow : propertyRows) {
+ if(isTheSameFeature(feature, getFeatureFromPropertyRow(nextRow))) {
+ return nextRow;
+ }
+ }
+ return null;
+ }
+
+ private EStructuralFeature getFeatureFromPropertyRow(Object propertyRow) {
+ List<Object> row = (List<Object>)propertyRow;
+ return (EStructuralFeature)row.get(0);
+ }
+
+ private boolean isTheSameFeature(EStructuralFeature feature1, EStructuralFeature feature2) {
+ return feature1.getFeatureID() == feature2.getFeatureID() && feature1.getName().equals(feature2.getName());
+ }
+
+}

Back to the top