Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-05-07 15:01:36 +0000
committervlorenzo2012-05-07 15:01:36 +0000
commit7540adb6a92a53e76b4cc59ad26056da373b3867 (patch)
treefaeb828d95fa61083cef405200a0051358661aea /extraplugins
parent7351b1da77ec746ec98c7b5c6e40b20036af2e73 (diff)
downloadorg.eclipse.papyrus-7540adb6a92a53e76b4cc59ad26056da373b3867.tar.gz
org.eclipse.papyrus-7540adb6a92a53e76b4cc59ad26056da373b3867.tar.xz
org.eclipse.papyrus-7540adb6a92a53e76b4cc59ad26056da373b3867.zip
378689: [Releng] Add EMF-Compare projects to releng
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378689
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.classpath7
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.project28
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF27
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/about.html28
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/build.properties10
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc4
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties3
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml12
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/Activator.java70
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java302
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java303
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java115
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java224
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java176
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java21
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties3
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/modelresource/EMFCompareEditorModel.java108
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/EMFCompareUtils.java53
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/ICompareViewerProvider.java40
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java166
21 files changed, 1707 insertions, 0 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.classpath b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.project b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.project
new file mode 100644
index 00000000000..d6c8da15259
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.emf.compare.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..5f29eab0890
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.compare.common;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.infra.emf.compare.common.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.papyrus.infra.emf.compare.instance,
+ org.eclipse.compare,
+ org.eclipse.emf.compare.ui,
+ org.eclipse.emf.compare,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.compare.match,
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.infra.emf.compare.ui;bundle-version="0.9.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.9.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.infra.emf.compare.common,
+ org.eclipse.papyrus.infra.emf.compare.common.editor,
+ org.eclipse.papyrus.infra.emf.compare.common.factory,
+ org.eclipse.papyrus.infra.emf.compare.common.handler,
+ org.eclipse.papyrus.infra.emf.compare.common.modelresource,
+ org.eclipse.papyrus.infra.emf.compare.common.utils
+Bundle-Localization: plugin
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/about.html b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/build.properties b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/build.properties
new file mode 100644
index 00000000000..7299a10c1b3
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ plugin.pdoc,\
+ build.properties,\
+ about.html
+src.includes = about.html
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc
new file mode 100644
index 00000000000..2bc2b2b7241
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="This plugin provides common for the CompareEditor integration inside the PapyrusSashEditora CompareEditor for Papyrus. This CompareEditor is done&#xD;&#xA;to be opened in the sasheditor as the others papyrus editors (diagram and table)&#xD;&#xA;This editor is &quot;partially volatile&quot;, that is to say, we lose all its information when we close it, &#xD;&#xA;but we don't lose it when we close Papyrus or Eclipse (see bug 371606)&#xD;&#xA;">
+ <referent firstName="vincent" lastName="lorenzo" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA-LIST"/>
+</doc:Documentation>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties
new file mode 100644
index 00000000000..d6b8baf2f09
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.infra.emf.compare.common
+providerName = Eclipse Modeling Project
+pluginName = Common Plugin for Papyrus Compare Editor (Incubation) \ No newline at end of file
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml
new file mode 100644
index 00000000000..c7d232618d8
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.core.model">
+ <model
+ classname="org.eclipse.papyrus.infra.emf.compare.common.modelresource.EMFCompareEditorModel"
+ description="The model for the PapyrusCompareEditor">
+ </model>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/Activator.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/Activator.java
new file mode 100644
index 00000000000..779c3fbb3c9
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/Activator.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.emf.compare.common"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** the Papyrus log helper */
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java
new file mode 100644
index 00000000000..4e19dc11971
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java
@@ -0,0 +1,302 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.editor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import org.eclipse.compare.internal.CompareEditor;
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IOperationHistoryListener;
+import org.eclipse.core.commands.operations.OperationHistoryEvent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.compare.EMFCompareException;
+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.IMatchScopeProvider;
+import org.eclipse.emf.compare.match.metamodel.MatchModel;
+import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput;
+import org.eclipse.emf.compare.util.EMFCompareMap;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.utils.ICompareViewerProvider;
+import org.eclipse.papyrus.infra.emf.compare.common.utils.PapyrusModelCompareEditorInput;
+import org.eclipse.papyrus.infra.emf.compare.ui.provider.EMFCompareLabelProvider;
+import org.eclipse.papyrus.infra.emf.compare.ui.utils.ICustomizableEditor;
+import org.eclipse.papyrus.infra.emf.compare.ui.utils.LabelProviderUtil;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ *
+ * This abstract allows to regroup the configuration for the Papyrus nested compare editor
+ * and the standalone Papyrus Compare Editor
+ *
+ */
+@SuppressWarnings("restriction")
+//suppress restriction for CompareEditor
+public abstract class AbstractPapyrusCompareEditor extends CompareEditor implements ICustomizableEditor, IEditingDomainProvider {
+
+
+ /**
+ * The listener on the operation history to catch the Undo/Redo and update the upper viewer
+ */
+ private IOperationHistoryListener historyListener;
+
+
+ /**
+ * The label provider for this editor
+ */
+ private EMFCompareLabelProvider labelProvider;
+
+ public AbstractPapyrusCompareEditor() {
+ super();
+ }
+
+ protected final void addUndoRedoListeners() {
+ final IOperationHistory operationHistory = getIOperationHistory();
+ operationHistory.addOperationHistoryListener(getUndoRedoListener());
+ }
+
+ /**
+ * Remove the listener on the Undo/Redo
+ */
+ protected void removeUndoRedoListener() {
+ final IOperationHistory operationHistory = getIOperationHistory();
+ operationHistory.removeOperationHistoryListener(getUndoRedoListener());
+ }
+
+ public EMFCompareLabelProvider getLabelProvider() {
+ if(labelProvider == null) {
+ labelProvider = LabelProviderUtil.createLabelProvider();
+ }
+ return labelProvider;
+ }
+
+ /**
+ *
+ * @param monitor
+ * the monitor
+ * @param left
+ * the left object
+ * @param right
+ * the right object
+ * @return
+ * the options for the comparison
+ */
+ //TODO verify the options to use for UML
+ protected Map<String, Object> getCompareOptions(final IProgressMonitor monitor, final EObject left, final EObject right) {
+ final Map<String, Object> options = new EMFCompareMap<String, Object>();
+ options.put(MatchOptions.OPTION_PROGRESS_MONITOR, monitor);
+ options.put(MatchOptions.OPTION_MATCH_SCOPE_PROVIDER, getMatchScopeProvider(left, right));
+ options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE); //TODO verify this parameter
+ options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE); //TODO verify this parameter
+ return options;
+ }
+
+ /**
+ *
+ * @param left
+ * the left object
+ * @param right
+ * the right object
+ * @return
+ * the match scope provider
+ */
+ //TODO verify the option to use for UML
+ protected IMatchScopeProvider getMatchScopeProvider(final EObject left, final EObject right) {
+ return new GenericMatchScopeProvider(left.eResource(), right.eResource());
+ }
+
+
+ @Override
+ public void setFocus() {
+ //I refresh the viewer here, because the EMF queries for name, ... are called during the creation of the editor, and
+ //it is not the correct Editor which is used by these queries to get the correct label provider
+ //
+ refreshViewers();
+ super.setFocus();
+ }
+
+ /**
+ *
+ * @param left
+ * the left eobject
+ * @param right
+ * the rihgt eobject
+ * @return
+ * the ComparisinSnapshot
+ */
+ protected ComparisonSnapshot doContentCompare(final EObject left, final EObject right) {
+ final ComparisonResourceSnapshot snapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
+
+ try {
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
+
+ public void run(final IProgressMonitor monitor) throws InterruptedException {
+ final Map<String, Object> options = getCompareOptions(monitor, left, right);
+ final MatchModel match = doContentMatch(left, right, options);
+ DiffModel diff = doDiff(match);
+ snapshot.setDiff(diff);
+ snapshot.setMatch(match);
+ }
+
+ });
+
+ } catch (final InterruptedException e) {
+ Activator.log.error(e);
+ } catch (final EMFCompareException e) {
+ Activator.log.error(e);
+ } catch (final InvocationTargetException e) {
+ Activator.log.error(e);
+ }
+
+ return snapshot;
+ }
+
+ /**
+ *
+ * @param left
+ * @param right
+ * @param options
+ * @return
+ * the MatchModel for the comparison
+ * @throws InterruptedException
+ */
+ protected MatchModel doContentMatch(final EObject left, final EObject right, final Map<String, Object> options) throws InterruptedException {
+ return MatchService.doContentMatch(left, right, options);
+ }
+
+ /**
+ *
+ * @param match
+ * @return
+ * the DiffModel for the comparison
+ */
+ protected DiffModel doDiff(final MatchModel match) {
+ return DiffService.doDiff(match);
+ }
+
+ /**
+ *
+ * @param left
+ * @param right
+ * @return
+ */
+ protected final ModelCompareEditorInput getCompareInput(final EObject left, final EObject right) {
+ final ComparisonSnapshot snapshot = doContentCompare(left, right);
+ return getConfiguredModelCompareEditorInput(snapshot);
+ }
+
+ /**
+ *
+ * @param snapshot
+ * the ComparisonSnapshot
+ * @return
+ * the ModelCompareEditorInput for this snapshot
+ */
+ //TODO try to set this method in private
+ private final ModelCompareEditorInput getConfiguredModelCompareEditorInput(final ComparisonSnapshot snapshot) {
+ final ModelCompareEditorInput input = createModelCompareEditorInput(snapshot);
+ configureInput((PapyrusModelCompareEditorInput)input);
+ return input;
+ }
+
+ protected ModelCompareEditorInput createModelCompareEditorInput(final ComparisonSnapshot snapshot) {
+ return new PapyrusModelCompareEditorInput(snapshot, this);
+ }
+
+ /**
+ * This method allows to set label and image to use for this input
+ *
+ * @param input
+ * the input
+ */
+ protected abstract void configureInput(final PapyrusModelCompareEditorInput input);
+
+ /**
+ *
+ */
+ protected void addListeners() {
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.compare.ui.utils.ICustomizableEditor#refreshViewers()
+ *
+ */
+ public void refreshViewers() {
+ final IEditorInput input = this.getEditorInput();
+ if(input instanceof ICompareViewerProvider) {
+ final Viewer contentViewer = ((ICompareViewerProvider)input).getContentMergeViewer();
+ final Viewer structureViewer = ((ICompareViewerProvider)input).getStructureMergeViewer();
+ if(contentViewer != null) {
+ contentViewer.refresh();
+ }
+ if(structureViewer != null) {
+ structureViewer.refresh();
+ }
+ }
+ }
+
+ protected IOperationHistoryListener getUndoRedoListener() {
+ if(this.historyListener == null) {
+ this.historyListener = new IOperationHistoryListener() {
+
+ /** the last catched event */
+ private OperationHistoryEvent lastEvent = null;
+
+ /**
+ *
+ * @see org.eclipse.core.commands.operations.IOperationHistoryListener#historyNotification(org.eclipse.core.commands.operations.OperationHistoryEvent)
+ *
+ * @param event
+ */
+ public void historyNotification(final OperationHistoryEvent event) {
+ int eventType = event.getEventType();
+ if(eventType == 10 || eventType == 9) {
+ if(this.lastEvent != event) {
+ this.lastEvent = event;
+ if(!event.getOperation().getLabel().equals("Create CompareEditor")) {//TODO improve it!
+ resetInput();
+ }
+ }
+ }
+ }
+
+ private void resetInput() {
+ AbstractPapyrusCompareEditor.this.resetInput();
+ }
+ };
+ }
+ return this.historyListener;
+ }
+
+ protected abstract IOperationHistory getIOperationHistory();
+
+ /**
+ * reset the input in the viewer
+ */
+ protected abstract void resetInput();
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java
new file mode 100644
index 00000000000..a8a016f7e65
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java
@@ -0,0 +1,303 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.editor;
+
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.editor.listener.CloseEditorTriggerListener;
+import org.eclipse.papyrus.infra.emf.compare.common.utils.EMFCompareUtils;
+import org.eclipse.papyrus.infra.emf.compare.common.utils.PapyrusModelCompareEditorInput;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusEMFCompareInstance;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.ISaveablesLifecycleListener;
+import org.eclipse.ui.ISaveablesSource;
+import org.eclipse.ui.PartInitException;
+
+/**
+ *
+ * This class provides an EMF-Compare Editor for Papyrus. This Editor has been created to be embedded in the Papyrus SashEditor
+ *
+ */
+public class EMFCompareEditor extends AbstractPapyrusCompareEditor implements IReusableEditor, ISaveablesSource, IPropertyChangeListener, ISaveablesLifecycleListener {
+
+ /** the service registry */
+ protected ServicesRegistry servicesRegistry;
+
+ private CloseEditorTriggerListener closeListener;
+
+ protected PapyrusEMFCompareInstance rawModel;
+
+
+ /**
+ * The compare editor input
+ */
+ private CompareEditorInput input;//TODO move it in the supper class?
+
+ private PartNameSynchronizer synchronizer;
+
+ /**
+ *
+ * @see org.eclipse.compare.internal.CompareEditor#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ *
+ * @param event
+ */
+ @Override
+ public void propertyChange(final PropertyChangeEvent event) {
+ if(event.getSource() == IAction.class && event.getProperty() == CompareEditorInput.PROP_TITLE) {
+ //the CustomizationAction of the viewer sent this refresh
+ setPartName(EMFCompareUtils.getCompareEditorTitle(EMFCompareEditor.this, rawModel));
+ } else {
+ super.propertyChange(event);
+ }
+ }
+
+
+ /**
+ * @param servicesRegistry
+ * the service registry
+ * @param rawModel
+ * the raw model
+ *
+ */
+ public EMFCompareEditor(final ServicesRegistry servicesRegistry, final PapyrusEMFCompareInstance rawModel) {
+ this.servicesRegistry = servicesRegistry;
+ this.rawModel = rawModel;
+ this.synchronizer = new PartNameSynchronizer(rawModel);
+ this.input = getCompareInput(rawModel.getLeft(), rawModel.getRight());
+ addListeners();
+ }
+
+
+ protected EMFCompareEditor() {
+ //FIXME, used by the compare UMl File Editor, try to merge code
+ super();
+ }
+
+
+
+ @Override
+ protected void addListeners() {
+ addUndoRedoListeners();
+ if(EMFCompareEditor.this.servicesRegistry != null) {//we are in papyrus
+ TransactionalEditingDomain domain = null;
+ try {
+ domain = EMFCompareEditor.this.servicesRegistry.getService(TransactionalEditingDomain.class);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+
+ closeListener = new CloseEditorTriggerListener(this.rawModel, this.servicesRegistry);
+ domain.addResourceSetListener(closeListener);
+ }
+ }
+
+ /**
+ * Remove the listener
+ */
+ protected void removeListeners() {
+ removeUndoRedoListener();
+ //done by the CloseTriggerlistener. Here, it is too early to remove it
+ // if(EMFCompareEditor.this.servicesRegistry != null) {//we are in papyrus
+ // TransactionalEditingDomain domain = null;
+ // try {
+ // domain = EMFCompareEditor.this.servicesRegistry.getService(TransactionalEditingDomain.class);
+ // } catch (ServiceException e) {
+ // Activator.log.error(e);
+ // }
+ //
+ // domain.removeResourceSetListener(closeListener);
+ // }
+ }
+
+ protected ISashWindowsContainer getISashWindowsContainer() {
+ ISashWindowsContainer container = null;
+ if(EMFCompareEditor.this.servicesRegistry != null) {//we are in papyrus
+ try {
+ container = ServiceUtils.getInstance().getISashWindowsContainer(this.servicesRegistry);
+ } catch (ServiceException e) {
+ Activator.log.error("I can't get the ISashWindowsContainer to add a listener on it", e); //$NON-NLS-1$
+ }
+ }
+ return container;
+ }
+
+
+
+ /**
+ *
+ * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ *
+ * @param site
+ * @param input
+ * @throws PartInitException
+ */
+ @Override
+ public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
+ if(input instanceof CompareEditorInput) {
+ super.init(site, input);
+ } else {
+ super.init(site, this.input);
+ }
+
+ }
+
+ @Override
+ public void dispose() {
+ removeListeners();
+ super.dispose();
+ }
+
+ /**
+ *
+ * A class taking in charge the synchronization of the partName and the right/left elements.
+ * When a name change, the other is automatically updated.
+ *
+ * @author vincent lorenzo
+ * adapted class from UmlGmfDiagramEditor
+ */
+ public class PartNameSynchronizer {
+
+ /** the papyrus table */
+ private PapyrusEMFCompareInstance compareInstance;
+
+ /**
+ * Listener on diagram name change.
+ */
+ private final Adapter tableNameListener = new Adapter() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ public void notifyChanged(final Notification notification) {
+ setPartName(EMFCompareUtils.getCompareEditorTitle(EMFCompareEditor.this, rawModel));
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#getTarget()
+ *
+ * @return
+ */
+ public Notifier getTarget() {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
+ *
+ * @param newTarget
+ */
+ public void setTarget(final Notifier newTarget) {
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
+ *
+ * @param type
+ * @return
+ */
+ public boolean isAdapterForType(final Object type) {
+ return false;
+ }
+
+ };
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ */
+ public PartNameSynchronizer(final PapyrusEMFCompareInstance compareInstance) {
+ setCompare(compareInstance);
+ }
+
+ /**
+ * Change the associated diagram.
+ *
+ * @param papyrusTable
+ */
+ public void setCompare(final PapyrusEMFCompareInstance compareInstance) {
+ // Remove from old diagram, if any
+ if(this.compareInstance != null) {
+ compareInstance.getLeft().eAdapters().remove(this.tableNameListener);
+ compareInstance.getRight().eAdapters().remove(this.tableNameListener);
+ }
+ // Set new table
+ this.compareInstance = compareInstance;
+
+ // Listen to name change
+ compareInstance.getLeft().eAdapters().add(this.tableNameListener);
+ compareInstance.getRight().eAdapters().add(this.tableNameListener);
+
+ }
+ }
+
+ @Override
+ protected void configureInput(final PapyrusModelCompareEditorInput input) {
+ //not useful for the moment
+ }
+
+
+ @Override
+ protected IOperationHistory getIOperationHistory() {
+ return ((NotifyingWorkspaceCommandStack)getEditingDomain().getCommandStack()).getOperationHistory();
+ }
+
+
+ @Override
+ protected void resetInput() {
+ final TreeViewer viewer = ((PapyrusModelCompareEditorInput)this.input).getStructureMergeViewer();
+ final PapyrusModelCompareEditorInput input = (PapyrusModelCompareEditorInput)getCompareInput(rawModel.getLeft(), rawModel.getRight());
+ final ModelCompareInput input2 = input.getpreparedModelCompareInput();
+ viewer.setInput(input2);
+ }
+
+
+ public EditingDomain getEditingDomain() {
+ TransactionalEditingDomain domain = null;
+ try {
+ domain = servicesRegistry.getService(TransactionalEditingDomain.class);
+ } catch (ServiceException e) {
+ Activator.log.error("I can't find the TransactionalEditingDomain", e);
+ }
+
+ return domain;
+ }
+
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java
new file mode 100644
index 00000000000..2531ee4e670
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.editor.listener;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.TriggerListener;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.messages.Messages;
+
+/**
+ *
+ * This class listen the close of the nested Compare Editor.
+ * When it is closed,
+ * - it removed it from the model (notation and di files are concerned)
+ * - it remove itself from the list of listener on the editing domain
+ *
+ */
+public class CloseEditorTriggerListener extends TriggerListener {
+
+ /**
+ * The listened model of the editor
+ */
+ private final EObject rawModel;
+
+ /** the service registry */
+ private final ServicesRegistry registry;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param rawModel
+ * the model for the editor to listen
+ * @param registry
+ * the service registry
+ */
+ public CloseEditorTriggerListener(final EObject rawModel, final ServicesRegistry registry) {
+ this.rawModel = rawModel;
+ this.registry = registry;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.transaction.TriggerListener#trigger(org.eclipse.emf.transaction.TransactionalEditingDomain,
+ * org.eclipse.emf.common.notify.Notification)
+ *
+ * @param domain
+ * @param notification
+ * @return
+ */
+ @Override
+ protected Command trigger(final TransactionalEditingDomain domain, final Notification notification) {
+ final Object notifier = notification.getNotifier();
+ IPageMngr mngr = null;
+ try {
+ mngr = ServiceUtils.getInstance().getIPageMngr(registry);
+ } catch (ServiceException e) {
+ Activator.log.error(Messages.CloseEditorTriggerListener_ICantFoundTheIPageManager, e);
+ }
+
+ final IPageMngr mngr2 = mngr;
+ if(notifier instanceof PageRef) {
+ final PageRef ref = (PageRef)notifier;
+ final EObject pageId = ref.getEmfPageIdentifier();
+ if(pageId == rawModel) {
+ final CompoundCommand command = new CompoundCommand();
+ final Command sashRemoveComd = new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ mngr2.removePage(rawModel);
+ }
+ };
+ EList<EObject> tabls = rawModel.eResource().getContents();
+ command.append(sashRemoveComd);
+ command.append(new RemoveCommand(domain, tabls, rawModel));
+ final Command removeListener = new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ //we remove this listener from the editingdomain
+ //it can't be done in the class which set it, because it would be removed too early
+ domain.removeResourceSetListener(CloseEditorTriggerListener.this);
+ }
+ };
+ command.append(removeListener);
+ return command;
+ }
+ }
+ return null;
+ }
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java
new file mode 100644
index 00000000000..1ae75bc1afb
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java
@@ -0,0 +1,224 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.factory;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.compare.EMFCompareException;
+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.metamodel.MatchModel;
+import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput;
+import org.eclipse.emf.compare.util.EMFCompareMap;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.core.editor.BackboneException;
+import org.eclipse.papyrus.infra.core.extension.diagrameditor.AbstractEditorFactory;
+import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.editor.EMFCompareEditor;
+import org.eclipse.papyrus.infra.emf.compare.common.utils.EMFCompareUtils;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusEMFCompareInstance;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.EditorActionBarContributor;
+
+public abstract class AbstractEMFCompareEditorFactory extends AbstractEditorFactory {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param editorClass
+ * the editor class
+ * @param editorType
+ * the type of editor
+ */
+ public AbstractEMFCompareEditorFactory(final Class<?> editorClass, final String type) {
+ super(editorClass, type);
+ }
+
+ /**
+ * Create the IPageModel that is used by the SashWindows to manage the editor.
+ *
+ * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object)
+ *
+ * @param pageIdentifier
+ * The model pushed in the sashmodel by the creation command
+ * @return A model implementing the IPageModel
+ */
+ public IPageModel createIPageModel(Object pageIdentifier) {
+ return new CompareEditorModel(pageIdentifier, getServiceRegistry());
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object)
+ *
+ * @param pageIdentifier
+ * @return
+ */
+ public boolean isPageModelFactoryFor(Object pageIdentifier) {
+ if(pageIdentifier instanceof PapyrusEMFCompareInstance) {
+ return ((PapyrusEMFCompareInstance)pageIdentifier).getType().equals(this.getExpectedType());
+ }
+ return false;
+ }
+
+ /**
+ * IEditorModel used internally by the SashContainer. This model know how to handle IEditor creation.
+ *
+ *
+ *
+ */
+ private class CompareEditorModel implements IEditorModel {
+
+
+ /**
+ * The servicesRegistry provided at creation.
+ */
+ private ServicesRegistry servicesRegistry;
+
+ /**
+ * The created editor.
+ */
+ private IEditorPart editor;
+
+ /**
+ * The raw model stored in the SashProvider.
+ */
+ private PapyrusEMFCompareInstance rawModel;
+
+ /**
+ *
+ * Constructor.
+ */
+ public CompareEditorModel(Object pageIdentifier, ServicesRegistry servicesRegistry) {
+ rawModel = (PapyrusEMFCompareInstance)pageIdentifier;
+ this.servicesRegistry = servicesRegistry;
+ }
+
+ /**
+ * Create the IEditor for the diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart()
+ * @return
+ * @throws PartInitException
+ *
+ */
+ public IEditorPart createIEditorPart() throws PartInitException {
+ try {
+ Constructor<?> c = getDiagramClass().getConstructor(ServicesRegistry.class, PapyrusEMFCompareInstance.class);
+ editor = (IEditorPart)c.newInstance(servicesRegistry, rawModel);
+ return editor;
+
+ } catch (Exception e) {
+ // Lets propagate. This is an implementation problem that should be solved by
+ // programmer.
+ throw new PartInitException("Can't create CompareEditor", e); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ * Get the action bar requested by the Editor.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor()
+ * @return
+ *
+ */
+ public EditorActionBarContributor getActionBarContributor() {
+
+ String actionBarId = editorDescriptor.getActionBarContributorId();
+
+ // Do nothing if no EditorActionBarContributor is specify.
+ if(actionBarId == null || actionBarId.length() == 0) {
+ return null;
+ }
+
+ // Try to get it.
+
+ // Get ServiceRegistry
+ // ServicesRegistry serviceRegistry = getServicesRegistry();
+ ActionBarContributorRegistry registry;
+ try {
+ registry = servicesRegistry.getService(ActionBarContributorRegistry.class);
+ } catch (ServiceException e) {
+ // Service not found
+ Activator.log.error(e);
+ return null;
+ }
+
+ try {
+ return registry.getActionBarContributor(actionBarId);
+ } catch (BackboneException e) {
+ Activator.log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Get the underlying RawModel. Return the Diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel()
+ * @return
+ *
+ */
+ public Object getRawModel() {
+ return rawModel;
+ }
+
+ /**
+ * Get the icon to be shown by Tabs
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon()
+ * @return
+ *
+ */
+ public Image getTabIcon() {
+ ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon();
+ if(imageDescriptor == null) {
+ return null;
+ }
+ return imageDescriptor.createImage();
+ }
+
+ /**
+ * Get the title of the Diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle()
+ * @return
+ *
+ */
+ public String getTabTitle() {
+ return EMFCompareUtils.getCompareEditorTitle(editor, rawModel);
+ }
+ }
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java
new file mode 100644
index 00000000000..df607baef1d
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.handler;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.AbstractEMFOperation;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.commands.CheckedOperationHistory;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.editor.EMFCompareEditor;
+import org.eclipse.papyrus.infra.emf.compare.common.modelresource.EMFCompareEditorModel;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusEMFCompareInstance;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusemfcompareinstanceFactory;
+import org.eclipse.ui.PlatformUI;
+
+
+public abstract class AbstractEMFCompareEditorHandler extends AbstractHandler {
+
+ final private String type;
+
+ public AbstractEMFCompareEditorHandler(final String type) {
+ this.type = type;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return
+ */
+ @Override
+ public boolean isEnabled() {
+ return getSelection().size() == 2;
+ }
+
+
+ //TODO essayer de merger cet handler avec un autre fournissant une commande et la sélection!
+ protected List<EObject> getSelection() {
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ List<EObject> currentSelection = new ArrayList<EObject>();
+ Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+ while(iter.hasNext()) {
+ Object current = iter.next();
+ if(current instanceof IAdaptable) {
+ EObject tmp = (EObject)((IAdaptable)current).getAdapter(EObject.class);
+ if(tmp != null) {
+ currentSelection.add(tmp);
+ }
+ }
+ }
+ return currentSelection;
+ }
+
+ /**
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ try {
+
+ runAsTransaction();
+ } catch (ServiceException e) {
+ throw new ExecutionException("I can't create CompareEditor", e); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ /**
+ * Run the command as a transaction.
+ * Create a Transaction and delegate the command to {@link #doExecute(ServicesRegistry)}.
+ *
+ * @throws ServiceException
+ *
+ */
+ public void runAsTransaction() throws ServiceException {
+ final ServicesRegistry serviceRegistry = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry();
+ TransactionalEditingDomain domain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+
+ //Create the transactional command
+ AbstractEMFOperation command = new AbstractEMFOperation(domain, "Create CompareEditor") { //$NON-NLS-1$
+
+ @Override
+ protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ try {
+ AbstractEMFCompareEditorHandler.this.doExecute(serviceRegistry);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ return Status.CANCEL_STATUS;
+ } catch (NotFoundException e) {
+ Activator.log.error(e);
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ // Execute the command
+ try {
+ CheckedOperationHistory.getInstance().execute(command, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error("I can't create CompareEditor", e); //$NON-NLS-1$
+ }
+
+ }
+
+
+ /**
+ * Do the execution of the command.
+ *
+ * @param serviceRegistry
+ * @throws ServiceException
+ * @throws NotFoundException
+ */
+ public void doExecute(final ServicesRegistry serviceRegistry) throws ServiceException, NotFoundException {
+ Object editorModel = createEditorModel(serviceRegistry);
+ // Get the mngr allowing to add/open new editor.
+ IPageMngr pageMngr = ServiceUtils.getInstance().getIPageMngr(serviceRegistry);
+ // add the new editor model to the sash.
+ pageMngr.openPage(editorModel);
+
+ }
+
+ /**
+ * Create a model identifying the editor. This model will be saved with the sash
+ *
+ * @return
+ * @throws ServiceException
+ * @throws NotFoundException
+ * The model where to save the TableInstance is not found.
+ */
+ protected Object createEditorModel(final ServicesRegistry serviceRegistry) throws ServiceException, NotFoundException {
+ PapyrusEMFCompareInstance editor = PapyrusemfcompareinstanceFactory.eINSTANCE.createPapyrusEMFCompareInstance();
+ editor.setLeft(getSelection().get(0));
+ editor.setRight(getSelection().get(1));
+ editor.setType(this.type);
+ EMFCompareEditorModel model = (EMFCompareEditorModel)ServiceUtils.getInstance().getModelSet(serviceRegistry).getModelChecked(EMFCompareEditorModel.MODEL_ID);
+ model.addEMFCompareEditorInstance(editor);
+ return editor;
+ }
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java
new file mode 100644
index 00000000000..db86b67cfdd
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java
@@ -0,0 +1,21 @@
+package org.eclipse.papyrus.infra.emf.compare.common.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.emf.compare.common.messages.messages"; //$NON-NLS-1$
+
+ public static String CloseEditorTriggerListener_ICantFoundTheIPageManager;
+
+ public static String EMFCompareUtils_CompareTitle;
+
+ public static String PapyrusModelCompareEditorInput_CompareTitle;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties
new file mode 100644
index 00000000000..3362eb23ae1
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties
@@ -0,0 +1,3 @@
+CloseEditorTriggerListener_ICantFoundTheIPageManager=I can't find the IPageManager
+EMFCompareUtils_CompareTitle=Compare (''{0}'' - ''{1}'')
+PapyrusModelCompareEditorInput_CompareTitle=Compare (''{0}'' - ''{1}'')
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/modelresource/EMFCompareEditorModel.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/modelresource/EMFCompareEditorModel.java
new file mode 100644
index 00000000000..149c4dec57c
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/modelresource/EMFCompareEditorModel.java
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.modelresource;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusEMFCompareInstance;
+
+
+public class EMFCompareEditorModel extends AbstractModelWithSharedResource<PapyrusEMFCompareInstance> implements IModel {
+
+ /*
+ * To save in a new file :
+ * the class should extends AbstractBaseModel and NOTATION_FILE_EXTENSION = "nattable" for example
+ */
+
+
+ /**
+ * File extension used for notation.
+ */
+ public static final String NOTATION_FILE_EXTENSION = "notation"; //$NON-NLS-1$
+
+ /**
+ * Model ID.
+ */
+ public static final String MODEL_ID = "org.eclipse.papyrus.emf.compare.resource.EMFCompareEditorModel"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public EMFCompareEditorModel() {
+
+ }
+
+
+ /**
+ * Get the file extension used for this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension()
+ *
+ * @return
+ */
+ @Override
+ protected String getModelFileExtension() {
+ return NOTATION_FILE_EXTENSION;
+ }
+
+ /**
+ * Get the identifier used to register this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier()
+ *
+ * @return
+ */
+ @Override
+ public String getIdentifier() {
+ return MODEL_ID;
+ }
+
+
+ /**
+ * Add a new initialized {@link PapyrusEMFCompareInstance} to the model.
+ *
+ * @param compareInstance
+ * The compareInstance to add.
+ */
+ public void addEMFCompareEditorInstance(PapyrusEMFCompareInstance compareInstance) {
+ getResource().getContents().add(compareInstance);
+ }
+
+ /**
+ * Add a new initialized {@link PapyrusEMFCompareInstance} to the model.
+ *
+ * @param compareInstance
+ * The compareInstance to add.
+ */
+ public void removeEMFCompareEditorInstance(PapyrusEMFCompareInstance compareInstance) {
+ getResource().getContents().remove(compareInstance);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#isModelRoot(org.eclipse.emf.ecore.EObject)
+ *
+ * @param object
+ * @return
+ */
+ @Override
+ protected boolean isModelRoot(EObject object) {
+ return false;
+ }
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/EMFCompareUtils.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/EMFCompareUtils.java
new file mode 100644
index 00000000000..efdfa3d06aa
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/EMFCompareUtils.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.utils;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.emf.compare.common.messages.Messages;
+import org.eclipse.papyrus.infra.emf.compare.instance.papyrusemfcompareinstance.PapyrusEMFCompareInstance;
+import org.eclipse.papyrus.infra.emf.compare.ui.provider.EMFCompareLabelProvider;
+import org.eclipse.papyrus.infra.emf.compare.ui.utils.ICustomizableEditor;
+import org.eclipse.ui.IEditorPart;
+
+
+
+public class EMFCompareUtils {
+
+ private EMFCompareUtils() {
+ //nothing to do
+ }
+
+
+ /**
+ *
+ * @param editor
+ * the editor
+ * @param rawModel
+ * the raw model
+ * @return
+ * the name for the editor
+ */
+ public static String getCompareEditorTitle(final IEditorPart editor, final PapyrusEMFCompareInstance rawModel) {
+ if(editor instanceof ICustomizableEditor) {
+ EMFCompareLabelProvider labelProvider = (EMFCompareLabelProvider)((ICustomizableEditor)editor).getLabelProvider();
+ String leftLabel = labelProvider.getText(rawModel.getLeft());
+ String rightLabel = labelProvider.getText(rawModel.getRight());
+ String title = NLS.bind(Messages.EMFCompareUtils_CompareTitle, leftLabel, rightLabel);
+ return title;
+ }
+ return "";
+
+ }
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/ICompareViewerProvider.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/ICompareViewerProvider.java
new file mode 100644
index 00000000000..ed11d80beae
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/ICompareViewerProvider.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.utils;
+
+import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
+import org.eclipse.emf.compare.ui.viewer.structure.ModelStructureMergeViewer;
+
+/**
+ *
+ * This interface
+ *
+ */
+public interface ICompareViewerProvider {
+
+ /**
+ *
+ * @return
+ * the content merge viewer for this input. The returned value can be <code>null</code> if the viewer has not been yet created
+ */
+ public ContentMergeViewer getContentMergeViewer();
+
+ /**
+ *
+ * @return
+ * the structure merge viewer for this input. The returned value can be <code>null</code> if the viewer has not been yet created
+ */
+ public ModelStructureMergeViewer getStructureMergeViewer();
+
+}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java
new file mode 100644
index 00000000000..bd12843a080
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java
@@ -0,0 +1,166 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.common.utils;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.Splitter;
+import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.ui.ModelCompareInput;
+import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput;
+import org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewer;
+import org.eclipse.emf.compare.ui.viewer.structure.ModelStructureMergeViewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.emf.compare.common.messages.Messages;
+import org.eclipse.papyrus.infra.emf.compare.ui.content.transactional.viewer.PapyrusTransactionalModelContentMergeViewer;
+import org.eclipse.papyrus.infra.emf.compare.ui.structural.viewer.PapyrusCustomizableParameterizedStructureMergeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ *
+ * the ModelInput for Papyrus Compare
+ *
+ */
+public class PapyrusModelCompareEditorInput extends ModelCompareEditorInput implements ICompareViewerProvider {
+
+ /** the editor */
+ protected IEditorPart editor;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param snapshot
+ * the snapshot
+ * @param editor
+ * the editor for the comparison
+ * @param ancestor
+ * the ancestor
+ * @param left
+ * the left Object to compare (used to display the name of elementthe element
+ * @param right
+ */
+ public PapyrusModelCompareEditorInput(final ComparisonSnapshot snapshot, final IEditorPart editor) {
+ super(snapshot);
+ this.editor = editor;
+ }
+
+ /**
+ * This methods allows to set the labels displayed at the top of the content merger viewers
+ * These labels are used too for the title of the editor
+ *
+ * @param leftLabel
+ * the left label
+ * @param leftImage
+ * the left image
+ * @param rightLabel
+ * the right label
+ * @param rightImage
+ * the right image
+ */
+ public void initLabels(final String leftLabel, final Image leftImage, final String rightLabel, final Image rightImage) {
+ CompareConfiguration cc = getCompareConfiguration();
+ cc.setLeftLabel(leftLabel);
+ cc.setRightLabel(rightLabel);
+ cc.setLeftImage(leftImage);
+ cc.setRightImage(rightImage);
+ setTitle(NLS.bind(Messages.PapyrusModelCompareEditorInput_CompareTitle, leftLabel, rightLabel));
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput#createMergeViewer(org.eclipse.compare.CompareViewerPane,
+ * org.eclipse.compare.CompareConfiguration)
+ *
+ * @param pane
+ * @param config
+ * @return
+ */
+ @Override
+ protected ModelContentMergeViewer createMergeViewer(final CompareViewerPane pane, final CompareConfiguration config) {
+ return new PapyrusTransactionalModelContentMergeViewer(pane, config, editor);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see CompareEditorInput#createOutlineContents(Composite, int)
+ */
+ @Override
+ public Control createOutlineContents(final Composite parent, final int direction) {
+ final Splitter splitter = new Splitter(parent, direction);
+
+ final CompareViewerPane pane = new CompareViewerPane(splitter, SWT.NONE);
+
+ //structureMergeViewer = new ModelStructureMergeViewer(pane, getCompareConfiguration());
+ CompareConfiguration conf = getCompareConfiguration();
+ // conf.s
+ structureMergeViewer = new PapyrusCustomizableParameterizedStructureMergeViewer(pane, getCompareConfiguration(), editor);
+ pane.setContent(structureMergeViewer.getTree());
+
+ structureMergeViewer.setInput(preparedInput);
+
+ return splitter;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param monitor
+ */
+ @Override
+ public void saveChanges(final IProgressMonitor monitor) {
+ //normally it ok, there is nothing to do to save notation and di files
+ super.saveChanges(monitor);
+ }
+
+ /**
+ *
+ * @return
+ * the content merge viewer for this input. The returned value can be <code>null</code> if the viewer has not been yet created
+ */
+ public ContentMergeViewer getContentMergeViewer() {
+ return this.contentMergeViewer;
+ }
+
+ /**
+ *
+ * @return
+ * the structure merge viewer for this input. The retruned value can be <code>null</code> if the viewer has not been yet created
+ */
+ public ModelStructureMergeViewer getStructureMergeViewer() {
+ return this.structureMergeViewer;
+ }
+
+ /**
+ *
+ * @return
+ * the prepared input
+ */
+ public ModelCompareInput getpreparedModelCompareInput() {
+ prepareInput(new NullProgressMonitor());
+ return this.preparedInput;
+ }
+
+}

Back to the top