diff options
author | cletavernie | 2013-06-18 08:16:24 +0000 |
---|---|---|
committer | cletavernie | 2013-06-18 08:16:24 +0000 |
commit | 098d8c358b9b62de9cb43e6424bca6ecec506087 (patch) | |
tree | a79ae6004374ba16ae62adbda5a88db75dbe0284 /deprecated | |
parent | e30c5c80eb0d2ee70abf965916c04145d78edfbd (diff) | |
download | org.eclipse.papyrus-098d8c358b9b62de9cb43e6424bca6ecec506087.tar.gz org.eclipse.papyrus-098d8c358b9b62de9cb43e6424bca6ecec506087.tar.xz org.eclipse.papyrus-098d8c358b9b62de9cb43e6424bca6ecec506087.zip |
Deprecate 1.X integration of EMF Compare for Papyrus 0.10.X
Diffstat (limited to 'deprecated')
287 files changed, 27479 insertions, 0 deletions
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.classpath b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.project b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.project new file mode 100644 index 00000000000..4646b498da8 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.compare.report.ui</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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.settings/org.eclipse.jdt.core.prefs b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0b515fef1d4 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1
+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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/META-INF/MANIFEST.MF b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..f12b0ae7e9d --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/META-INF/MANIFEST.MF @@ -0,0 +1,26 @@ +Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.papyrus.compare.report;bundle-version="0.10.0",
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.compare.ui,
+ org.eclipse.ocl,
+ org.eclipse.ocl.ecore,
+ org.eclipse.acceleo.model,
+ org.eclipse.acceleo.engine
+Export-Package: org.eclipse.papyrus.compare.report.ui.common
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Name: %Bundle-Name
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.compare.report.ui.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.compare.report.ui;singleton:=
+ true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/OSGI-INF/l10n/bundle.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000000..aafbd3c60ac --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,5 @@ +#Properties file for org.eclipse.papyrus.compare.report.ui
+menu.label = Acceleo Model to Text
+action.label = Generate DiffReport
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Acceleo GenerateReport Module IDE Plug-in (Incubation)
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/about.html b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/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>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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>
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/build.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/build.properties new file mode 100644 index 00000000000..d9ef6898f30 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/build.properties @@ -0,0 +1,10 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ about.html,\
+ OSGI-INF/
+src.includes = about.html
+
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/icons/export_as_html.gif b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/icons/export_as_html.gif Binary files differnew file mode 100644 index 00000000000..8a31f458379 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/icons/export_as_html.gif diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/plugin.xml b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/plugin.xml new file mode 100644 index 00000000000..b1b7e793e1e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/plugin.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.emfdiff"
+ id="org.eclipse.papyrus.compare.report.ui.popupMenus.contribution.IFile">
+ <menu id="org.eclipse.acceleo.module.menu" label="%menu.label" path="additionsAcceleo">
+ <groupMarker name="acceleo"/>
+ </menu>
+ <action
+ class="org.eclipse.papyrus.compare.report.ui.popupMenus.AcceleoGenerateGenerateReportAction"
+ enablesFor="+"
+ id="org.eclipse.papyrus.compare.report.ui.popupMenus.acceleoGenerateGenerateReportAction"
+ icon="icons/export_as_html.gif"
+ label="%action.label"
+ menubarPath="org.eclipse.acceleo.module.menu/acceleo"/>
+ </objectContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.emf.compare.ui.export">
+ <action
+ class="org.eclipse.papyrus.compare.report.ui.action.ExportAsGenReportAction"
+ fileExtension="uml"
+ id="org.eclipse.papyrus.compare.exportAsHTMLAction">
+ </action>
+ </extension>
+
+</plugin>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/Activator.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/Activator.java new file mode 100644 index 00000000000..9c9b26f604d --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/Activator.java @@ -0,0 +1,66 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.ui;
+
+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.compare.report.ui";
+
+ /**
+ * The shared instance.
+ */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ * @generated
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ * @generated
+ */
+ 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsGenReportAction.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsGenReportAction.java new file mode 100644 index 00000000000..806c0f5fef3 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsGenReportAction.java @@ -0,0 +1,53 @@ +package org.eclipse.papyrus.compare.report.ui.action;
+
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.ui.export.IExportAction;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.compare.report.ui.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+public class ExportAsGenReportAction implements IExportAction {
+
+ private final String myText = "As HTML Report";
+
+ private final String myToolTipText = "Export Diff Report in HTML format";
+
+ private final String myImagePath = "icons/export_as_html.gif";
+
+ private final Image myImage;
+
+ public ExportAsGenReportAction() {
+ myImage = AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, myImagePath).createImage();
+ }
+
+ public String getText() {
+ return myText;
+ }
+
+ public String getToolTipText() {
+ return myToolTipText;
+ }
+
+ public void exportSnapshot(ComparisonSnapshot snapshot) {
+ final ExportAsHTMLWizard wizard = new ExportAsHTMLWizard();
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+
+ wizard.init(workbench, snapshot);
+ final WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+
+ }
+
+ public Image getDisabledImage() {
+ return myImage;
+ }
+
+ public Image getEnabledImage() {
+ return myImage;
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsHTMLWizard.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsHTMLWizard.java new file mode 100644 index 00000000000..a223b3c2075 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/action/ExportAsHTMLWizard.java @@ -0,0 +1,178 @@ +package org.eclipse.papyrus.compare.report.ui.action;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSetSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.ui.internal.wizard.SaveDeltaWizard;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.compare.report.services.UmlElementService;
+import org.eclipse.papyrus.compare.report.ui.common.GenerateAll;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+
+public class ExportAsHTMLWizard extends SaveDeltaWizard {
+
+ private static final String HTML_EXTENSION = "html";
+
+ private static final String EMFDIFF_EXTENSION = "emfdiff";
+
+ private WizardNewFileCreationPage myNewReportFileCreationPage;
+
+ private IResource myFirstSelectedFile;
+
+ private String myDefaultFileName;
+
+ public ExportAsHTMLWizard() {
+ super(null); // use default extension
+ }
+
+
+ public void init(IWorkbench workbench, ComparisonSnapshot inputSnapshot) {
+ super.init(workbench, inputSnapshot);
+ DiffModel model = getDiffModel(inputSnapshot);
+ Resource firstSelectedResource = getFirstSelectedResource(model);
+ myFirstSelectedFile = ResourcesPlugin.getWorkspace().getRoot().findMember(firstSelectedResource.getURI().toPlatformString(true));
+ myDefaultFileName = new UmlElementService().getFileName(model);
+ }
+
+ private DiffModel getDiffModel(ComparisonSnapshot inputSnapshot) {
+ if(inputSnapshot instanceof ComparisonResourceSnapshot) {
+ return ((ComparisonResourceSnapshot)inputSnapshot).getDiff();
+ } else {
+ EList<DiffModel> diffModels = ((ComparisonResourceSetSnapshot)inputSnapshot).getDiffResourceSet().getDiffModels();
+ if(!diffModels.isEmpty()) {
+ return diffModels.get(0);
+ } else {
+ // log;
+ return null;
+ }
+ }
+ }
+
+ private Resource getFirstSelectedResource(DiffModel diffModel) {
+ EList<EObject> leftRoots = diffModel.getLeftRoots();
+ if(leftRoots.isEmpty()) {
+ // log
+ return null;
+ }
+ return leftRoots.get(0).eResource();
+ }
+
+ @Override
+ public IStructuredSelection getSelection() {
+ IStructuredSelection result = super.getSelection();
+ if(result == null || result.isEmpty() && myFirstSelectedFile != null) {
+ return new StructuredSelection(myFirstSelectedFile);
+ }
+ return result;
+ }
+
+ public void addPages() {
+ super.addPages();
+ findNewDiffFilePage().setAllowExistingResources(true);
+ findNewDiffFilePage().setFileExtension(EMFDIFF_EXTENSION);
+ findNewDiffFilePage().setFileName(getDefaultFileName() + "." + EMFDIFF_EXTENSION);
+
+ myNewReportFileCreationPage = new WizardNewFileCreationPage("newFilePage1", getSelection());//$NON-NLS-1$
+ myNewReportFileCreationPage.setFileName(getDefaultFileName() + "." + HTML_EXTENSION);
+ myNewReportFileCreationPage.setAllowExistingResources(true);
+ myNewReportFileCreationPage.setTitle("New HTML File");
+ myNewReportFileCreationPage.setDescription("Create a new HTML file");
+ myNewReportFileCreationPage.setFileExtension(HTML_EXTENSION);
+ addPage(myNewReportFileCreationPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ boolean result = super.performFinish();
+ if(!result) {
+ return false;
+ }
+
+ myNewReportFileCreationPage.createNewFile();
+
+ IProgressMonitor monitor = new NullProgressMonitor();
+ IResource targetFolder = getTargetFolder(); // The logical folder were the IFile is to appear.
+ File rawTargetFolder = getRawTargetFolder(); // The file-system folder were the File is to be created.
+ GenerateAll generator = new GenerateAll(getNewDiffModelURI(), rawTargetFolder, getTemplateArguments());
+
+ try {
+ generator.doGenerate(monitor);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ } finally {
+ try {
+ targetFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+ private String getDefaultFileName() {
+ return myDefaultFileName;
+ }
+
+ private List<? extends Object> getTemplateArguments() {
+ return Collections.singletonList(myNewReportFileCreationPage.getFileName());
+ }
+
+ private File getRawTargetFolder() {
+ File targetFolder = null;
+ IResource targetFolderResource = ResourcesPlugin.getWorkspace().getRoot().findMember(myNewReportFileCreationPage.getContainerFullPath());
+ if (targetFolderResource.isLinked()) {
+ targetFolder = targetFolderResource.getRawLocation().toFile();
+ } else {
+ IPath targetFolderPath = targetFolderResource.getLocation();
+ if (targetFolderPath != null) {
+ targetFolder = targetFolderPath.toFile();
+ } else {
+ // Virtual folder or non-local project.
+ // In that case, use the diff-model's folder as file-system folder.
+ WizardNewFileCreationPage saveDiffPage = findNewDiffFilePage();
+ IPath filePath = saveDiffPage.getContainerFullPath().append(saveDiffPage.getFileName());
+ IFile fileHandle = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
+ targetFolder = fileHandle.getRawLocation().toFile().getParentFile();
+ }
+ }
+ return targetFolder;
+ }
+
+ private IResource getTargetFolder() {
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(myNewReportFileCreationPage.getContainerFullPath());
+ }
+
+ private WizardNewFileCreationPage findNewDiffFilePage() {
+ final String page = "newFilePage1"; //$NON-NLS-1$
+ return (WizardNewFileCreationPage)getPage(page);
+ }
+
+ private URI getNewDiffModelURI() {
+ WizardNewFileCreationPage saveDiffPage = findNewDiffFilePage();
+ IPath filePath = saveDiffPage.getContainerFullPath().append(saveDiffPage.getFileName());
+ IFile fileHandle = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
+ return URI.createFileURI(fileHandle.getLocation().toOSString());
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/common/GenerateAll.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/common/GenerateAll.java new file mode 100644 index 00000000000..b72d221e949 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/common/GenerateAll.java @@ -0,0 +1,93 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.ui.common;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+
+
+/**
+ * Main entry point of the 'GenerateReport' generation module.
+ */
+public class GenerateAll {
+
+ /**
+ * The model URI.
+ */
+ private URI modelURI;
+
+ private EObject model;
+
+ /**
+ * The output folder.
+ */
+ private File targetFolder;
+
+ /**
+ * The other arguments.
+ */
+ List<? extends Object> arguments;
+
+ /**
+ * Constructor.
+ *
+ * @param modelURI
+ * is the URI of the model.
+ * @param targetFolder
+ * is the output folder
+ * @param arguments
+ * are the other arguments
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ * @generated
+ */
+ public GenerateAll(URI modelURI, File targetFolder, List<? extends Object> arguments) {
+ this.modelURI = modelURI;
+ this.targetFolder = targetFolder;
+ this.arguments = arguments;
+ }
+
+ public GenerateAll(EObject model, File targetFolder, List<? extends Object> arguments) {
+ this.model = model;
+ this.targetFolder = targetFolder;
+ this.arguments = arguments;
+ }
+ /**
+ * Launches the generation.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ * @generated
+ */
+ public void doGenerate(IProgressMonitor monitor) throws IOException {
+ if (!targetFolder.exists()) {
+ targetFolder.mkdirs();
+ }
+
+ org.eclipse.papyrus.compare.report.files.GenerateReport gen0;
+ if (modelURI != null) {
+ gen0 = new org.eclipse.papyrus.compare.report.files.GenerateReport(modelURI, targetFolder, arguments);
+ } else {
+ gen0 = new org.eclipse.papyrus.compare.report.files.GenerateReport(model, targetFolder, arguments);
+ }
+ gen0.doGenerate(BasicMonitor.toMonitor(monitor));
+
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/popupMenus/AcceleoGenerateGenerateReportAction.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/popupMenus/AcceleoGenerateGenerateReportAction.java new file mode 100644 index 00000000000..04555f6a2a2 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report.ui/src/org/eclipse/papyrus/compare/report/ui/popupMenus/AcceleoGenerateGenerateReportAction.java @@ -0,0 +1,112 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.ui.popupMenus;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.compare.report.ui.Activator;
+import org.eclipse.papyrus.compare.report.ui.common.GenerateAll;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * GenerateReport code generation.
+ */
+public class AcceleoGenerateGenerateReportAction extends ActionDelegate implements IActionDelegate {
+
+ /**
+ * Selected model files.
+ */
+ protected List<IFile> files;
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ files = ((IStructuredSelection) selection).toList();
+ }
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
+ * @generated
+ */
+ public void run(IAction action) {
+ if (files != null) {
+ IRunnableWithProgress operation = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ Iterator<IFile> filesIt = files.iterator();
+ while (filesIt.hasNext()) {
+ IFile model = (IFile)filesIt.next();
+ URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true);
+ try {
+ IContainer target = model.getProject().getFolder("reports");
+ GenerateAll generator = new GenerateAll(modelURI, target.getLocation().toFile(), getArguments());
+ generator.doGenerate(monitor);
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ } finally {
+ model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ }
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ };
+ try {
+ PlatformUI.getWorkbench().getProgressService().run(true, true, operation);
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ } catch (InterruptedException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ }
+
+ /**
+ * Computes the arguments of the generator.
+ *
+ * @return the arguments
+ * @generated
+ */
+ protected List<? extends Object> getArguments() {
+ return new ArrayList<String>();
+ }
+
+}
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.classpath b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.project b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.project new file mode 100644 index 00000000000..187fa7d6f05 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.compare.report</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>
+ <buildCommand>
+ <name>org.eclipse.acceleo.ide.ui.acceleoBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.acceleo.ide.ui.acceleoNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.settings/org.eclipse.jdt.core.prefs b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0b515fef1d4 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1
+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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/META-INF/MANIFEST.MF b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..d38d1ac5c3b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.ocl,
+ org.eclipse.ocl.ecore,
+ org.eclipse.acceleo.model,
+ org.eclipse.acceleo.engine;bundle-version="3.0.0",
+ org.eclipse.uml2.uml;bundle-version="3.1.0",
+ org.eclipse.uml2.uml.edit;bundle-version="3.1.0",
+ org.eclipse.emf.edit.ui;bundle-version="2.6.0"
+Export-Package: org.eclipse.papyrus.compare.report.files,
+ org.eclipse.papyrus.compare.report.services
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Name: %Bundle-Name
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.compare.report.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.compare.report
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/OSGI-INF/l10n/bundle.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000000..7d49f053684 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,3 @@ +#Properties file for org.eclipse.papyrus.compare.report
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Acceleo Report Module Runtime Plug-in (Incubation)
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/about.html b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/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>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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>
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.acceleo b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.acceleo new file mode 100644 index 00000000000..da659727a93 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.acceleo @@ -0,0 +1,28 @@ +<!-- ===================================================================== -->
+<!-- Custom targets. -->
+<!-- Set customBuildCallbacks = build.acceleo in your build.properties. -->
+<!-- ===================================================================== -->
+<project name="Build Acceleo Module" default="noDefault">
+
+ <!-- ================================================================= -->
+ <!-- Default target -->
+ <!-- ================================================================= -->
+ <target name="noDefault">
+ <echo message="This file must be called with explicit targets" />
+ </target>
+
+ <!-- ================================================================= -->
+ <!-- Steps to do after the target gather.bin.parts -->
+ <!-- Available parameters : -->
+ <!-- build.result.folder - folder containing the build results -->
+ <!-- target.folder - destination folder -->
+ <!-- ================================================================= -->
+
+ <target name="post.gather.bin.parts">
+ <acceleoCompiler
+ sourceFolders="${target.folder}"
+ dependencies="">
+ </acceleoCompiler>
+ </target>
+
+</project>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.properties new file mode 100644 index 00000000000..ed077d52ad5 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/build.properties @@ -0,0 +1,8 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ OSGI-INF/
+customBuildCallbacks = build.acceleo
+src.includes = about.html
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/Activator.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/Activator.java new file mode 100644 index 00000000000..df49594465e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/Activator.java @@ -0,0 +1,64 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends Plugin {
+
+ /**
+ * The plug-in ID.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.compare.report";
+
+ /**
+ * The shared instance.
+ */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#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/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/AttributeChange.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/AttributeChange.java new file mode 100644 index 00000000000..b0196cb4bbd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/AttributeChange.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'AttributeChange' generation module.
+ *
+ * @generated
+ */
+public class AttributeChange extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "attributeChange";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "attributeChange", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public AttributeChange() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public AttributeChange(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public AttributeChange(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ AttributeChange generator = new AttributeChange(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Common.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Common.java new file mode 100644 index 00000000000..d19eb5d035b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Common.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'Common' generation module.
+ *
+ * @generated
+ */
+public class Common extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "common";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "common", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public Common() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public Common(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public Common(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ Common generator = new Common(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ConflictingDiffElement.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ConflictingDiffElement.java new file mode 100644 index 00000000000..03b988617cd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ConflictingDiffElement.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'ConflictingDiffElement' generation module.
+ *
+ * @generated
+ */
+public class ConflictingDiffElement extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "conflictingDiffElement";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "conflictingDiffElement", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public ConflictingDiffElement() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public ConflictingDiffElement(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public ConflictingDiffElement(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ ConflictingDiffElement generator = new ConflictingDiffElement(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Css.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Css.java new file mode 100644 index 00000000000..dbd232c9847 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/Css.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'Css' generation module.
+ *
+ * @generated
+ */
+public class Css extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "css";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "css", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public Css() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public Css(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public Css(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ Css generator = new Css(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffElement.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffElement.java new file mode 100644 index 00000000000..fadf884c9b6 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffElement.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'DiffElement' generation module.
+ *
+ * @generated
+ */
+public class DiffElement extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "diffElement";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "diffElement", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public DiffElement() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public DiffElement(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public DiffElement(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ DiffElement generator = new DiffElement(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffGroup.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffGroup.java new file mode 100644 index 00000000000..33b506d07bb --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/DiffGroup.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'DiffGroup' generation module.
+ *
+ * @generated
+ */
+public class DiffGroup extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "diffGroup";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "diffGroup", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public DiffGroup() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public DiffGroup(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public DiffGroup(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ DiffGroup generator = new DiffGroup(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/GenerateReport.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/GenerateReport.java new file mode 100644 index 00000000000..cc6ddc9db51 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/GenerateReport.java @@ -0,0 +1,273 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'GenerateReport' generation module.
+ *
+ * @generated
+ */
+public class GenerateReport extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "generateReport";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "generateReport", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public GenerateReport() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public GenerateReport(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public GenerateReport(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ GenerateReport generator = new GenerateReport(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/HtmlUtils.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/HtmlUtils.java new file mode 100644 index 00000000000..ffcdbeab1cd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/HtmlUtils.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'HtmlUtils' generation module.
+ *
+ * @generated
+ */
+public class HtmlUtils extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "htmlUtils";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "htmlUtils", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public HtmlUtils() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public HtmlUtils(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public HtmlUtils(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ HtmlUtils generator = new HtmlUtils(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelElementChange.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelElementChange.java new file mode 100644 index 00000000000..4d198dc0dfc --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelElementChange.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'ModelElementChange' generation module.
+ *
+ * @generated
+ */
+public class ModelElementChange extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "modelElementChange";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "modelElementChange", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public ModelElementChange() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public ModelElementChange(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public ModelElementChange(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ ModelElementChange generator = new ModelElementChange(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelUtils.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelUtils.java new file mode 100644 index 00000000000..e655b03a9f3 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ModelUtils.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'ModelUtils' generation module.
+ *
+ * @generated
+ */
+public class ModelUtils extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "modelUtils";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "modelUtils", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public ModelUtils() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public ModelUtils(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public ModelUtils(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ ModelUtils generator = new ModelUtils(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ReferenceChange.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ReferenceChange.java new file mode 100644 index 00000000000..ea93d0d4176 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ReferenceChange.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'ReferenceChange' generation module.
+ *
+ * @generated
+ */
+public class ReferenceChange extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "referenceChange";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "referenceChange", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public ReferenceChange() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public ReferenceChange(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public ReferenceChange(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ ReferenceChange generator = new ReferenceChange(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ResourceDiff.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ResourceDiff.java new file mode 100644 index 00000000000..52090d61301 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/ResourceDiff.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'ResourceDiff' generation module.
+ *
+ * @generated
+ */
+public class ResourceDiff extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "resourceDiff";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "resourceDiff", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public ResourceDiff() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public ResourceDiff(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public ResourceDiff(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ ResourceDiff generator = new ResourceDiff(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE.getNsURI(), org.eclipse.emf.compare.diff.metamodel.DiffPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/TableUtils.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/TableUtils.java new file mode 100644 index 00000000000..7224bf92709 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/TableUtils.java @@ -0,0 +1,271 @@ +/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.compare.report.files;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Entry point of the 'TableUtils' generation module.
+ *
+ * @generated
+ */
+public class TableUtils extends AbstractAcceleoGenerator {
+ /**
+ * The name of the module.
+ *
+ * @generated
+ */
+ public static final String MODULE_FILE_NAME = "tableUtils";
+
+ /**
+ * The name of the templates that are to be generated.
+ *
+ * @generated
+ */
+ public static final String[] TEMPLATE_NAMES = { "tableUtils", };
+
+ /**
+ * Allows the public constructor to be used. Note that a generator created
+ * this way cannot be used to launch generations before one of
+ * {@link #initialize(EObject, File, List)} or
+ * {@link #initialize(URI, File, List)} is called.
+ * <p>
+ * The main reason for this constructor is to allow clients of this
+ * generation to call it from another Java file, as it allows for the
+ * retrieval of {@link #getProperties()} and
+ * {@link #getGenerationListeners()}.
+ * </p>
+ *
+ * @generated
+ */
+ public TableUtils() {
+ // Empty implementation
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param modelURI
+ * URI where the model on which this generator will be used is located.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
+ * @generated
+ */
+ public TableUtils(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * This allows clients to instantiates a generator with all required information.
+ *
+ * @param model
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
+ * @param targetFolder
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
+ * @param arguments
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
+ * @throws IOException
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * @generated
+ */
+ public TableUtils(EObject model, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
+
+ /**
+ * This can be used to launch the generation from a standalone application.
+ *
+ * @param args
+ * Arguments of the generation.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+ List<String> arguments = new ArrayList<String>();
+ for (int i = 2; i < args.length; i++) {
+ arguments.add(args[i]);
+ }
+ TableUtils generator = new TableUtils(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * This will be thrown if any of the output files cannot be saved to disk.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // TODO if you need to listen to generation event, add listeners to the list here
+ return listeners;
+ }
+
+ /**
+ * If you need to change the way files are generated, this is your entry point.
+ * <p>
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
+ * files on the fly. If you only need to preview the results, return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
+ * the running Eclipse and can be used standalone.
+ * </p>
+ * <p>
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna
+ * override files that are under clear case or any other VCS that could forbid the overriding), then
+ * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
+ * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
+
+ /**
+ * This will be called in order to find and load the module that will be launched through this launcher.
+ * We expect this name not to contain file extension, and the module to be located beside the launcher.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
+
+ /**
+ * If the module(s) called by this launcher require properties files, return their qualified path from
+ * here.Take note that the first added properties files will take precedence over subsequent ones if they
+ * contain conflicting keys.
+ * <p>
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of
+ * the form <package>.<properties file name without extension>. For example, if you have a file
+ * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
+ * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
+
+ /**
+ * This can be used to update the resource set's package registry with all needed EPackages.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * This can be used to update the resource set's resource factory registry with all needed factories.
+ *
+ * @param resourceSet
+ * The resource set which registry has to be updated.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/attributeChange.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/attributeChange.mtl new file mode 100644 index 00000000000..4184e9df08d --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/attributeChange.mtl @@ -0,0 +1,60 @@ +[comment encoding = UTF-8 /] + +[comment] +A representation of the model object 'Attribute Change'. Superclass of elements describing difference between the values of a given attribute. +[/comment] + +[module attributeChange('http://www.eclipse.org/emf/compare/diff/1.1')/] + +[import tableUtils/] +[import modelUtils/] +[import common/] + +[template public genAttributeChanges(el : DiffElement, leftRoot: String, rightRoot: String) {attributeChanges: Sequence(AttributeChange) = attributeChanges(el); }] +[if not attributeChanges->isEmpty()] +[openTable()/] +[addHeader('Changed Attributes', leftRoot, rightRoot)/] +[for (attributeChanges)] +[genAttributeChange()/] +[/for] +[closeTable()/] +[/if] +[/template] + +[template public genAttributeChange(el : AttributeChange)] +[if not el.attribute.oclIsInvalid() and not el.attribute.oclIsUndefined()] +[addRow(el.attribute.name, el.leftElement.eGet(el.attribute).attributeToString(), el.rightElement.eGet(el.attribute).attributeToString())/] +[/if] +[/template] + +[comment] +A representation of the model object 'Attribute Change Left Target'. +A "LeftTarget" element change describes a difference involving the left element/resource. +In the case of AttributeChanges, these describe differences within multi-valued attributes. +Specifically, the addition of a value or the remote removal of a value (for three way comparisons). +[/comment] +[template public genAttributeChange(el : AttributeChangeLeftTarget)] +[addRow(el.attribute.name.concat(' value removed'), noElement().attributeToString(), el.leftTarget.attributeToString())/] +[/template] + +[comment] +A representation of the model object 'Attribute Change Right Target'. +A "RightTarget" element change describes a difference involving the right element/resource. +In the case of AttributeChanges, these describe differences within multi-valued attributes. +Specifically, the removal of a value or the remote addition of a value (for three way comparisons). +[/comment] +[template public genAttributeChange(el : AttributeChangeRightTarget)] +[addRow(el.attribute.name.concat(' value added'), noElement(), el.rightTarget.attributeToString())/] +[/template] + +[comment] +A representation of the model object 'Update Attribute'. +Differences of this kind represent modifications of the value of single-valued attributes. +[/comment] +[template public genAttributeChange(el :UpdateAttribute)] +[addRow(el.attribute.name, el.leftElement.eGet(el.attribute).attributeToString(), el.rightElement.eGet(el.attribute).attributeToString())/] +[/template] + +[query private attributeChanges(element : DiffElement) : Sequence(AttributeChange) = element.subDiffElements->select(attr: DiffElement| attr.oclIsKindOf(AttributeChange))/] + +[query private attributeToString(element : OclAny) : String = element.toString()/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/common.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/common.mtl new file mode 100644 index 00000000000..977e407b352 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/common.mtl @@ -0,0 +1,11 @@ +[comment encoding = UTF-8 /] +[module common('http://www.eclipse.org/emf/compare/diff/1.1','http://www.eclipse.org/uml2/3.0.0/UML')/] + + +[query public appendLevelToIndex(index: Sequence(Integer)) : Sequence(Integer) = index->append(0)/] + +[query private nextIndex(index: Sequence(Integer)) : Sequence(Integer) = index->subSequence(1, (index->size()-1))->append(index->last() + 1)/] + +[query public composeIndex(prefix: String , i : Integer) : String = if (prefix <> '') then prefix.concat('.').concat(i.toString()) else prefix.concat(i.toString()) endif/] + +[query public hierarchyLevel(index: String) : Integer = index.tokenize('.')->size() + 1/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/conflictingDiffElement.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/conflictingDiffElement.mtl new file mode 100644 index 00000000000..a7ebbef973a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/conflictingDiffElement.mtl @@ -0,0 +1,20 @@ +[comment encoding = UTF-8 /] +[module conflictingDiffElement('http://www.eclipse.org/emf/compare/diff/1.1')/] + +[import tableUtils/] +[import modelUtils/] +[import htmlUtils/] +[import common/] + +[comment] +A representation of the model object 'Conflicting Diff Element'. +This will act as a container for conflictual changes. +[/comment] +[template public genConflictingDiffElement(el : ConflictingDiffElement, prefix : String , leftRoot: String, rightRoot: String)] +[elementHeading(el.originElement, prefix)/] +Conflictual Change: +[openTable()/] +[addHeader('Origin Element', leftRoot, rightRoot)/] +[addRow(el.originElement.elementName(), el.leftParent.elementName(), el.rightParent.elementName())/] +[closeTable()/] +[/template] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/css.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/css.mtl new file mode 100644 index 00000000000..8336476b1fc --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/css.mtl @@ -0,0 +1,193 @@ +[comment encoding = UTF-8 /] +[module css('http://www.eclipse.org/emf/2002/Ecore')/] + +[template public genCSS()] +<STYLE type="text/css"> +.Normal { +font-family: Verdana; +font-size: 11pt;} +.BodyText { +font-family: Verdana; +font-size: 11pt;} +.Title { +text-align: center; +font-family: Verdana; +font-size: 20pt; +font-weight: bold; +padding-bottom: 16pt;} +.Subtitle { +text-align: center; +font-family: Verdana; +font-size: 16pt; +font-style: italic; +padding-bottom: 16pt;} +.DocumentInfo { +font-family: Verdana; +font-size: 11pt;} +.ListNumber2 { +font-family: Verdana; +font-size: 11pt;} +.Heading1 { +margin-top: 12pt; +border-top-style: dotted;page-break-before: always; +font-family: Verdana; +font-size: 16pt; +font-weight: bold; +padding-top: 12pt; +padding-bottom: 12pt;} +.Heading2 { +font-family: Verdana; +font-size: 14pt; +padding-top: 6pt; +padding-bottom: 6pt;} +.Heading3 { +font-family: Verdana; +font-size: 12pt; +padding-left: 0.7cm; +padding-top: 6pt; +padding-bottom: 6pt;} +.Heading4 { +font-family: Verdana; +font-size: 11pt; +padding-left: 1cm; +padding-bottom: 6pt;} +.Heading5 { +font-family: Verdana; +font-size: 10pt; +padding-left: 1.2cm; +padding-bottom: 6pt;} +.Heading6 { +font-family: Verdana; +font-size: 9pt; +padding-left: 1.4cm; +padding-bottom: 6pt;} +.TableCell { +text-align: left; +vertical-align:middle; +font-family: Verdana; +font-size: 9pt; +padding-left: 0.1cm; +padding-right: 0.1cm;} +.TableHeadingCell { +text-align: left; +vertical-align:middle; +color: rgb(255,255,255); +background-color: rgb(0,0,128); +font-family: Verdana; +font-size: 9pt; +font-weight: bold; +padding-left: 0.1cm;} +.TOC1 { +font-family: Verdana; +font-size: 12pt; +font-weight: bold; +padding-top: 12pt;} +.TOC2 { +font-family: Verdana; +font-size: 12pt; +padding-left: 0.35cm; +padding-top: 12pt;} +.TOC3 { +font-family: Verdana; +font-size: 11pt; +font-style: italic; +padding-left: 0.7cm; +padding-top: 6pt;} +.TOC4 { +font-family: Verdana; +font-size: 9pt; +padding-left: 1cm;} +.Header { +font-family: Tahoma; +font-size: 9pt; +font-weight: bold;} +.Footer { +font-family: Tahoma; +font-size: 9pt;} +.Caption { +text-align: center; +font-family: Verdana; +font-size: 8pt; +font-weight: bold; +padding-top: 6pt; +padding-bottom: 12pt;} +.TableCaption { +text-align: left; +font-family: Verdana; +font-size: 8pt; +font-weight: bold; +padding-bottom: 6pt;} +.ListOfFigures { +font-family: Verdana; +font-size: 11pt; +font-weight: bold;} +.Hyperlink { +color: rgb(0,0,255); +font-family: Verdana; +font-size: 11pt; +text-decoration: underline;} +.DocumentClass { +text-align: center; +font-family: Verdana; +font-size: 11pt;} +.TableCellAnnot { +text-align: left; +vertical-align:middle; +font-family: Verdana; +font-size: 9pt; +font-style: italic; +padding-left: 0.1cm; +padding-right: 0.1cm;} +.TableHeadingCellAnnot { +text-align: left; +vertical-align:middle; +background-color: rgb(255,255,0); +font-family: Verdana; +font-size: 9pt; +font-weight: bold; +padding-left: 0.1cm;} +.TextualCode { +font-family: Courier; +font-size: 9pt; +margin-bottom: 12pt; +border-style: solid; +border-width: 1pt; +padding-left: 3pt; +padding-top: 3pt; +padding-bottom: 3pt; +padding-right: 3pt; +min-width: 160mm; +width: 80%; +white-space: nowrap;} +.EndOfDocument { +text-align: center; +color: rgb(192,192,192); +font-family: Verdana; +font-size: 7pt;} +.ListTitle { +font-family: Verdana; +font-size: 8pt; +font-weight: bold;} +.ListOfTables { +font-family: Verdana; +font-size: 11pt; +font-weight: bold;} +table{ +border:1px solid rgb(0, 0, 0); +border-spacing: 0px; +border-collapse: collapse; +} +td{ +border:1px solid rgb(0, 0, 0); +border-collapse: collapse; + min-height: 0.5cm; +height: 0.5cm; +} +th{ +border:1px solid rgb(0, 0, 0); +border-collapse: collapse; + min-height: 0.5cm; +height: 0.5cm; +} +</STYLE> +[/template] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffElement.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffElement.mtl new file mode 100644 index 00000000000..7e6c327c3aa --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffElement.mtl @@ -0,0 +1,38 @@ +[comment encoding = UTF-8 /] +[module diffElement('http://www.eclipse.org/emf/compare/diff/1.1')/] + +[import attributeChange/] +[import referenceChange/] +[import diffGroup/] +[import modelElementChange/] +[import conflictingDiffElement/] +[import resourceDiff/] + +[template public processDiffElement(el : DiffGroup, leftRoot: String, rightRoot: String)] +[el.processDiffGroup('', leftRoot, rightRoot)/] +[/template] + +[template public processDiffElement(el : AttributeChange, leftRoot: String, rightRoot: String)] +[el.genAttributeChange()/] +[/template] + +[template public processDiffElement(el : ReferenceChange, leftRoot: String, rightRoot: String)] +[el.genReferenceChange()/] +[/template] + +[template public processDiffElement(el : ConflictingDiffElement, leftRoot: String, rightRoot: String)] +[el.genConflictingDiffElement('', leftRoot, rightRoot)/] +[/template] + +[template public processDiffElement(el : ModelElementChange, leftRoot: String, rightRoot: String)] +[el.genModelElementChange('', leftRoot, rightRoot)/] +[/template] + +[template public processDiffElement(el : ResourceDiff, leftRoot: String, rightRoot: String)] +[el.genResourceDiff('', leftRoot, rightRoot)/] +[/template] + +[template public processDiffElement(el : DiffElement, leftRoot: String, rightRoot: String)] +[el.kind/] Unknown diff +[/template] + diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffGroup.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffGroup.mtl new file mode 100644 index 00000000000..8d5d0f77b1c --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/diffGroup.mtl @@ -0,0 +1,35 @@ +[comment encoding = UTF-8 /] +[module diffGroup('http://www.eclipse.org/emf/compare/diff/1.1')/] + +[import common/] +[import modelUtils/] +[import tableUtils/] +[import htmlUtils/] + +[import attributeChange/] +[import referenceChange/] +[import modelElementChange/] +[import conflictingDiffElement/] + +[template public processDiffGroup(el : DiffGroup, prefix : String, leftRoot: String, rightRoot: String) {subgroups: Sequence(DiffGroup) = el.subDiffGroups();}] +[if prefix <> ''] +[elementHeading(el.rightParent, prefix)/] +[/if] +[el.genAttributeChanges(leftRoot, rightRoot)/] +[el.genReferenceChanges(leftRoot, rightRoot)/] +[for (next : DiffGroup | subgroups)] +[next.processDiffGroup(composeIndex(prefix, i), leftRoot, rightRoot)/] +[/for] + +[for (next: ModelElementChange | el.modelElementChanges())] +[next.genModelElementChange(composeIndex(prefix, subgroups->size() + i), leftRoot, rightRoot)/] +[/for] +[for (next: ConflictingDiffElement | el.conflictingDiffElements())] +[next.genConflictingDiffElement(composeIndex(prefix, el.modelElementChanges()->size()+ i), leftRoot, rightRoot)/] +[/for] + +[/template] + +[query private subDiffGroups(element : DiffElement) : Sequence(DiffGroup) = element.subDiffElements->select(next: DiffElement| next.oclIsKindOf(DiffGroup))/] + +[query private conflictingDiffElements(element : DiffElement) : Sequence(DiffGroup) = element.subDiffElements->filter(ConflictingDiffElement)/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/generateReport.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/generateReport.mtl new file mode 100644 index 00000000000..7dbd296ebd9 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/generateReport.mtl @@ -0,0 +1,29 @@ +[comment encoding = UTF-8 /] +[module generateReport('http://www.eclipse.org/emf/compare/diff/1.1','http://www.eclipse.org/emf/2002/Ecore','http://www.eclipse.org/uml2/3.0.0/UML')/] + +[import modelUtils/] +[import htmlUtils/] +[import diffElement/] + +[template public generateReport(model : DiffModel)] +[comment @main /] +[generateReport(model, model.fileName().concat('.html'))/] +[/template] + +[template public generateReport(model : DiffModel, fileName : String)] +[file (fileName, false, 'UTF-8')] +[docHeading()/] +[reportHeader(leftRootName(model), rightRootName(model))/] +[for (diffElement : DiffElement | model.ownedElements)] +[diffElement.processDiffElement(leftRootName(model), rightRootName(model))/] +[/for] +[printClosingText('End of Diff Report')/] +[docEnding()/] +[/file] +[/template] + +[template private reportHeader(leftRoot : String, rightRoot : String)] +[heading(1)/] Difference report between (1) [leftRoot/] and (2)[rightRoot/][closeHeading()/] +[/template] + +[query private fileName(model: DiffModel) : String = model.leftRootName().concat('_diff_').concat(model.rightRootName())/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/htmlUtils.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/htmlUtils.mtl new file mode 100644 index 00000000000..dae7493ed80 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/htmlUtils.mtl @@ -0,0 +1,46 @@ +[comment encoding = UTF-8 /] +[module htmlUtils('http://www.eclipse.org/emf/2002/Ecore')/] + +[import common/] +[import css/] +[import modelUtils/] + +[template public elementHeading(el : EObject, index: String)] +[heading(hierarchyLevel(index))/][index/] +[decode(invoke('org.eclipse.papyrus.compare.report.services.UmlElementService', 'getText(org.eclipse.emf.ecore.EObject)', Sequence{el}))/] +[closeHeading()/] +[/template] + +[template public docHeading()] +<HTML> +<HEAD> +[genCSS()/] +</HEAD> +<BODY> +[/template] + +[template public printClosingText(text : String)] +<HR style="width: 14cm; text-align: center;"> +<BR> +<DIV class="BodyText">[text/]<BR> +</DIV> +[/template] + +[template public docEnding()] +</BODY> +</HTML> +[/template] + +[template public lineBreak()] +<br> +[/template] + +[template public heading(level : Integer)] +<DIV class="Heading[level/]"> +[/template] + +[template public closeHeading()] +</DIV> +[/template] + +[query public decode(name : OclAny) : String = name.oclAsType(String).replaceAll('<', '<').replaceAll('>', '>')/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelElementChange.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelElementChange.mtl new file mode 100644 index 00000000000..5576cd7744f --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelElementChange.mtl @@ -0,0 +1,85 @@ +[comment encoding = UTF-8 /] +[module modelElementChange('http://www.eclipse.org/emf/compare/diff/1.1','http://www.eclipse.org/emf/2002/Ecore')/] + +[import modelUtils/] +[import tableUtils/] +[import htmlUtils/] + +[template public genModelElementChange(el : ModelElementChangeLeftTarget, prefix : String , leftRoot: String, rightRoot: String)] +[elementHeading(el.leftElement, prefix)/] +(1) [elementQualifiedName(el.leftElement)/][lineBreak()/] +Deleted in the second model + +[openTable()/] +[addHeader(leftRoot, rightRoot)/] +[addRow(elementContents(el.leftElement), noElement())/] +[closeTable()/] +[/template] + +[template public genModelElementChange(el : ModelElementChangeRightTarget, prefix : String , leftRoot: String, rightRoot: String)] +[elementHeading(el.rightElement, prefix)/] +(2) [elementQualifiedName(el.rightElement)/][lineBreak()/] +Added in the second model + +[openTable()/] +[addHeader(leftRoot, rightRoot)/] +[addRow(noElement(), elementContents(el.rightElement))/] +[closeTable()/] +[/template] + +[template public elementContents(obj: EObject)] +[invoke('org.eclipse.papyrus.compare.report.services.UmlElementService', 'getContents(org.eclipse.emf.ecore.EObject)', Sequence{obj})/] +[/template] + + +[comment] +A representation of the model object 'Update Containment Feature'. +This particular kind of move operation describe a change of containment reference +of a given element within the same container. +[/comment] +[template public genModelElementChange(el : UpdateContainmentFeature, prefix : String , leftRoot: String, rightRoot: String)] +[elementHeading(el.leftElement, prefix)/] +(1) [elementQualifiedName(el.leftElement)/][lineBreak()/] +(2) [elementQualifiedName(el.rightElement)/][lineBreak()/] +Containment Feature was changed: + +[openTable()/] +[addHeader('-', leftRoot, rightRoot)/] +[addRow('Containment Feature', elementName(el.leftElement.eContainmentFeature()), elementName(el.rightElement.eContainmentFeature()))/] +[closeTable()/] +[/template] + +[comment] +A representation of the model object 'Move Model Element'. +These describe a change of container for a given element. +[/comment] +[template public genModelElementChange(el : MoveModelElement, prefix : String , leftRoot: String, rightRoot: String)] +[elementHeading(el.leftElement, prefix)/] +(1) [elementQualifiedName(el.leftElement)/][lineBreak()/] +(2) [elementQualifiedName(el.rightElement)/][lineBreak()/] +The Element was moved: + +[openTable()/] +[addHeader('-', leftRoot, rightRoot)/] +[addRow('Parent', elementName(el.leftTarget), elementName(el.rightTarget))/] +[closeTable()/] +[/template] + +[comment] +A representation of the model object 'Update Model Element'. +Superclass of DiffElements used to describe "move" types of differences. +This includes both Moving from a container to another and changing the containment reference of an element. These changes imply both an addition and a removal. +[/comment] +[template public genModelElementChange(el : UpdateModelElement, prefix : String , leftRoot: String, rightRoot: String)] +Generic processModelElementChange for [el.kind/] kind +[/template] + +[comment] +A representation of the model object 'Model Element Change'. +Superclass of DiffElements used to describe element additions or removals. +[/comment] +[template public genModelElementChange(el : ModelElementChange, prefix : String , leftRoot: String, rightRoot: String)] +Generic processModelElementChange for [el.kind/] kind +[/template] + +[query public modelElementChanges(element : DiffElement) : Sequence(ModelElementChange) = element.subDiffElements->select(next: DiffElement| next.oclIsKindOf(ModelElementChange))/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelUtils.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelUtils.mtl new file mode 100644 index 00000000000..8c84d46ff5e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/modelUtils.mtl @@ -0,0 +1,42 @@ +[comment encoding = UTF-8 /] +[module modelUtils('http://www.eclipse.org/emf/compare/diff/1.1','http://www.eclipse.org/uml2/3.0.0/UML')/] + +[comment] +This will return the name of the given element +[/comment] +[query public elementName(element : OclAny) : String = if (not element.oclIsUndefined() and element.oclIsKindOf(NamedElement)) then element.oclAsType(NamedElement).name else '<not a named element>' endif/] + +[query public elementQualifiedName(element : OclAny) : String = if (not element.oclIsUndefined() and element.oclIsKindOf(NamedElement)) + then element.oclAsType(NamedElement).getQualifiedName2() + else '<not a named element>' endif/] + +[query public getQualifiedName2(element : NamedElement) : String = if (element.getQualifiedName().isEmpty()) + then elementQualifiedName(element.namespace) + else element.getQualifiedName().replaceAll('::', '/') endif/] + +[query public elementMetaclass(element : OclAny) : String = if (not element.oclIsUndefined()) then element.eClass().name else '' endif/] + +[query public elementContent(element : OclAny) : String = if (element.oclIsKindOf(NamedElement)) then element.oclAsType(NamedElement).name else '<not a named element>' endif/] + +[query public leftRootName(model: DiffModel) : String = model.leftRoots->first().elementName()/] + +[query public rightRootName(model: DiffModel) : String = model.rightRoots->first().elementName()/] + +[query public label(element : OclAny) : String = if (not umlLabel().isEmpty()) then umlLabel() else + (if (not element.oclIsUndefined() and element.oclIsKindOf(ValueSpecification)) then element.oclAsType(ValueSpecification).stringValue() else '' endif) + endif/] + +[query public elementStereotypesAndKeywords(element : OclAny) : String = if (not element.oclIsUndefined() and element.oclIsKindOf(Element)) then elementStereotypes(element.oclAsType(Element)) else '' endif/] + +[query public elementStereotypes(element : Element) : String = if (not element.getAppliedStereotypes()->isEmpty()) then elementStereotypes2() else '' endif/] + +[query public elementStereotypes2(element : Element) : String = element.getAppliedStereotypes().elementName()->sep(', ')/] + +[query public elementKeywords(element : Element) : String = element.getKeywords()->sep(', ')/] + +[query private umlLabel(element : OclAny) : String = if (not element.oclIsUndefined() and element.oclIsKindOf(Element)) then element.oclAsType(NamedElement).getLabel() else '' endif/] + +[query private isEmpty(str : String) : Boolean = str.oclIsUndefined() or str.size() = 0/] + +[query public noElement() : String = '-'/] + diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/referenceChange.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/referenceChange.mtl new file mode 100644 index 00000000000..3b9e8b3c85c --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/referenceChange.mtl @@ -0,0 +1,56 @@ +[comment encoding = UTF-8 /] +[module referenceChange('http://www.eclipse.org/emf/compare/diff/1.1', 'http://www.eclipse.org/emf/2002/Ecore')/] + +[import modelUtils/] +[import tableUtils/] + +[template public genReferenceChanges(el : DiffElement, leftRoot: String, rightRoot: String) {referenceChanges: Sequence(ReferenceChange) = referenceChanges(el); }] +[if not referenceChanges->isEmpty()] +[openTable()/] +[addHeader('Changed References', leftRoot, rightRoot)/] +[for (referenceChanges)] +[genReferenceChange()/] +[/for] +[closeTable()/] +[/if] +[/template] + +[comment] +A representation of the model object 'Reference Change Left Target'. +A "LeftTarget" element change describes a difference involving the left element/resource. +In the case of ReferenceChanges, these describe differences within multi-valued references. +Specifically, the addition of a value or the remote removal of a value (for three way comparisons). +[/comment] +[template public genReferenceChange(el : ReferenceChangeLeftTarget)] +[addRow(el.reference.name.concat(' value removed'), el.leftTarget.elementName(), noElement()) /] +[/template] + +[comment] +[/comment] +[template public genReferenceChange(el : ReferenceChangeRightTarget)] +[addRow(el.reference.name.concat(' value added'), noElement(), el.rightTarget.elementName())/] +[/template] + +[comment] +A representation of the model object 'Reference Order Change'. +[/comment] +[template public genReferenceChange(el : ReferenceOrderChange)] +[addRow(el.reference.name.concat(' reference order change'), elementNames(el.leftTarget), elementNames(el.rightTarget))/] +[/template] + +[comment] +Differences of this kind represent modifications of the value of single-valued references. +[/comment] +[template public genReferenceChange(el : UpdateReference)] +[addRow(el.reference.name, el.leftElement.eGet(el.reference).elementName(), el.rightElement.eGet(el.reference).elementName())/] +[/template] + +[template public genReferenceChange(el : ReferenceChange)] +[addRow(el.reference.name, el.leftElement.eGet(el.reference).elementName(), el.rightElement.eGet(el.reference).elementName())/] +[/template] + +[query private referenceChanges(element : DiffElement) : Sequence(ReferenceChange) = element.subDiffElements->select(next: DiffElement| next.oclIsKindOf(ReferenceChange))/] + +[query private elementNames(elements : Collection(EObject)) : String = elements.elementName()->sep(',')/] + + diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/resourceDiff.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/resourceDiff.mtl new file mode 100644 index 00000000000..a0bb9acbc0a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/resourceDiff.mtl @@ -0,0 +1,42 @@ +[comment encoding = UTF-8 /] +[module resourceDiff('http://www.eclipse.org/emf/compare/diff/1.1', 'http://www.eclipse.org/emf/2002/Ecore')/] + +[import tableUtils/] +[import modelUtils/] +[import common/] + +[comment] +Differences of this kind represent changes regarding a third-party resource. +[/comment] +[template public genResourceDiff(el : ResourceDiff, prefix : String , leftRoot: String, rightRoot: String)] +Changes regarding a third-party resource: +[for (next: ResourceDiff | el.subDiffElements->filter(ResourceDiff))] +[next.genResourceDiff(prefix, leftRoot, rightRoot)/] +[/for] +//call children changes +[/template] + +[comment] +Superclass of DiffElements representing additions or removals of references towards a third-party resource. +[/comment] +[template public genResourceDiff(el : ResourceDependencyChange)] +[elementNames(el.roots)/] +[/template] + +[comment] +"LeftTarget" element change describes a difference involving the left ResourceSet. These differences can be +used to describe additions or remote removals of third-party resources dependencies. +[/comment] +[template public genResourceDiff(el : ResourceDependencyChangeLeftTarget)] +[elementNames(el.roots)/] +[/template] + +[comment] +"RightTarget" element change describes a difference involving the right ResourceSet. These differences can +be used to describe deletions or remote additions of third-party resources dependencies. +[/comment] +[template public genResourceDiff(el : ResourceDependencyChangeRightTarget)] +[elementNames(el.roots)/] +[/template] + +[query private elementNames(elements : Collection(EObject)) : String = elements.elementName()->sep(',')/] diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/tableUtils.mtl b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/tableUtils.mtl new file mode 100644 index 00000000000..898070a5baa --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/files/tableUtils.mtl @@ -0,0 +1,37 @@ +[comment encoding = UTF-8 /] +[module tableUtils('http://www.eclipse.org/emf/2002/Ecore')/] + +[import modelUtils/] +[import common/] +[import htmlUtils/] + +[template public openTable()] +<TABLE ><TBODY> +[/template] + +[template public closeTable()] +</TBODY></TABLE>[lineBreak()/] +[/template] + +[template public addHeader(name: String, leftRoot: String, rightRoot: String)] +<tr><th class="TableHeadingCell" style="width: 50mm;">[name/]</th> +<th class="TableHeadingCell" style="width: 50mm;">(1) [leftRoot/]</th> +<th class="TableHeadingCell" style="width: 50mm;">(2) [rightRoot/]</th></tr> +[/template] + +[template public addHeader(leftRoot: String, rightRoot: String)] +<tr><th class="TableHeadingCell" style="width: 50mm;">(1) [leftRoot/]</th> +<th class="TableHeadingCell" style="width: 50mm;">(2) [rightRoot/]</th></tr> +[/template] + +[template public addRow(title: String, leftElement: String, rightElement: String)] +<tr><TD class="TableCell" style="width: 50mm;">[title/]</td> +<TD class="TableCell" style="width: 80mm;">[leftElement/]</td> +<TD class="TableCell" style="width: 80mm;">[rightElement/]</td></tr> +[/template] + +[template public addRow(leftElement: String, rightElement: String)] +<tr><TD class="TableCell" style="width: 100mm;">[leftElement/]</td> +<TD class="TableCell" style="width: 100mm;">[rightElement/]</td></tr> +[/template] + diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/services/UmlElementService.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/services/UmlElementService.java new file mode 100644 index 00000000000..9800f162cc5 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.compare.report/src/org/eclipse/papyrus/compare/report/services/UmlElementService.java @@ -0,0 +1,115 @@ +package org.eclipse.papyrus.compare.report.services;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+
+public class UmlElementService {
+
+ private static AdapterFactoryLabelProvider oursAdapterLabelProvider = new AdapterFactoryLabelProvider(
+ new UMLItemProviderAdapterFactory());
+
+ public String getFileName(DiffModel model) {
+ return getFirstElementName(model.getLeftRoots()) + "_diff_" + getFirstElementName(model.getRightRoots());
+ }
+
+ private String getFirstElementName(EList<EObject> children) {
+ if (children.isEmpty()) {
+ return "";
+ }
+ return getElementName(children.get(0));
+ }
+
+ public String getText(EObject eobject) {
+ return oursAdapterLabelProvider.getText(eobject);
+ }
+
+
+ public String getContents(EObject eObject) {
+ EClass eClass = eObject.eClass();
+ StringBuffer result = new StringBuffer();
+ for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) {
+ EStructuralFeature eStructuralFeature = eClass
+ .getEStructuralFeature(i);
+ if (eStructuralFeature.isChangeable()
+ && !eStructuralFeature.isDerived()) {
+ if (eStructuralFeature instanceof EAttribute) {
+ result.append(getAttributeString(eObject,
+ (EAttribute) eStructuralFeature));
+ } else {
+ result.append(getReferenceString(eObject,
+ (EReference) eStructuralFeature));
+ }
+ }
+ }
+ return result.toString();
+ }
+
+ private StringBuffer getAttributeString(EObject eObject, EAttribute attr) {
+ StringBuffer result = new StringBuffer();
+ Object attrValue = eObject.eGet(attr);
+ if (attrValue != null && !attrValue.equals("")) {
+ result.append(attr.getName());
+ result.append(" : ");
+ result.append(attrValue);
+ result.append("</br>");
+ }
+ return result;
+ }
+
+ private StringBuffer getReferenceString(EObject eObject,
+ EReference eReference) {
+ StringBuffer result = new StringBuffer();
+ Object refValue = getElementName(eObject.eGet(eReference));
+ if (refValue != null && !refValue.equals("") && !refValue.equals("[]") && !refValue.equals(" ")) {
+ if (eReference.isContainment()) {
+ result.append(eReference.getName());
+ result.append(" ");
+ result.append(" : ");
+ result.append(refValue);
+ result.append("</br>");
+ } else {
+ result.append(eReference.getName());
+ result.append(" : ");
+ result.append("'" + refValue + "'");
+ result.append("</br>");
+ }
+ }
+ return result;
+ }
+
+ private String getElementName(Object obj) {
+ if (obj == null) {
+ return "";
+ }
+ if (obj instanceof NamedElement) {
+ return ((NamedElement) obj).getLabel();
+ }
+ if (obj instanceof Comment) {
+ return ((Comment) obj).getBody();
+ }
+ if (obj instanceof EObject) {
+ return obj.toString();
+ }
+ if (obj instanceof List) {
+ String result = "";
+ for (Object next : ((List) obj)) {
+ result += getElementName(next);
+ result += ", ";
+ }
+ return result;
+ }
+ return obj.toString();
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.classpath b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.project b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.project new file mode 100644 index 00000000000..d6c8da15259 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..44217f8c068 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..2a5688f01a0 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/META-INF/MANIFEST.MF @@ -0,0 +1,35 @@ +Manifest-Version: 1.0
+Require-Bundle: org.eclipse.papyrus.infra.emf.compare.instance;bundle-version="0.10.0",
+ org.eclipse.compare,
+ org.eclipse.emf.compare.ui;bundle-version="1.3.1",
+ org.eclipse.emf.compare;bundle-version="1.3.1",
+ org.eclipse.emf.compare.diff;bundle-version="1.3.1",
+ org.eclipse.emf.compare.match;bundle-version="1.3.1",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.infra.emf.compare.ui;bundle-version="0.10.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.10.0",
+ org.eclipse.ui,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.10.0"
+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-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.10.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.infra.emf.compare.common.Activat
+ or
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.compare.common;sing
+ leton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/about.html b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/deprecated/uml-compare-1.X/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 ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/build.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/build.properties new file mode 100644 index 00000000000..7299a10c1b3 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.pdoc new file mode 100644 index 00000000000..2bc2b2b7241 --- /dev/null +++ b/deprecated/uml-compare-1.X/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
to be opened in the sasheditor as the others papyrus editors (diagram and table)
This editor is "partially volatile", that is to say, we lose all its information when we close it, 
but we don't lose it when we close Papyrus or Eclipse (see bug 371606)
">
+ <referent firstName="vincent" lastName="lorenzo" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA-LIST"/>
+</doc:Documentation>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.properties new file mode 100644 index 00000000000..d6b8baf2f09 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/plugin.xml new file mode 100644 index 00000000000..c7d232618d8 --- /dev/null +++ b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/Activator.java b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java new file mode 100644 index 00000000000..c6a4b893771 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/AbstractPapyrusCompareEditor.java @@ -0,0 +1,290 @@ +/*****************************************************************************
+ * 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.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.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 {
+
+
+ /**
+ * 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 : i'm not sure of these options for EMF, but this method is always overriden in Papyrus
+ 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, new GenericMatchScopeProvider(left.eResource(), right.eResource()));
+ 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;
+ }
+
+
+ @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 = doMatch(monitor, left, right, options);
+ DiffModel diff = doDiff(match, options);
+ 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 monitor TODO
+ * @param left
+ * @param right
+ * @param options
+ * @return
+ * the MatchModel for the comparison
+ * @throws InterruptedException
+ */
+ protected MatchModel doMatch(IProgressMonitor monitor, final EObject left, final EObject right, final Map<String, Object> options) throws InterruptedException {
+ return MatchService.doContentMatch(left, right, options);
+ }
+
+ /**
+ *
+ * @param match
+ * @param options
+ * @return
+ * the DiffModel for the comparison
+ */
+ protected DiffModel doDiff(final MatchModel match, Map<String, Object> options) {
+ 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 == OperationHistoryEvent.UNDONE || eventType == OperationHistoryEvent.REDONE) {
+ if(this.lastEvent != event) {
+ this.lastEvent = event;
+ if(!event.getOperation().getLabel().equals("Create CompareEditor")) {//TODO improve it!
+ resetInput();
+ }
+ }
+ }
+ //after each action, the status could have change
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java new file mode 100644 index 00000000000..8aef8ca034e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java @@ -0,0 +1,309 @@ +/*****************************************************************************
+ * 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.messages.Messages;
+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() {
+ return (EditingDomain)getAdapter(TransactionalEditingDomain.class);
+ }
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(adapter.equals(TransactionalEditingDomain.class)) {
+ TransactionalEditingDomain domain = null;
+ try {
+ domain = servicesRegistry.getService(adapter);
+ } catch (ServiceException e) {
+ Activator.log.error(Messages.EMFCompareEditor_EditingDomainNotFound, e);
+ }
+ return domain;
+ }
+ return super.getAdapter(adapter);
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java new file mode 100644 index 00000000000..94077194016 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/factory/AbstractEMFCompareEditorFactory.java @@ -0,0 +1,204 @@ +/*****************************************************************************
+ * 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 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.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.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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java new file mode 100644 index 00000000000..c0e8c6ce386 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/handler/AbstractEMFCompareEditorHandler.java @@ -0,0 +1,174 @@ +/*****************************************************************************
+ * 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.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.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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java new file mode 100644 index 00000000000..7e04def1dbd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java @@ -0,0 +1,23 @@ +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 EMFCompareEditor_EditingDomainNotFound;
+
+ 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties new file mode 100644 index 00000000000..ba07d46048a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties @@ -0,0 +1,4 @@ +CloseEditorTriggerListener_ICantFoundTheIPageManager=I can't find the IPageManager
+EMFCompareEditor_EditingDomainNotFound=TransactionalEditingDomain not found
+EMFCompareUtils_CompareTitle=Compare (''{0}'' - ''{1}'')
+PapyrusModelCompareEditorInput_CompareTitle=Compare (''{0}'' - ''{1}'')
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/modelresource/EMFCompareEditorModel.java b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/EMFCompareUtils.java b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/ICompareViewerProvider.java b/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java new file mode 100644 index 00000000000..de33db83c16 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/utils/PapyrusModelCompareEditorInput.java @@ -0,0 +1,178 @@ +/*****************************************************************************
+ * 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.CompareViewerPane;
+import org.eclipse.compare.Splitter;
+import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
+import org.eclipse.core.runtime.IAdaptable;
+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.emf.transaction.TransactionalEditingDomain;
+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;
+ }
+
+ /**
+ *
+ * @return
+ * the EditingDomain for the current Editor, or <code>null</code> if not found
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ TransactionalEditingDomain domain = null;
+ if(this.editor instanceof IAdaptable) {
+ domain = (TransactionalEditingDomain)this.editor.getAdapter(TransactionalEditingDomain.class);
+ }
+ return domain;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.classpath b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.classpath new file mode 100644 index 00000000000..11515e2650c --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.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 excluding="org/eclipse/papyrus/emf/compare/merger/services/PapyrusMergeFactory.java|org/eclipse/papyrus/infra/emf/compare/diff/service/PapyrusMergeFactory.java" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.project b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.project new file mode 100644 index 00000000000..a432349cb6e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.emf.compare.diff</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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.settings/org.eclipse.jdt.core.prefs b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..44217f8c068 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/.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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/META-INF/MANIFEST.MF b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..6cee97758c5 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/META-INF/MANIFEST.MF @@ -0,0 +1,35 @@ +Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.compare,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="0.10.0",
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.tools;bundle-version="0.10.0",
+ com.google.guava;bundle-version="10.0.1",
+ org.eclipse.emf.compare.match
+Export-Package: org.eclipse.papyrus.infra.emf.compare.diff,
+ org.eclipse.papyrus.infra.emf.compare.diff.check,
+ org.eclipse.papyrus.infra.emf.compare.diff.internal.command,
+ org.eclipse.papyrus.infra.emf.compare.diff.internal.merger,
+ org.eclipse.papyrus.infra.emf.compare.diff.internal.provider,
+ org.eclipse.papyrus.infra.emf.compare.diff.internal.util,
+ org.eclipse.papyrus.infra.emf.compare.diff.merge,
+ org.eclipse.papyrus.infra.emf.compare.diff.provider,
+ org.eclipse.papyrus.infra.emf.compare.diff.service,
+ org.eclipse.papyrus.infra.emf.compare.diff.utils
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.10.0.qualifier
+Bundle-Name: %Bundle-Name
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.infra.emf.compare.diff.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.compare.diff;single
+ ton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/OSGI-INF/l10n/bundle.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000000..c61ef00c81b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,4 @@ +#Properties file for org.eclipse.papyrus.infra.emf.compare.diff
+extension-point.name = org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Papyrus EMF Merger (Incubation)
\ No newline at end of file diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/about.html b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/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 ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/build.properties b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/build.properties new file mode 100644 index 00000000000..63b01ff7554 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/build.properties @@ -0,0 +1,11 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ build.properties,\
+ schema/,\
+ about.html,\
+ OSGI-INF/,\
+ plugin.pdoc
+src.includes = about.html
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/plugin.pdoc b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/plugin.pdoc new file mode 100644 index 00000000000..9ed59603112 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/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 Transactional EMF Merger.">
+ <referent firstName="vincent" lastName="lorenzo" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA-LIST"/>
+</doc:Documentation>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/plugin.xml b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/plugin.xml new file mode 100644 index 00000000000..1735ddc95b2 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider" name="org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider" schema="schema/org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider.exsd"/>
+ <extension
+ point="org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider">
+ <mergerprovider
+ mergerProviderClass="org.eclipse.papyrus.infra.emf.compare.diff.internal.provider.DefaultTransactionalMergerProvider"
+ new_attribute="org.eclipse.papyrus.infra.emf.compare.diff.TransactionalMergerProvider1">
+ </mergerprovider>
+ </extension>
+
+
+</plugin>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/schema/org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider.exsd b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/schema/org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider.exsd new file mode 100644 index 00000000000..ad697e5aa43 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/schema/org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider.exsd @@ -0,0 +1,136 @@ +<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.emf.compare.diff" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.emf.compare.diff" id="org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider" name="org.eclipse.papyrus.infra.emf.compare.diff.mergerprovider"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="mergerprovider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="mergerprovider">
+ <annotation>
+ <documentation>
+ This extension point allows to register merge provider for
+the Papyrus UML Compare. This extension point has been adapted from the EMF-Compare
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="fileExtension" type="string">
+ <annotation>
+ <documentation>
+ Comma separated list of the extensions this merger provider targets. * for any file extension.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="mergerProviderClass" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.emf.compare.diff.provider.ITransactionalMergerProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority">
+ <annotation>
+ <documentation>
+ The priority of this engine. Values can be <code>lowest</code>, <code>low</code>, <code>normal</code>, <code>high</code>, <code>highest</code>.
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="lowest">
+ </enumeration>
+ <enumeration value="low">
+ </enumeration>
+ <enumeration value="normal">
+ </enumeration>
+ <enumeration value="high">
+ </enumeration>
+ <enumeration value="highest">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/Activator.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/Activator.java new file mode 100644 index 00000000000..2858c1d669e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/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.diff;
+
+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.diff"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** the log helper for this plugin */
+ 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);
+ log = new LogHelper(this);
+ plugin = 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/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/FeaturesCheck.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/FeaturesCheck.java new file mode 100644 index 00000000000..c43c699fadd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/FeaturesCheck.java @@ -0,0 +1,106 @@ +/*****************************************************************************
+ * 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.diff.check;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.compare.diff.engine.IMatchManager;
+import org.eclipse.emf.compare.diff.engine.check.AbstractCheck;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.emf.compare.diff.utils.PapyrusCompareOptions;
+
+/**
+ *
+ * This checker allow to know if differences on a feature should be ignored or not
+ *
+ */
+public class FeaturesCheck extends AbstractCheck implements IFeaturesCheck {
+
+ /**
+ * The list of the features that should be ignored in the whole diff
+ */
+ private final List<EStructuralFeature> ignoreAll;
+
+ /**
+ * the list of the features that should be ignored for some EObject
+ */
+ private final Map<EStructuralFeature, List<EObject>> ignoreSomeCase;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * @param options
+ */
+ @SuppressWarnings("unchecked")
+ //cast on List and Map
+ public FeaturesCheck(final IMatchManager manager, final Map<String, Object> options) {
+ super(manager);
+
+ if(options != null && options.containsKey(PapyrusCompareOptions.KEY_IGNORE_ALL_CHANGES_ON_FEATURES)) {
+ this.ignoreAll = (List<EStructuralFeature>)options.get(PapyrusCompareOptions.KEY_IGNORE_ALL_CHANGES_ON_FEATURES);
+ } else {
+ this.ignoreAll = Collections.EMPTY_LIST;
+ }
+ if(options != null && options.containsKey(PapyrusCompareOptions.KEY_IGNORE_CHANGES_ON_FEATURES_FOR)) {
+ this.ignoreSomeCase = (Map<EStructuralFeature, List<EObject>>)options.get(PapyrusCompareOptions.KEY_IGNORE_CHANGES_ON_FEATURES_FOR);
+ } else {
+ this.ignoreSomeCase = Collections.EMPTY_MAP;
+ }
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ */
+ public FeaturesCheck(final IMatchManager manager) {
+ this(manager, null);
+ }
+
+ /**
+ * This method is used to know if a feature should always be ignored
+ *
+ * @param feature
+ * @return
+ */
+ public boolean shouldBeIgnored(final EStructuralFeature feature) {
+ return this.ignoreAll.contains(feature);
+ }
+
+ /**
+ * This method begins by testing the feature must ALWAYS be ignored using shouldBeIgnored(feature).
+ * If not, we verify is the feature should be ignored in some case, depending on its context
+ *
+ *
+ * @param feature
+ * @param context
+ * @return
+ */
+ public boolean shouldBeIgnored(final EStructuralFeature feature, final EObject context) {
+ if(shouldBeIgnored(feature)) {
+ return true;
+ }
+ final List<EObject> values = this.ignoreSomeCase.get(feature);
+ if(values != null) {
+ return values.contains(context);
+ }
+ return false;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/IFeaturesCheck.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/IFeaturesCheck.java new file mode 100644 index 00000000000..7ad0443c4a3 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/IFeaturesCheck.java @@ -0,0 +1,45 @@ +/*****************************************************************************
+ * 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.diff.check;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ *
+ * This interface allows to define checker enable to ignore differences following the context
+ *
+ */
+public interface IFeaturesCheck {
+
+ /**
+ * return <code>true</code> if the feature should be ignored
+ *
+ * @param feature
+ * @return
+ */
+ public boolean shouldBeIgnored(final EStructuralFeature feature);
+
+ /**
+ * return <code>true</code> if the feature should be ignored in this context
+ *
+ * @param feature
+ * a feature
+ * @param context
+ * the context of this attribute
+ * @return
+ */
+ public boolean shouldBeIgnored(final EStructuralFeature feature, final EObject context);
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusAttributesCheck.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusAttributesCheck.java new file mode 100644 index 00000000000..5f78f3657ab --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusAttributesCheck.java @@ -0,0 +1,128 @@ +/*****************************************************************************
+ * 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.diff.check;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.engine.IMatchManager;
+import org.eclipse.emf.compare.diff.engine.check.AttributesCheck;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.match.metamodel.Match2Elements;
+import org.eclipse.emf.compare.match.metamodel.Match3Elements;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+
+public class PapyrusAttributesCheck extends AttributesCheck {
+
+ /**
+ * a checker used to manage diff configuration
+ */
+ private final FeaturesCheck checker;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param matchManager
+ * @param featuresCheck
+ * the checker used to manage diff configuration
+ */
+ public PapyrusAttributesCheck(final IMatchManager matchManager, final FeaturesCheck featuresCheck) {
+ super(matchManager);
+ this.checker = featuresCheck;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.compare.diff.engine.check.AttributesCheck#shouldBeIgnored(org.eclipse.emf.ecore.EAttribute)
+ *
+ * @param attribute
+ * @return
+ */
+ @Override
+ protected boolean shouldBeIgnored(final EAttribute attribute) {
+ boolean shouldBeIgnored = super.shouldBeIgnored(attribute);
+ return shouldBeIgnored || this.checker.shouldBeIgnored(attribute);
+ }
+
+ /**
+ * return <code>true</code> if the attribute should be ignored in this context
+ *
+ * @param attribute
+ * an attribute
+ * @param context
+ * the context of this attribute
+ * @return
+ */
+ protected boolean shouldBeIgnored(final EAttribute attribute, final EObject context) {
+ return this.checker.shouldBeIgnored(attribute, context);
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.compare.diff.engine.check.AttributesCheck#checkAttributesUpdates(org.eclipse.emf.compare.diff.metamodel.DiffGroup, org.eclipse.emf.compare.match.metamodel.Match2Elements)
+ *
+ * @param root
+ * @param mapping
+ * @throws FactoryException
+ */
+ @Override
+ public void checkAttributesUpdates(DiffGroup root, Match2Elements mapping) throws FactoryException {
+ final EClass eClass = mapping.getLeftElement().eClass();
+
+ final List<EAttribute> eclassAttributes = eClass.getEAllAttributes();
+ // for each feature, compare the value
+ final Iterator<EAttribute> it = eclassAttributes.iterator();
+ while(it.hasNext()) {
+ final EAttribute next = it.next();
+ if(!shouldBeIgnored(next) && !shouldBeIgnored(next, mapping.getLeftElement())) {
+ checkAttributeUpdates(root, mapping, next);
+ }
+ }
+ }
+
+ /**
+ * This will iterate through all the attributes of the <code>mapping</code>'s three elements to check if
+ * any of them has been modified.
+ *
+ * @param root
+ * {@link DiffGroup root} of the {@link DiffElement} to create if one of the attribute has
+ * actually been changed.
+ * @param mapping
+ * This contains the mapping information about the elements we need to check for a move.
+ * @throws FactoryException
+ * Thrown if one of the checks fails.
+ */
+ public void checkAttributesUpdates(DiffGroup root, Match3Elements mapping) throws FactoryException {
+ // Ignores matchElements when they don't have origin (no updates on
+ // these)
+ if(mapping.getOriginElement() == null)
+ return;
+ final EClass eClass = mapping.getOriginElement().eClass();
+
+ final List<EAttribute> eclassAttributes = eClass.getEAllAttributes();
+ // for each feature, compare the value
+ final Iterator<EAttribute> it = eclassAttributes.iterator();
+ while(it.hasNext()) {
+ final EAttribute next = it.next();
+ if(!shouldBeIgnored(next) && !shouldBeIgnored(next, mapping.getOriginElement())) {
+ checkAttributeUpdates(root, mapping, next);
+ }
+ }
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusReferencesCheck.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusReferencesCheck.java new file mode 100644 index 00000000000..226b2b7b52a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/check/PapyrusReferencesCheck.java @@ -0,0 +1,147 @@ +/*****************************************************************************
+ * 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.diff.check;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.engine.IMatchManager;
+import org.eclipse.emf.compare.diff.engine.check.ReferencesCheck;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.match.metamodel.Match2Elements;
+import org.eclipse.emf.compare.match.metamodel.Match3Elements;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ *
+ * This reference checker allows to ignore differences on features for the comparison
+ *
+ */
+public class PapyrusReferencesCheck extends ReferencesCheck {
+
+ /**
+ * the checker used to take in account the ignored features for the Diff
+ */
+ private final FeaturesCheck checker;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param matchManager
+ * @param checker
+ * the checker used to take in account the ignored features for the Diff
+ */
+ public PapyrusReferencesCheck(final IMatchManager matchManager, final FeaturesCheck checker) {
+ super(matchManager);
+ this.checker = checker;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.compare.diff.engine.check.ReferencesCheck#shouldBeIgnored(org.eclipse.emf.ecore.EReference)
+ *
+ * @param reference
+ * @return
+ */
+ @Override
+ protected boolean shouldBeIgnored(final EReference reference) {
+ boolean shouldBeIgnored = super.shouldBeIgnored(reference);
+ return shouldBeIgnored || this.checker.shouldBeIgnored(reference);
+ }
+
+ /**
+ * return <code>true</code> if the attribute should be ignored in this context
+ *
+ * @param reference
+ * a reference
+ * @param context
+ * the context of this reference
+ * @return
+ */
+ protected boolean shouldBeIgnored(final EReference reference, final EObject context) {
+ return this.checker.shouldBeIgnored(reference, context);
+ }
+
+ /**
+ * Checks if there's been references updates in the model.<br/>
+ * <p>
+ * A reference is considered updated if its value(s) has been changed (either removal or addition of an element if the reference is multi-valued
+ * or update of a single-valued reference) between the left and the right model.
+ * </p>
+ *
+ * @param root
+ * {@link DiffGroup root} of the {@link DiffElement} to create.
+ * @param mapping
+ * Contains informations about the left and right model elements we have to compare.
+ * @throws FactoryException
+ * Thrown if we cannot fetch the references' values.
+ */
+ public void checkReferencesUpdates(DiffGroup root, Match2Elements mapping) throws FactoryException {
+ final EClass eClass = mapping.getLeftElement().eClass();
+ final List<EReference> eclassReferences = eClass.getEAllReferences();
+
+ final Iterator<EReference> it = eclassReferences.iterator();
+ while(it.hasNext()) {
+ final EReference next = it.next();
+ if(!shouldBeIgnored(next, mapping.getLeftElement())) {
+ if(!shouldBeIgnored(next)) {
+ checkReferenceUpdates(root, mapping, next);
+ } else if(next.isContainment() && next.isOrdered()) {
+ checkContainmentReferenceOrderChange(root, mapping, next);
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if there's been references updates in the model.<br/>
+ * <p>
+ * A reference is considered updated if its value(s) has been changed (either removal or addition of an element if the reference is multi-valued
+ * or update of a single-valued reference) between the left and the ancestor model, the right and the ancestor or between the left and the right
+ * model.
+ * </p>
+ *
+ * @param root
+ * {@link DiffGroup root} of the {@link DiffElement} to create.
+ * @param mapping
+ * Contains informations about the left, right and origin model elements we have to compare.
+ * @throws FactoryException
+ * Thrown if we cannot fetch the references' values.
+ */
+ public void checkReferencesUpdates(DiffGroup root, Match3Elements mapping) throws FactoryException {
+ // Ignores matchElements when they don't have origin (no updates on these)
+ if(mapping.getOriginElement() == null)
+ return;
+ final EClass eClass = mapping.getOriginElement().eClass();
+ final List<EReference> eclassReferences = eClass.getEAllReferences();
+
+ final Iterator<EReference> it = eclassReferences.iterator();
+ while(it.hasNext()) {
+ final EReference next = it.next();
+ if(!shouldBeIgnored(next, mapping.getLeftElement())) {
+ if(!shouldBeIgnored(next)) {
+ checkReferenceUpdates(root, mapping, next);
+ } else if(next.isContainment() && next.isOrdered()) {
+ checkContainmentReferenceOrderChange(root, mapping, next);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/AbstractFireMergeCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/AbstractFireMergeCommand.java new file mode 100644 index 00000000000..e6fea11c30a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/AbstractFireMergeCommand.java @@ -0,0 +1,76 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+
+
+public abstract class AbstractFireMergeCommand extends AbstractCommand {
+
+ /**
+ * the list of the listeners
+ */
+ private final List<IMergeListener> listeners;
+
+ /**
+ * a list of the diff element
+ */
+ private final List<DiffElement> diffs;
+
+ private final DiffElement diffElement;
+
+ public AbstractFireMergeCommand(final DiffElement diffElement, final List<IMergeListener> listeners) {
+ this.diffElement = diffElement;
+ this.diffs = Collections.emptyList();
+ this.listeners = new ArrayList<IMergeListener>(listeners);
+ }
+
+ public AbstractFireMergeCommand(final List<DiffElement> diffs, final List<IMergeListener> listeners) {
+ this.diffElement = null;
+ this.diffs = new ArrayList<DiffElement>(diffs);
+ this.listeners = new ArrayList<IMergeListener>(listeners);
+ }
+
+ public boolean canRedo() {
+ return canExecute();
+ }
+
+ public List<IMergeListener> getMergeListeners() {
+ return Collections.unmodifiableList(listeners);
+ }
+
+ public List<DiffElement> getDiffElementsList() {
+ return Collections.unmodifiableList(this.diffs);
+ }
+
+ public DiffElement getDiffElement() {
+ return this.diffElement;
+ }
+
+ @Override
+ protected boolean prepare() {
+ return true;
+ }
+
+ public void redo() {
+ execute();
+
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/CopyXMIIDCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/CopyXMIIDCommand.java new file mode 100644 index 00000000000..ca2070468a5 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/CopyXMIIDCommand.java @@ -0,0 +1,111 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+/**
+ *
+ * This command allows to copy the XMI_ID from one EObject to another one, only if they are not owned by the same resource
+ *
+ */
+//TODO should be moved in infra.emf plugin when the problem of the saùme resource will be corrected in Papyrus
+public class CopyXMIIDCommand extends AbstractCommand {
+
+ /**
+ * the EObject which provides the XMI_ID
+ */
+ private final EObject source;
+
+ /**
+ * the EObject which receive the XMI_ID
+ */
+ private final EObject target;
+
+ /**
+ * the initial XMI_ID of the target
+ */
+ private String initialID;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ * the EObject which provides the XMI_ID
+ * @param target
+ * the EObject which receive the XMI_ID
+ */
+ public CopyXMIIDCommand(final EObject source, final EObject target) {
+ this.source = source;
+ this.target = target;
+ this.initialID = null;
+ setLabel("Copy XMI_ID command"); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.command.Command#execute()
+ *
+ */
+ public void execute() {
+ final Resource sourceResource = source.eResource();
+ final Resource targetResource = target.eResource();
+ if(sourceResource instanceof XMIResource && targetResource instanceof XMIResource) {
+ if(sourceResource != targetResource) {//see bug 377189: [Nested UML Compare] the merged elements have the same XMI ID
+ final String xmi_id = EMFHelper.getXMIID(this.source);
+ this.initialID = EMFHelper.getXMIID(target);
+ ((XMIResource)this.target.eResource()).setID(this.target, xmi_id);
+ }
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.command.Command#redo()
+ *
+ */
+ public void redo() {
+ execute();
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
+ *
+ * @return
+ */
+ @Override
+ protected boolean prepare() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#undo()
+ *
+ */
+ @Override
+ public void undo() {
+ final Resource targetResource = target.eResource();
+ if(targetResource instanceof XMIResource) {
+ ((XMIResource)this.target.eResource()).setID(this.target, this.initialID);
+ }
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffEndCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffEndCommand.java new file mode 100644 index 00000000000..8f69d5dc751 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffEndCommand.java @@ -0,0 +1,43 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.merge.MergeEvent;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+
+
+public class FireMergeDiffEndCommand extends AbstractFireMergeCommand {
+
+ public FireMergeDiffEndCommand(final DiffElement diffElement, final List<IMergeListener> listeners) {
+ super(diffElement, listeners);
+ }
+
+ public void execute() {
+ List<IMergeListener> listeners = getMergeListeners();
+ if(getDiffElement() != null) {
+ for(IMergeListener current : listeners) {
+ current.mergeDiffStart(new MergeEvent(getDiffElement()));
+ }
+
+ }
+ }
+
+ @Override
+ public void undo() {
+ //TODO?
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffStartCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffStartCommand.java new file mode 100644 index 00000000000..cbbf8bdc1f1 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeDiffStartCommand.java @@ -0,0 +1,43 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.merge.MergeEvent;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+
+
+public class FireMergeDiffStartCommand extends AbstractFireMergeCommand {
+
+ public FireMergeDiffStartCommand(final DiffElement diffElement, final List<IMergeListener> listeners) {
+ super(diffElement, listeners);
+ }
+
+ public void execute() {
+ List<IMergeListener> listeners = getMergeListeners();
+ if(getDiffElement() != null) {
+ for(IMergeListener current : listeners) {
+ current.mergeDiffEnd(new MergeEvent(getDiffElement()));
+ }
+
+ }
+ }
+
+ @Override
+ public void undo() {
+ //TODO?
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationEndCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationEndCommand.java new file mode 100644 index 00000000000..62efe3df121 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationEndCommand.java @@ -0,0 +1,52 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.merge.MergeEvent;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+
+
+public class FireMergeOperationEndCommand extends AbstractFireMergeCommand {
+
+ public FireMergeOperationEndCommand(final DiffElement diffElement, final List<IMergeListener> listeners) {
+ super(diffElement, listeners);
+ }
+
+ public FireMergeOperationEndCommand(final List<DiffElement> diffs, final List<IMergeListener> listeners) {
+ super(diffs, listeners);
+ }
+
+ public void execute() {
+ List<IMergeListener> listeners = getMergeListeners();
+ if(!getDiffElementsList().isEmpty()) {
+ for(IMergeListener current : listeners) {
+ current.mergeOperationEnd(new MergeEvent(getDiffElementsList()));
+ }
+ }
+ if(getDiffElement() != null) {
+ for(IMergeListener current : listeners) {
+ current.mergeOperationEnd(new MergeEvent(getDiffElement()));
+ }
+
+ }
+ }
+
+ @Override
+ public void undo() {
+ //TODO?
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationStartCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationStartCommand.java new file mode 100644 index 00000000000..76f611bc7a7 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/FireMergeOperationStartCommand.java @@ -0,0 +1,52 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.merge.MergeEvent;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+
+
+public class FireMergeOperationStartCommand extends AbstractFireMergeCommand {
+
+ public FireMergeOperationStartCommand(final DiffElement diffElement, final List<IMergeListener> listeners) {
+ super(diffElement, listeners);
+ }
+
+ public FireMergeOperationStartCommand(final List<DiffElement> diffs, final List<IMergeListener> listeners) {
+ super(diffs, listeners);
+ }
+
+ public void execute() {
+ List<IMergeListener> listeners = getMergeListeners();
+ if(!getDiffElementsList().isEmpty()) {
+ for(IMergeListener current : listeners) {
+ current.mergeOperationStart(new MergeEvent(getDiffElementsList()));
+ }
+ }
+ if(getDiffElement() != null) {
+ for(IMergeListener current : listeners) {
+ current.mergeOperationStart(new MergeEvent(getDiffElement()));
+ }
+
+ }
+ }
+
+ @Override
+ public void undo() {
+ //TODO?
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexCommand.java new file mode 100644 index 00000000000..1150ea6df39 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexCommand.java @@ -0,0 +1,257 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.internal.l10n.EMFTypeCoreMessages;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+
+//TODO move this class and create it in the service edit
+//TODO : breaks this class into 2 classes : 1 for the move and another one for the reorder?
+public class MoveWithIndexCommand extends MoveElementsCommand {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param request
+ */
+ public MoveWithIndexCommand(final MoveRequest request) {
+ super(request);
+ }
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final int index = getIndex();
+ if(index != -1) {
+ for(Iterator<?> i = getElementsToMove().keySet().iterator(); i.hasNext();) {
+ final EObject element = (EObject)i.next();
+ final EReference feature = getTargetFeature(element);
+ if(feature != null) {
+ if(FeatureMapUtil.isMany(getTargetContainer(), feature)) {
+ if(shouldReorder()) {
+ //we attach the real position to the object
+ attachRealPositionEAdapter(element, index);
+ }
+ final Object value = getTargetContainer().eGet(feature);
+ if(value instanceof List<?>) {
+ final List<?> listValue = (List<?>)value;
+ final int indexMax = listValue.size() - 1;
+ if(indexMax < index) {
+ //we add the element at the end of the list
+ final List values = ((List<?>)getTargetContainer().eGet(feature));
+ values.add(element);
+ if(shouldReorder()) {
+ reorderList(values);
+ }
+ } else {
+ ((List)value).add(index, element);
+ if(shouldReorder()) {
+ reorderList((List)value);
+ }
+ }
+
+ } else {
+ ((Collection)getTargetContainer().eGet(feature)).add(element);
+ if(shouldReorder()) {
+ reorderList((List)((Collection)getTargetContainer().eGet(feature)));
+ }
+ }
+ } else {
+ getTargetContainer().eSet(feature, element);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult(EMFTypeCoreMessages.moveElementsCommand_noTargetFeature);
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ return super.doExecuteWithResult(monitor, info);
+ }
+
+ @Override
+ public boolean canExecute() {
+ super.canExecute();
+ return true;
+ }
+
+ /**
+ *
+ * @return
+ * the index for the move command
+ */
+ protected int getIndex() {
+ IEditCommandRequest req = getRequest();
+ if(req instanceof MoveWithIndexRequest) {
+ return ((MoveWithIndexRequest)req).getIndex();
+ }
+ return -1;
+ }
+
+ /**
+ *
+ * @return
+ * <code>true</code> when the list should be reorderded
+ */
+ protected boolean shouldReorder() {
+ final IEditCommandRequest req = getRequest();
+ boolean shouldReoder = false;
+ if(req instanceof MoveWithIndexRequest) {
+ shouldReoder = ((MoveWithIndexRequest)req).shouldReoder();
+ }
+ return shouldReoder;
+ }
+
+ /**
+ * Duplicate code from EFactory
+ * If we could not merge a given object at its expected position in a list, we'll attach an Adapter to it
+ * in order to "remember" that "expected" position. That will allow us to reorder the list later on if
+ * need be.
+ *
+ * @param object
+ * The object on which to attach an Adapter.
+ * @param expectedPosition
+ * The expected position of <code>object</code> in its list.
+ */
+ private void attachRealPositionEAdapter(final Object object, final int expectedPosition) {
+ if(object instanceof EObject) {
+ ((EObject)object).eAdapters().add(new PositionAdapter(expectedPosition));
+ }
+ }
+
+ /**
+ * Reorders the given list if it contains EObjects associated with a PositionAdapter which are not located
+ * at their expected positions.
+ *
+ * @param list
+ * The list that is to be reordered.
+ * @param <T>
+ * type of the list's elements.
+ */
+ private <T> void reorderList(final List<T> list) {
+ List<T> newList = new ArrayList<T>(list);
+ Collections.sort(newList, new EObjectComparator());
+ for(int i = 0; i < list.size(); i++) {
+ int oldIndex = list.indexOf(newList.get(i));
+ list.add(i, list.remove(oldIndex));
+ }
+ return;
+ }
+
+ /**
+ * duplicate code from Efactory
+ * This adapter will be used to remember the accurate position of an EObject in its target list.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+ private static class PositionAdapter extends AdapterImpl {
+
+ /** The index at which we expect to find this object. */
+ private final int expectedIndex;
+
+ /**
+ * Creates our adapter.
+ *
+ * @param index
+ * The index at which we expect to find this object.
+ */
+ public PositionAdapter(final int index) {
+ this.expectedIndex = index;
+ }
+
+ /**
+ * Returns the index at which we expect to find this object.
+ *
+ * @return The index at which we expect to find this object.
+ */
+ public int getExpectedIndex() {
+ return expectedIndex;
+ }
+ }
+
+ /**
+ *
+ * This class allows to compare EObject using the PositionAdapter.
+ *
+ *
+ */
+ private static class EObjectComparator<T> implements Comparator<T> {
+
+ /**
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ public int compare(final T o1, final T o2) {
+ if(o1 instanceof EObject && o2 instanceof EObject) {
+ final int position1 = getWantedPosition((EObject)o1);
+ final int position2 = getWantedPosition((EObject)o2);
+ if(position1 != -1 && position2 != -1) {
+ return position1 - position2;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ *
+ * @param obj1
+ * an EObject
+ * @return
+ * the wanted position for this object
+ */
+ private int getWantedPosition(final EObject obj1) {
+ final Iterator<Adapter> adapters = obj1.eAdapters().iterator();
+ int expectedIndex = -1;
+ while(expectedIndex == -1 && adapters.hasNext()) {
+ final Adapter adapter = adapters.next();
+ if(adapter instanceof PositionAdapter) {
+ expectedIndex = ((PositionAdapter)adapter).getExpectedIndex();
+ }
+ }
+ return expectedIndex;
+ }
+
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexRequest.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexRequest.java new file mode 100644 index 00000000000..64abe2dc988 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/MoveWithIndexRequest.java @@ -0,0 +1,56 @@ +/*****************************************************************************
+ * 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.diff.internal.command;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+
+//TODO : move this class
+/**
+ *
+ * Created for EMF-Compare, for MoveModelElementMerger
+ *
+ *
+ */
+public class MoveWithIndexRequest extends MoveRequest {
+
+ /**
+ * the wanted index for the moved element
+ */
+ private final int index;
+
+ /**
+ * indicates if the list should be reordered after the move
+ */
+ private final boolean reorder;
+
+ //TODO : and the other constructor?
+ public MoveWithIndexRequest(final TransactionalEditingDomain editingDomain, final EObject targetContainer, final EReference targetFeature, final EObject elementToMove, final int index, final boolean reorder) {
+ super(editingDomain, targetContainer, targetFeature, elementToMove);
+ this.index = index;
+ this.reorder = reorder;
+ }
+
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public boolean shouldReoder() {
+ return this.reorder;
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/PapyrusMergeCommandProvider.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/PapyrusMergeCommandProvider.java new file mode 100644 index 00000000000..b0260226a9f --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/command/PapyrusMergeCommandProvider.java @@ -0,0 +1,78 @@ +/*****************************************************************************
+ * Copyright (c) 2011 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.diff.internal.command;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+
+//TODO : try to merge with the PapyrusTableCommandFactory?
+public class PapyrusMergeCommandProvider {
+
+ public static PapyrusMergeCommandProvider INSTANCE = new PapyrusMergeCommandProvider();
+
+ private PapyrusMergeCommandProvider() {
+
+ }
+
+ public Command getDestroyCommand(final TransactionalEditingDomain domain, final EObject element) {
+ final IEditCommandRequest request = new DestroyElementRequest(domain, element, false);
+ return getCommand(element, request);
+ }
+
+ //TODO elementToEdit and targetContainer are the same
+ public Command getMoveCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EObject targetContainer, final EReference targetFeature, final EObject elementToMove) {
+ final IEditCommandRequest request = new MoveRequest(domain, targetContainer, targetFeature, elementToMove);
+ return getCommand(elementToEdit, request);
+ }
+
+ public Command getCommand(final EObject elementToEdit, final IEditCommandRequest request) {
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
+ if(request instanceof MoveWithIndexRequest) {//TODO remove this test when the move with index will be in the service edit
+ return new GMFtoEMFCommandWrapper(new MoveWithIndexCommand((MoveRequest)request));
+ }
+ if(provider != null) {
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
+ return null;
+ }
+
+ public Command getDestroyReferenceCommand(final TransactionalEditingDomain editingDomain, final EObject container, final EReference containingFeature, final EObject referencedObject, final boolean confirmationRequired) {
+ final IEditCommandRequest request = new DestroyReferenceRequest(editingDomain, container, containingFeature, referencedObject, confirmationRequired);
+ return getCommand(container, request);
+ }
+
+ public Command getSetCommand(final TransactionalEditingDomain domain, final EObject element, final EStructuralFeature feature, final Object value) {
+ final IEditCommandRequest request = new SetRequest(domain, element, feature, value);
+ return getCommand(element, request);
+ }
+
+
+ //TODO elementToEdit and targetContainer are the same
+ public Command getMoveWithIndexCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EObject targetContainer, final EReference targetFeature, final EObject elementToMove, final int index, final boolean reorder) {
+ final IEditCommandRequest request = new MoveWithIndexRequest(domain, targetContainer, targetFeature, elementToMove, index, reorder);
+ return getCommand(elementToEdit, request);
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AbstractDefaultMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AbstractDefaultMerger.java new file mode 100644 index 00000000000..b35b092fa0a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AbstractDefaultMerger.java @@ -0,0 +1,29 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import org.eclipse.emf.compare.diff.merge.IMerger;
+
+
+public abstract class AbstractDefaultMerger implements IMerger {
+
+ final public void applyInOrigin() {
+ throw new UnsupportedOperationException("This method is not available in a Transactional Compare Editor");
+ }
+
+ final public void undoInTarget() {
+ throw new UnsupportedOperationException("This method is not available in a Transactional Compare Editor");
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeLeftTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeLeftTargetTransactionalMerger.java new file mode 100644 index 00000000000..377b95f0a25 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeLeftTargetTransactionalMerger.java @@ -0,0 +1,125 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.EMFComparePlugin;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeLeftTarget;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+/**
+ *
+ * Transactional version of the class {@link AttributeChangeLeftTargetMerger}
+ *
+ */
+public class AttributeChangeLeftTargetTransactionalMerger extends DefaultTransactionalMerger {
+
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeChangeLeftTargetMerger}
+ // *
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // *
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget)this.diff;
+ // final EObject origin = theDiff.getLeftElement();
+ // final Object value = theDiff.getLeftTarget();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // EFactory.eRemove(origin, attr.getName(), value);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeChangeLeftTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // *
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget)this.diff;
+ // final EObject target = theDiff.getRightElement();
+ // final Object value = theDiff.getLeftTarget();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // int valueIndex = -1;
+ // if(attr.isMany()) {
+ // final EObject leftElement = theDiff.getLeftElement();
+ // final Object leftValues = leftElement.eGet(attr);
+ // if(leftValues instanceof List) {
+ // final List leftValuesList = (List)leftValues;
+ // valueIndex = leftValuesList.indexOf(value);
+ // }
+ // }
+ // EFactory.eAdd(target, attr.getName(), value, valueIndex);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+
+
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget)this.diff;
+ final EObject origin = theDiff.getLeftElement();
+ final Object value = theDiff.getLeftTarget();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ cmd = PapyrusEFactory.getERemoveCommand(domain, origin, attr.getName(), value);
+ } catch (FactoryException e) {
+ EMFComparePlugin.log(e, true);
+ }
+ return cmd;
+ }
+
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget)this.diff;
+ final EObject target = theDiff.getRightElement();
+ final Object value = theDiff.getLeftTarget();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ int valueIndex = -1;
+ if(attr.isMany()) {
+ final EObject leftElement = theDiff.getLeftElement();
+ final Object leftValues = leftElement.eGet(attr);
+ if(leftValues instanceof List) {
+ final List<?> leftValuesList = (List<?>)leftValues;
+ valueIndex = leftValuesList.indexOf(value);
+ }
+ }
+ cmd = PapyrusEFactory.getEAddCommand(domain, target, attr.getName(), value, valueIndex);
+ } catch (FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeRightTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeRightTargetTransactionalMerger.java new file mode 100644 index 00000000000..32501ba0853 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeChangeRightTargetTransactionalMerger.java @@ -0,0 +1,117 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeRightTarget;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+/**
+ *
+ * Transactional version of the class {@link AttributeChangeRightTargetMerger}
+ *
+ */
+public class AttributeChangeRightTargetTransactionalMerger extends DefaultTransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeChangeRightTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final AttributeChangeRightTarget theDiff = (AttributeChangeRightTarget)this.diff;
+ // final EObject origin = theDiff.getLeftElement();
+ // final Object value = theDiff.getRightTarget();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // int valueIndex = -1;
+ // if(attr.isMany()) {
+ // final EObject rightElement = theDiff.getRightElement();
+ // final Object rightValues = rightElement.eGet(attr);
+ // if(rightValues instanceof List) {
+ // final List rightValuesList = (List)rightValues;
+ // valueIndex = rightValuesList.indexOf(value);
+ // }
+ // }
+ // EFactory.eAdd(origin, attr.getName(), value, valueIndex);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeChangeRightTargetMerger}
+ // *
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final AttributeChangeRightTarget theDiff = (AttributeChangeRightTarget)this.diff;
+ // final EObject target = theDiff.getRightElement();
+ // final Object value = theDiff.getRightTarget();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // EFactory.eRemove(target, attr.getName(), value);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final AttributeChangeRightTarget theDiff = (AttributeChangeRightTarget)this.diff;
+ final EObject origin = theDiff.getLeftElement();
+ final Object value = theDiff.getRightTarget();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ int valueIndex = -1;
+ if(attr.isMany()) {
+ final EObject rightElement = theDiff.getRightElement();
+ final Object rightValues = rightElement.eGet(attr);
+ if(rightValues instanceof List) {
+ final List<?> rightValuesList = (List<?>)rightValues;
+ valueIndex = rightValuesList.indexOf(value);
+ }
+ }
+ cmd = PapyrusEFactory.getEAddCommand(domain, origin, attr.getName(), value, valueIndex);
+ } catch (FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final AttributeChangeRightTarget theDiff = (AttributeChangeRightTarget)this.diff;
+ final EObject target = theDiff.getRightElement();
+ final Object value = theDiff.getRightTarget();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ cmd = PapyrusEFactory.getERemoveCommand(domain, target, attr.getName(), value);
+ } catch (FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeOrderChangeTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeOrderChangeTransactionalMerger.java new file mode 100644 index 00000000000..51eeb52bb4b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/AttributeOrderChangeTransactionalMerger.java @@ -0,0 +1,300 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.diff.internal.merge.impl.AttributeOrderChangeMerger;
+import org.eclipse.emf.compare.diff.metamodel.AttributeOrderChange;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+import org.eclipse.papyrus.infra.tools.util.ReflectHelper;
+
+/**
+ *
+ * Transactional version of the class {@link AttributeOrderChangeMerger}
+ *
+ */
+public class AttributeOrderChangeTransactionalMerger extends DefaultTransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeOrderChangeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final AttributeOrderChange theDiff = (AttributeOrderChange)this.diff;
+ // final EAttribute attribute = theDiff.getAttribute();
+ // final EObject leftElement = theDiff.getLeftElement();
+ // final EObject rightElement = theDiff.getRightElement();
+ //
+ // final List<Object> leftList = (List<Object>)leftElement.eGet(attribute);
+ // final List<Object> rightList = (List<Object>)rightElement.eGet(attribute);
+ //
+ // /*
+ // * We need to transform the "left" list into the "right" list, modulo missing values. In practical
+ // * terms, this means that we'll simply leave untouched any element that has no match in the "right"
+ // * list (elements that were deleted) while reordering the others in the order they have in the "right"
+ // * list.
+ // */
+ // final List<Object> leftCopy = new ArrayList<Object>(leftList);
+ // final List<Object> result = new ArrayList<Object>(leftList.size());
+ // // Add all unmatched values in the result list
+ // for(int i = 0; i < leftList.size(); i++) {
+ // final Object left = leftList.get(i);
+ //
+ // boolean hasMatch = false;
+ // for(int j = 0; !hasMatch && j < rightList.size(); j++) {
+ // hasMatch = !areDistinctValues(left, rightList.get(j));
+ // }
+ //
+ // if(!hasMatch) {
+ // leftCopy.remove(left);
+ // result.add(left);
+ // }
+ // }
+ // // Then reorder according to the right list's order
+ // for(int i = 0; i < rightList.size(); i++) {
+ // final Object right = rightList.get(i);
+ //
+ // Object leftMatch = null;
+ // for(int j = 0; leftMatch == null && j < leftCopy.size(); j++) {
+ // if(!areDistinctValues(right, leftCopy.get(j))) {
+ // leftMatch = leftCopy.get(j);
+ // }
+ // }
+ //
+ // if(leftMatch != null) {
+ // leftCopy.remove(leftMatch);
+ // result.add(leftMatch);
+ // }
+ // }
+ // // Finally, set the value of our attribute to this new list
+ // leftElement.eSet(attribute, result);
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link AttributeOrderChangeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final AttributeOrderChange theDiff = (AttributeOrderChange)this.diff;
+ // final EAttribute attribute = theDiff.getAttribute();
+ // final EObject leftElement = theDiff.getLeftElement();
+ // final EObject rightElement = theDiff.getRightElement();
+ //
+ // final List<Object> leftList = (List<Object>)leftElement.eGet(attribute);
+ // final List<Object> rightList = (List<Object>)rightElement.eGet(attribute);
+ //
+ // /*
+ // * We need to transform the "right" list into the "left" list, modulo missing values. In practical
+ // * terms, this means that we'll simply leave untouched any element that has no match in the "left"
+ // * list (elements that were added) while reordering the others in the order they have in the "left"
+ // * list.
+ // */
+ // final List<Object> rightCopy = new ArrayList<Object>(rightList);
+ // final List<Object> result = new ArrayList<Object>(rightList.size());
+ // // Add all unmatched values in the result list
+ // for(int i = 0; i < rightList.size(); i++) {
+ // final Object right = rightList.get(i);
+ //
+ // boolean hasMatch = false;
+ // for(int j = 0; !hasMatch && j < leftList.size(); j++) {
+ // hasMatch = !areDistinctValues(right, leftList.get(j));
+ // }
+ //
+ // if(!hasMatch) {
+ // rightCopy.remove(right);
+ // result.add(right);
+ // }
+ // }
+ // // Then reorder according to the left list's order
+ // for(int i = 0; i < leftList.size(); i++) {
+ // final Object left = leftList.get(i);
+ //
+ // Object rightMatch = null;
+ // for(int j = 0; rightMatch == null && j < rightCopy.size(); j++) {
+ // if(!areDistinctValues(left, rightCopy.get(j))) {
+ // rightMatch = rightCopy.get(j);
+ // }
+ // }
+ //
+ // if(rightMatch != null) {
+ // rightCopy.remove(rightMatch);
+ // result.add(rightMatch);
+ // }
+ // }
+ // // Finally, set the value of our attribute to this new list
+ // rightElement.eSet(attribute, result);
+ // }
+
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ final AttributeOrderChange theDiff = (AttributeOrderChange)this.diff;
+ final EAttribute attribute = theDiff.getAttribute();
+ final EObject leftElement = theDiff.getLeftElement();
+ final EObject rightElement = theDiff.getRightElement();
+
+ final List<Object> leftList = (List<Object>)leftElement.eGet(attribute);
+ final List<Object> rightList = (List<Object>)rightElement.eGet(attribute);
+
+ /*
+ * We need to transform the "left" list into the "right" list, modulo missing values. In practical
+ * terms, this means that we'll simply leave untouched any element that has no match in the "right"
+ * list (elements that were deleted) while reordering the others in the order they have in the "right"
+ * list.
+ */
+ final List<Object> leftCopy = new ArrayList<Object>(leftList);
+ final List<Object> result = new ArrayList<Object>(leftList.size());
+ // Add all unmatched values in the result list
+ for(int i = 0; i < leftList.size(); i++) {
+ final Object left = leftList.get(i);
+
+ boolean hasMatch = false;
+ for(int j = 0; !hasMatch && j < rightList.size(); j++) {
+ hasMatch = !areDistinctValues(left, rightList.get(j));
+ }
+
+ if(!hasMatch) {
+ leftCopy.remove(left);
+ result.add(left);
+ }
+ }
+ // Then reorder according to the right list's order
+ for(int i = 0; i < rightList.size(); i++) {
+ final Object right = rightList.get(i);
+
+ Object leftMatch = null;
+ for(int j = 0; leftMatch == null && j < leftCopy.size(); j++) {
+ if(!areDistinctValues(right, leftCopy.get(j))) {
+ leftMatch = leftCopy.get(j);
+ }
+ }
+
+ if(leftMatch != null) {
+ leftCopy.remove(leftMatch);
+ result.add(leftMatch);
+ }
+ }
+ // Finally, set the value of our attribute to this new list
+ // leftElement.eSet(attribute, result);
+ return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, leftElement, attribute, result);
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ final AttributeOrderChange theDiff = (AttributeOrderChange)this.diff;
+ final EAttribute attribute = theDiff.getAttribute();
+ final EObject leftElement = theDiff.getLeftElement();
+ final EObject rightElement = theDiff.getRightElement();
+
+ final List<Object> leftList = (List<Object>)leftElement.eGet(attribute);
+ final List<Object> rightList = (List<Object>)rightElement.eGet(attribute);
+
+ /*
+ * We need to transform the "right" list into the "left" list, modulo missing values. In practical
+ * terms, this means that we'll simply leave untouched any element that has no match in the "left"
+ * list (elements that were added) while reordering the others in the order they have in the "left"
+ * list.
+ */
+ final List<Object> rightCopy = new ArrayList<Object>(rightList);
+ final List<Object> result = new ArrayList<Object>(rightList.size());
+ // Add all unmatched values in the result list
+ for(int i = 0; i < rightList.size(); i++) {
+ final Object right = rightList.get(i);
+
+ boolean hasMatch = false;
+ for(int j = 0; !hasMatch && j < leftList.size(); j++) {
+ hasMatch = !areDistinctValues(right, leftList.get(j));
+ }
+
+ if(!hasMatch) {
+ rightCopy.remove(right);
+ result.add(right);
+ }
+ }
+ // Then reorder according to the left list's order
+ for(int i = 0; i < leftList.size(); i++) {
+ final Object left = leftList.get(i);
+
+ Object rightMatch = null;
+ for(int j = 0; rightMatch == null && j < rightCopy.size(); j++) {
+ if(!areDistinctValues(left, rightCopy.get(j))) {
+ rightMatch = rightCopy.get(j);
+ }
+ }
+
+ if(rightMatch != null) {
+ rightCopy.remove(rightMatch);
+ result.add(rightMatch);
+ }
+ }
+ // Finally, set the value of our attribute to this new list
+ // rightElement.eSet(attribute, result);
+ return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, rightElement, attribute, result);
+ }
+
+
+ /**
+ * This method uses the reflexive way to call the static method of the super class
+ *
+ * @param left
+ * the left object
+ * @param right
+ * the right object
+ * @return
+ * <code>true</code> if the 2 objects are dictinct.
+ */
+ //TODO write a JUnit test to be sure that this methods is always accessible
+ protected boolean areDistinctValues(final Object left, final Object right) {
+
+ final Class<?>[] parameterTypes = new Class[2];
+ parameterTypes[0] = java.lang.Object.class;
+ parameterTypes[1] = java.lang.Object.class;
+ Method m = null;
+ try {
+ m = ReflectHelper.getMethod(AttributeOrderChangeMerger.class, "areDistinctValues", parameterTypes); //$NON-NLS-1$
+ } catch (SecurityException e) {
+ Activator.log.error(e);
+ } catch (NoSuchMethodException e) {
+ Activator.log.error(e);
+ }
+
+ Object[] parameters = new Object[2];
+ parameters[0] = left;
+ parameters[1] = right;
+
+ Object result = null;
+ try {
+ result = m.invoke(AttributeOrderChangeMerger.class, parameters);
+ } catch (IllegalArgumentException e) {
+ Activator.log.error(e);
+ } catch (IllegalAccessException e) {
+ Activator.log.error(e);
+ } catch (InvocationTargetException e) {
+ Activator.log.error(e);
+ }
+ assert (result instanceof Boolean);
+ return ((Boolean)result).booleanValue();
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultExtensionTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultExtensionTransactionalMerger.java new file mode 100644 index 00000000000..5cc9046a09d --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultExtensionTransactionalMerger.java @@ -0,0 +1,81 @@ +/*****************************************************************************
+ * 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
+ * Adapted code from EMF-Compare
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.compare.diff.internal.merger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.IdentityCommand;
+import org.eclipse.emf.compare.diff.metamodel.AbstractDiffExtension;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+
+public class DefaultExtensionTransactionalMerger extends DefaultTransactionalMerger {
+
+ public Command getDoApplyInOriginCommand(TransactionalEditingDomain domain) {
+ return IdentityCommand.INSTANCE;
+ }
+
+ public Command getDoUndoInTargetCommand(TransactionalEditingDomain domain) {
+ return IdentityCommand.INSTANCE;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ final List<DiffElement> requiredDiffs = diff.getRequires();
+ return getBusinessDependencies(applyInOrigin, requiredDiffs);
+ }
+
+ /**
+ * Get the difference dependencies to consider in the context of the merge process.
+ *
+ * @param applyInOrigin
+ * Direction of merge.
+ * @param requiredDiffs
+ * The required differences.
+ * @return The required differences to keep.
+ */
+ protected List<DiffElement> getBusinessDependencies(boolean applyInOrigin, List<DiffElement> requiredDiffs) {
+ final List<DiffElement> result = new ArrayList<DiffElement>();
+ for (DiffElement diffElement : requiredDiffs) {
+ if (!(diffElement instanceof AbstractDiffExtension)
+ || diffElement instanceof AbstractDiffExtension
+ && isBusinessDependency(applyInOrigin, (AbstractDiffExtension)diffElement)) {
+ result.add(diffElement);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Check if the given required difference extension has to be considered in relation to the direction of
+ * merge.
+ *
+ * @param applyInOrigin
+ * Direction of merge.
+ * @param requiredDiff
+ * The required difference.
+ * @return True if it has to be considered in the merge.
+ */
+ protected boolean isBusinessDependency(boolean applyInOrigin, final AbstractDiffExtension requiredDiff) {
+ return true;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java new file mode 100644 index 00000000000..52eaf63e37b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java @@ -0,0 +1,724 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.IdentityCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.diff.merge.EMFCompareEObjectCopier;
+import org.eclipse.emf.compare.diff.merge.IMergeListener;
+import org.eclipse.emf.compare.diff.merge.IMerger;
+import org.eclipse.emf.compare.diff.merge.MergeEvent;
+import org.eclipse.emf.compare.diff.merge.service.MergeFactory;
+import org.eclipse.emf.compare.diff.merge.service.MergeService;
+import org.eclipse.emf.compare.diff.metamodel.ConflictingDiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChange;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.emf.compare.util.ClassUtils;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.CopyWithReferenceCommand;
+import org.eclipse.papyrus.infra.emf.compare.diff.merge.ITransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeFactory;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeService;
+import org.eclipse.papyrus.infra.emf.compare.diff.utils.PapyrusCompareOptionsUtils;
+import org.eclipse.papyrus.infra.emf.compare.diff.utils.PapyrusOptionsAdapter;
+
+/**
+ *
+ * should replace DefaultMerger
+ *
+ */
+//TODO can we remove IMerger?
+public class DefaultTransactionalMerger extends AbstractDefaultMerger implements ITransactionalMerger {
+
+ //---------------------These methods comes from ITransactionalMerger
+ public Command getApplyInOriginCommand(TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
+ final PapyrusOptionsAdapter adapter = PapyrusCompareOptionsUtils.getPapyrusOptionsAdapter(diff);
+ //cf bug 396267: [UML Compare] it is not possible to merge a difference on a stereotype property
+ //final CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff)); //$NON-NLS-1$
+ final CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff.getClass())); //$NON-NLS-1$
+ if(adapter==null || adapter.canApplyInOrigin()) {
+ cmd.append(getMergeRequiredDifferencesCommand(domain, true, alreadyManaged));
+ cmd.append(getDoApplyInOriginCommand(domain));
+ cmd.append(getPostProcessCommand(domain));
+ } else {
+ cmd.append(UnexecutableCommand.INSTANCE);
+ }
+ return cmd;
+ }
+
+ public Command getUndoInTargetCommand(TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
+ final PapyrusOptionsAdapter adapter = PapyrusCompareOptionsUtils.getPapyrusOptionsAdapter(diff);
+ //cf bug 396267: [UML Compare] it is not possible to merge a difference on a stereotype property
+ //final CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff)); //$NON-NLS-1$
+ final CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff.getClass())); //$NON-NLS-1$
+ if(adapter == null || adapter.canUndoInTarget()) {
+ cmd.append(getMergeRequiredDifferencesCommand(domain, false, alreadyManaged));
+ cmd.append(getDoUndoInTargetCommand(domain));
+ cmd.append(getPostProcessCommand(domain));
+ } else {
+ cmd.append(UnexecutableCommand.INSTANCE);
+ }
+ return cmd;
+ }
+
+ public Command getDoApplyInOriginCommand(TransactionalEditingDomain domain) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ public Command getDoUndoInTargetCommand(TransactionalEditingDomain domain) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ public Command getMergeRequiredDifferencesCommand(TransactionalEditingDomain domain, boolean applyInOrigin, Collection<DiffElement> alreadyManaged) {
+ CompoundCommand cmd = new CompoundCommand("Merge required differences"); //$NON-NLS-1$
+ // if(mergedDiffs == null) { //we need to clean it, to avoid that the command creation duplicate elements in this list
+ mergedDiffs = new ArrayList<DiffElement>();
+ if(mergedDiffslistener == null) {
+ //TODO : improve that, and use command!
+ mergedDiffslistener = new MergedDiffsListener();
+ TransactionalMergeService.addMergeListener(mergedDiffslistener);
+ }
+ // }
+ mergedDiffs.add(diff);
+
+ for(DiffElement requiredDiff : getDependencies(applyInOrigin)) {
+ if(requiredDiff.eContainer() != null && !alreadyManaged.contains(requiredDiff)) {
+ final ITransactionalMerger merger = TransactionalMergeFactory.createMerger(requiredDiff);
+ alreadyManaged.add(requiredDiff);
+ if(applyInOrigin) {
+ cmd.append(((ITransactionalMerger)merger).getApplyInOriginCommand(domain, alreadyManaged));
+ } else {
+ cmd.append(((ITransactionalMerger)merger).getUndoInTargetCommand(domain, alreadyManaged));
+ }
+ }
+ }
+ if(cmd.isEmpty()) {
+ return IdentityCommand.INSTANCE;
+ }
+ return cmd;
+ }
+
+ public Command getPostProcessCommand(TransactionalEditingDomain domain) {
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ handleMutuallyDerivedReferences();
+ //ensureXMIIDCopied();
+ if(getDiffModel() != null) {//383515: [UML Compare] NPE with ReferenceChangeRightTarget leftToRight and ReferenceChangeLeftTarget rightToLeft
+ final EMFCompareEObjectCopier copier = TransactionalMergeService.getCopier(diff);
+ copier.copyXMIIDs();
+ }
+ removeFromContainer(diff);
+ return null;
+ }
+ });
+ }
+
+ //TODO move it in an upper class
+ protected static TransactionalEditingDomain getTransactionalEditingDomain(final DiffElement diff) {
+ DiffElement diffElement = diff;
+ final Iterator<EObject> iter = diff.eAllContents();
+ while(iter.hasNext()) {
+ final EObject current = iter.next();
+ if(current instanceof DiffElement && !(current instanceof DiffGroup)) {
+ diffElement = (DiffElement)current;
+ break;
+ }
+ }
+ //we try to get the EditingDomain using the left object AND the rightObject,
+ //because in some case it should be interesting to do a comparison between an object contained by a resource
+ //and an other object no contained by a resource
+ EObject element = (EObject)ClassUtils.invokeMethod(diffElement, "getRightElement"); //$NON-NLS-1$
+ if(element == null) {
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getLeftElement"); //$NON-NLS-1$
+ }
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(element);
+
+ if(domain == null) {
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getRightParent"); //$NON-NLS-1$
+ if(element == null) {
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getLeftParent"); //$NON-NLS-1$
+ }
+ domain = TransactionUtil.getEditingDomain(element);
+ }
+ assert domain!=null; //cf bug 396267: [UML Compare] it is not possible to merge a difference on a stereotype property
+// Assert.isNotNull(domain, NLS.bind("I didn't found the EditingDomain for {0}", diff)); //$NON-NLS-1$
+ return domain;
+
+ }
+
+ public boolean canApplyInOrigin() {
+ return getApplyInOriginCommand(getTransactionalEditingDomain(diff), new ArrayList<DiffElement>()).canExecute();
+ }
+
+
+ public boolean canUndoInTarget() {
+ return getUndoInTargetCommand(getTransactionalEditingDomain(diff), new ArrayList<DiffElement>()).canExecute();
+ }
+
+ //---------------------from Here to the end : duplicated and adapted code from DefaultMerger
+ /** The scheme used for all of EMF Compare's internal proxies. */
+ private static final String PROXY_SCHEME = "emfCompareProxy"; //$NON-NLS-1$
+
+ /** Stores the differences which are merged or being merged during a merge operation. */
+ private static List<DiffElement> mergedDiffs;
+
+ /** This listener will be used to reset the {@link mergedDiffs} list at the end of a merge operation. */
+ private static MergedDiffsListener mergedDiffslistener;
+
+ /** {@link DiffElement} to be merged by this merger. */
+ protected DiffElement diff;
+
+ /** Keeps a reference on the left resource for this merger. */
+ @Deprecated
+ protected Resource leftResource;
+
+ /** Keeps a reference on the right resource for this merger. */
+ @Deprecated
+ protected Resource rightResource;
+
+ /**
+ * Reset the {@link mergedDiffs} list.
+ *
+ * @since 1.3
+ */
+ protected static void resetMergedDiffs() {
+ mergedDiffs = null;
+ }
+
+ /**
+ * Returns <code>true</code> if the given URI is an internal EMF Compare proxy.
+ *
+ * @param uri
+ * The URI to check.
+ * @return <code>true</code> if the given URI is an internal EMF Compare proxy.
+ * @since 1.3
+ */
+ public static boolean isEMFCompareProxy(URI uri) {
+ return uri.scheme() != null && uri.scheme().equals(PROXY_SCHEME);
+ }
+
+ /**
+ * Checks whether the two given proxy URIs are equal, ignoring EMF Compare's internal {@link #PROXY_PREFIX}.
+ *
+ * @param uri1
+ * First of the two URIs to compare.
+ * @param uri2
+ * Second of the two URIs to compare.
+ * @return <code>true</code> if the two given URIs are equal.
+ *
+ * @since 1.3
+ */
+ public static boolean equalProxyURIs(URI uri1, URI uri2) {
+ String stringValue1 = uri1.toString();
+ String stringValue2 = uri2.toString();
+ if(isEMFCompareProxy(uri1)) {
+ stringValue1 = stringValue1.substring(PROXY_SCHEME.length() + 2);
+ }
+ if(isEMFCompareProxy(uri2)) {
+ stringValue2 = stringValue2.substring(PROXY_SCHEME.length() + 2);
+ }
+ return stringValue1.equals(stringValue2);
+ }
+
+ // /**
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.IMerger#applyInOrigin()
+ // */
+ // public void applyInOrigin() {
+ // mergeRequiredDifferences(true);
+ // doApplyInOrigin();
+ // postProcess();
+ // }
+ //
+ // /**
+ // * Applies the modification in the original (left) model.
+ // *
+ // * @since 1.3
+ // */
+ // protected void doApplyInOrigin() {
+ // // To specialize in child class.
+ // }
+ //
+ // /**
+ // * Applies a post processing.
+ // *
+ // * @since 1.3
+ // */
+ // protected void postProcess() {
+ // handleMutuallyDerivedReferences();
+ // ensureXMIIDCopied();
+ // removeFromContainer(diff);
+ // }
+
+ // /**
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.IMerger#canApplyInOrigin()
+ // */
+ // public boolean canApplyInOrigin() {
+ // return true;
+ // }
+ //
+ // /**
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.IMerger#canUndoInTarget()
+ // */
+ // public boolean canUndoInTarget() {
+ // return true;
+ // }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMerger#setDiffElement(org.eclipse.emf.compare.diff.metamodel.DiffElement)
+ */
+ public void setDiffElement(DiffElement element) {
+ diff = element;
+ }
+
+ // /**
+ // * {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.IMerger#undoInTarget()
+ // */
+ // public void undoInTarget() {
+ // mergeRequiredDifferences(false);
+ // doUndoInTarget();
+ // postProcess();
+ // }
+ //
+ // /**
+ // * Cancels the modification in the target (right) model.
+ // *
+ // * @since 1.3
+ // */
+ // protected void doUndoInTarget() {
+ // // To specialize in child class.
+ // }
+
+ /**
+ * Removes the given {@link DiffGroup} from its container if it was its last child, also calls for the
+ * same cleanup operation on its hierarchy.
+ *
+ * @param diffGroup
+ * {@link DiffGroup} we want to cleanup.
+ */
+ protected void cleanDiffGroup(DiffGroup diffGroup) {
+ if(diffGroup != null && diffGroup.getSubDiffElements().size() == 0) {
+ final EObject parent = diffGroup.eContainer();
+ if(parent instanceof DiffGroup) {
+ EcoreUtil.remove(diffGroup);
+ cleanDiffGroup((DiffGroup)parent);
+ }
+ }
+ }
+
+ // /**
+ // * Creates a copy of the given EObject as would {@link EcoreUtil#copy(EObject)} would, except we use
+ // * specific handling for unmatched references.
+ // *
+ // * @param eObject
+ // * The object to copy.
+ // * @return the copied object.
+ // */
+ // protected EObject copy(EObject eObject) {
+ // final EMFCompareEObjectCopier copier = TransactionalMergeService.getCopier(diff);
+ // if(copier.containsKey(eObject)) {
+ // //385289: [UML Compare] Bad result after merginf UMLStereotypeApplicationAddition/Removal
+ // //in some case, the elements are copied and merged twice!
+ // return copier.get(eObject);
+ // }
+ // final EObject result = copier.copy(eObject);
+ // copier.copyReferences();
+ // copier.copyXMIIDs();
+ // return result;
+ // }
+
+ /**
+ *
+ * @param eObject
+ * the eobject copy
+ * @return
+ * the result of the command is the copiedObject
+ * the copied object is immediately available doing copyCommand.getCommandResult().getReturnValue();
+ */
+ protected AbstractTransactionalCommand getCopyWithReferenceCommand(final EObject eObject) {
+ return new CopyWithReferenceCommand(getTransactionalEditingDomain(diff), TransactionalMergeService.getCopier(diff), eObject);
+ }
+
+ /**
+ * This can be called after a merge operation to ensure that all objects created by the operation share
+ * the same XMI ID as their original.
+ * <p>
+ * Implemented because of bug 351591 : some of the objects we copy mays not have been added to a resource when we check their IDs. We thus need to
+ * wait till the merge operation has completed.
+ * </p>
+ *
+ * @since 1.3
+ */
+ protected void ensureXMIIDCopied() {
+ final EMFCompareEObjectCopier copier = TransactionalMergeService.getCopier(diff);
+ copier.copyXMIIDs();
+ }
+
+ /**
+ * Returns the {@link DiffModel} containing the {@link DiffElement} this merger is intended to merge.
+ *
+ * @return The {@link DiffModel} containing the {@link DiffElement} this merger is intended to merge.
+ */
+ protected DiffModel getDiffModel() {
+ EObject container = diff.eContainer();
+ while(container != null) {
+ if(container instanceof DiffModel)
+ return (DiffModel)container;
+ container = container.eContainer();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the XMI ID of the given {@link EObject} or <code>null</code> if it cannot be resolved.
+ *
+ * @param object
+ * Object which we seek the XMI ID of.
+ * @return <code>object</code>'s XMI ID, <code>null</code> if not applicable.
+ */
+ protected String getXMIID(EObject object) {
+ String objectID = null;
+ if(object != null && object.eResource() instanceof XMIResource) {
+ objectID = ((XMIResource)object.eResource()).getID(object);
+ }
+ return objectID;
+ }
+
+ /**
+ * Removes all references to the given {@link EObject} from the {@link DiffModel}.
+ *
+ * @param deletedObject
+ * Object to remove all references to.
+ */
+ protected void removeDanglingReferences(EObject deletedObject) {
+ // EObject root = EcoreUtil.getRootContainer(deletedObject);
+ // if (root instanceof ComparisonResourceSnapshot) {
+ // root = ((ComparisonResourceSnapshot)root).getDiff();
+ // }
+ // if (root != null) {
+ // // FIXME performance, find a way to cache this referencer
+ // final Resource res = root.eResource();
+ // final EcoreUtil.CrossReferencer referencer;
+ // if (res != null && res.getResourceSet() != null) {
+ // referencer = new EcoreUtil.CrossReferencer(res.getResourceSet()) {
+ // private static final long serialVersionUID = 616050158241084372L;
+ //
+ // // initializer for this anonymous class
+ // {
+ // crossReference();
+ // }
+ //
+ // @Override
+ // protected boolean crossReference(EObject eObject, EReference eReference,
+ // EObject crossReferencedEObject) {
+ // if (eReference.isChangeable() && !eReference.isDerived())
+ // return crossReferencedEObject.eResource() == null;
+ // return false;
+ // }
+ // };
+ // } else if (res != null) {
+ // referencer = new EcoreUtil.CrossReferencer(res) {
+ // private static final long serialVersionUID = 616050158241084372L;
+ //
+ // // initializer for this anonymous class
+ // {
+ // crossReference();
+ // }
+ //
+ // @Override
+ // protected boolean crossReference(EObject eObject, EReference eReference,
+ // EObject crossReferencedEObject) {
+ // if (eReference.isChangeable() && !eReference.isDerived())
+ // return crossReferencedEObject.eResource() == null;
+ // return false;
+ // }
+ // };
+ // } else {
+ // referencer = new EcoreUtil.CrossReferencer(root) {
+ // private static final long serialVersionUID = 616050158241084372L;
+ //
+ // // initializer for this anonymous class
+ // {
+ // crossReference();
+ // }
+ //
+ // @Override
+ // protected boolean crossReference(EObject eObject, EReference eReference,
+ // EObject crossReferencedEObject) {
+ // if (eReference.isChangeable() && !eReference.isDerived())
+ // return crossReferencedEObject.eResource() == null;
+ // return false;
+ // }
+ // };
+ // }
+ // final Iterator<Map.Entry<EObject, Collection<EStructuralFeature.Setting>>> i = referencer
+ // .entrySet().iterator();
+ // while (i.hasNext()) {
+ // final Map.Entry<EObject, Collection<EStructuralFeature.Setting>> entry = i.next();
+ // final Iterator<EStructuralFeature.Setting> j = entry.getValue().iterator();
+ // while (j.hasNext()) {
+ // EcoreUtil.remove(j.next(), entry.getKey());
+ // }
+ // }
+ // }
+ }
+
+ /**
+ * Removes a {@link DiffElement} from its {@link DiffGroup}.
+ *
+ * @param diffElement
+ * {@link DiffElement} to remove from its container.
+ */
+ protected void removeFromContainer(DiffElement diffElement) {
+ final EObject parent = diffElement.eContainer();
+ EcoreUtil.remove(diffElement);
+ removeDanglingReferences(parent);
+
+ // If diff was contained by a ConflictingDiffElement, we call back this on it
+ if(parent instanceof ConflictingDiffElement) {
+ removeFromContainer((DiffElement)parent);
+ }
+
+ // if diff was in a diffGroup and it was the last one, we also remove the diffgroup
+ if(parent instanceof DiffGroup) {
+ cleanDiffGroup((DiffGroup)parent);
+ }
+ }
+
+ /**
+ * Sets the XMI ID of the given {@link EObject} if it belongs in an {@link XMIResource}.
+ *
+ * @param object
+ * Object we want to set the XMI ID of.
+ * @param id
+ * XMI ID to give to <code>object</code>.
+ */
+ protected void setXMIID(EObject object, String id) {
+ if(object != null && object.eResource() instanceof XMIResource) {
+ ((XMIResource)object.eResource()).setID(object, id);
+ }
+ }
+
+ /**
+ * Merge the differences required by the current difference.
+ *
+ * @param applyInOrigin
+ * True if the merge has to apply in origin.
+ * @since 1.3
+ */
+ protected void mergeRequiredDifferences(boolean applyInOrigin) {
+ if(mergedDiffs == null) {
+ mergedDiffs = new ArrayList<DiffElement>();
+ if(mergedDiffslistener == null) {
+ mergedDiffslistener = new MergedDiffsListener();
+ MergeService.addMergeListener(mergedDiffslistener);
+ }
+ }
+ mergedDiffs.add(diff);
+
+ for(DiffElement requiredDiff : getDependencies(applyInOrigin)) {
+ if(requiredDiff.eContainer() != null && !mergedDiffs.contains(requiredDiff)) {
+ final IMerger merger = MergeFactory.createMerger(requiredDiff);
+ if(applyInOrigin) {
+ merger.applyInOrigin();
+ } else {
+ merger.undoInTarget();
+ }
+ }
+ }
+ }
+
+ /**
+ * This default merge listener will allow us to reset the {@link #mergedDiffs} list at the end of the
+ * merge operation.
+ *
+ * @author <a href="mailto:cedric.notot@obeo.fr">Cedric Notot</a>
+ */
+ private class MergedDiffsListener implements IMergeListener {
+
+ /**
+ * Default constructor.
+ */
+ public MergedDiffsListener() {
+ // Enhance visibility of the default constructor.
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergeListener#mergeDiffEnd(org.eclipse.emf.compare.diff.merge.MergeEvent)
+ */
+ public void mergeDiffEnd(MergeEvent event) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergeListener#mergeDiffStart(org.eclipse.emf.compare.diff.merge.MergeEvent)
+ */
+ public void mergeDiffStart(MergeEvent event) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergeListener#mergeOperationEnd(org.eclipse.emf.compare.diff.merge.MergeEvent)
+ */
+ public void mergeOperationEnd(MergeEvent event) {
+ resetMergedDiffs();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergeListener#mergeOperationStart(org.eclipse.emf.compare.diff.merge.MergeEvent)
+ */
+ public void mergeOperationStart(MergeEvent event) {
+ // do nothing
+ }
+ }
+
+ /**
+ * Get the dependencies of the difference {@link diff} to merge. These dependencies will be merged before
+ * itself. This method may be overridden by a specific merger to choose to exploit or not the 'requires'
+ * link of the {@link diff} according to the nature of the merger and the direction of the merge.
+ *
+ * @param applyInOrigin
+ * The direction of the merge.
+ * @return The list of the dependencies to exploit.
+ * @since 1.3
+ */
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ return new ArrayList<DiffElement>();
+ }
+
+ /**
+ * Mutually derived references need specific handling : merging one will implicitely merge the other and
+ * there are no way to tell such references apart.
+ * <p>
+ * Currently known references raising such issues :
+ * <table>
+ * <tr>
+ * <td>{@link EcorePackage#ECLASS__ESUPER_TYPES}</td>
+ * <td>{@link EcorePackage#ECLASS__EGENERIC_SUPER_TYPES}</td>
+ * </tr>
+ * </table>
+ * </p>
+ */
+ private void handleMutuallyDerivedReferences() {
+ DiffElement toRemove = null;
+ if(diff instanceof ReferenceChange) {
+ final EReference reference = ((ReferenceChange)diff).getReference();
+ if(reference == EcorePackage.eINSTANCE.getEClass_ESuperTypes()) {
+ EObject referenceType = null;
+ if(diff instanceof ReferenceChangeLeftTarget) {
+ referenceType = ((ReferenceChangeLeftTarget)diff).getRightTarget();
+ } else if(diff instanceof ReferenceChangeRightTarget) {
+ referenceType = ((ReferenceChangeRightTarget)diff).getLeftTarget();
+ } else if(diff instanceof UpdateReference) {
+ referenceType = ((UpdateReference)diff).getLeftTarget();
+ } else {
+ // we did cover all the subclasses, we should have a RferenceOrderChange
+ }
+ for(final DiffElement siblingDiff : ((DiffGroup)diff.eContainer()).getSubDiffElements()) {
+ if(siblingDiff instanceof ModelElementChangeLeftTarget) {
+ if(((ModelElementChangeLeftTarget)siblingDiff).getLeftElement() instanceof EGenericType && ((EGenericType)((ModelElementChangeLeftTarget)siblingDiff).getLeftElement()).getEClassifier() == referenceType) {
+ toRemove = siblingDiff;
+ break;
+ }
+ } else if(siblingDiff instanceof ModelElementChangeRightTarget) {
+ if(((ModelElementChangeRightTarget)siblingDiff).getRightElement() instanceof EGenericType && ((EGenericType)((ModelElementChangeRightTarget)siblingDiff).getRightElement()).getEClassifier() == referenceType) {
+ toRemove = siblingDiff;
+ break;
+ }
+ }
+ }
+ }
+ } else if(diff instanceof ModelElementChangeLeftTarget && ((ModelElementChangeLeftTarget)diff).getLeftElement() instanceof EGenericType) {
+ final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)diff;
+ final EClassifier referenceType = ((EGenericType)theDiff.getLeftElement()).getEClassifier();
+ for(final DiffElement siblingDiff : ((DiffGroup)diff.eContainer()).getSubDiffElements()) {
+ if(siblingDiff instanceof ReferenceChangeLeftTarget && ((ReferenceChangeLeftTarget)siblingDiff).getReference().getFeatureID() == EcorePackage.ECLASS__ESUPER_TYPES) {
+ if(((ReferenceChangeLeftTarget)siblingDiff).getRightTarget() == referenceType) {
+ toRemove = siblingDiff;
+ break;
+ }
+ }
+ }
+ } else if(diff instanceof ModelElementChangeRightTarget && ((ModelElementChangeRightTarget)diff).getRightElement() instanceof EGenericType) {
+ final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)diff;
+ final EClassifier referenceType = ((EGenericType)theDiff.getRightElement()).getEClassifier();
+ for(final DiffElement siblingDiff : ((DiffGroup)diff.eContainer()).getSubDiffElements()) {
+ if(siblingDiff instanceof ReferenceChangeRightTarget && ((ReferenceChangeRightTarget)siblingDiff).getReference().getFeatureID() == EcorePackage.ECLASS__ESUPER_TYPES) {
+ if(((ReferenceChangeRightTarget)siblingDiff).getLeftTarget() == referenceType) {
+ toRemove = siblingDiff;
+ break;
+ }
+ }
+ }
+ }
+ if(toRemove != null) {
+ removeFromContainer(toRemove);
+ }
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java new file mode 100644 index 00000000000..5aa5b3e36c7 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java @@ -0,0 +1,106 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeService;
+
+/**
+ *
+ * Transactional version of the class DiffGroupMerger provided by EMF Compare
+ *
+ */
+public class DiffGroupTransactionalMerger extends DefaultTransactionalMerger {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getApplyInOriginCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, Collection)
+ *
+ * @param domain
+ * @return
+ */
+ public Command getApplyInOriginCommand(final TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
+ if(somethingToMerge((DiffGroup)diff)) {
+ return TransactionalMergeService.getMergeCommand(domain, diff.getSubDiffElements(), false);
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getUndoInTargetCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, Collection)
+ *
+ * @param domain
+ * @return
+ */
+ public Command getUndoInTargetCommand(final TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
+ if(somethingToMerge((DiffGroup)diff)) {
+ return TransactionalMergeService.getMergeCommand(domain, diff.getSubDiffElements(), true); // doUndoInTarget();
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @param group
+ * @return
+ * <code>true</code> if we found DiffElement that is not a DiffGroup in the content of the DiffElement
+ */
+ protected boolean somethingToMerge(final DiffGroup group) {
+ final Iterator<EObject> iter = group.eAllContents();
+ while(iter.hasNext()) {
+ final EObject current = iter.next();
+ if(current instanceof DiffElement && !(current instanceof DiffGroup)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#canApplyInOrigin()
+ *
+ * @return
+ */
+ @Override
+ public boolean canApplyInOrigin() {
+ if(somethingToMerge(((DiffGroup)diff))) {
+ return super.canApplyInOrigin();
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#canUndoInTarget()
+ *
+ * @return
+ */
+ @Override
+ public boolean canUndoInTarget() {
+ if(somethingToMerge(((DiffGroup)diff))) {
+ return super.canUndoInTarget();
+ }
+ return false;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeLeftTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeLeftTargetTransactionalMerger.java new file mode 100644 index 00000000000..35efe3e008f --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeLeftTargetTransactionalMerger.java @@ -0,0 +1,229 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.CopyXMIIDCommand;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+
+/**
+ *
+ * Transactional version of the class {@link ModelElementChangeLeftTargetMerger}
+ *
+ */
+public class ModelElementChangeLeftTargetTransactionalMerger extends DefaultTransactionalMerger {//ModelElementChangeLeftTargetMerger implements ITransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link ModelElementChangeLeftTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // protected void doApplyInOrigin() {
+ // final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ // final EObject element = theDiff.getLeftElement();
+ // final EObject parent = theDiff.getLeftElement().eContainer();
+ // EcoreUtil.remove(element);
+ // // now removes all the dangling references
+ // removeDanglingReferences(parent);
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ModelElementChangeLeftTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // protected void doUndoInTarget() {
+ // final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ // // we should copy the element to the Origin one.
+ // final EObject origin = theDiff.getRightParent();
+ // final EObject element = theDiff.getLeftElement();
+ // final EObject newOne = copy(element);
+ // final EReference ref = element.eContainmentFeature();
+ // if(ref != null) {
+ // try {
+ // int elementIndex = -1;
+ // if(ref.isMany()) {
+ // final Object containmentRefVal = element.eContainer().eGet(ref);
+ // if(containmentRefVal instanceof List<?>) {
+ // @SuppressWarnings("unchecked")
+ // final List<EObject> listVal = (List<EObject>)containmentRefVal;
+ // elementIndex = listVal.indexOf(element);
+ // }
+ // }
+ // EFactory.eAdd(origin, ref.getName(), newOne, elementIndex, true);
+ // setXMIID(newOne, getXMIID(element));
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // } else if(origin == null && getDiffModel().getRightRoots().size() > 0) {
+ // getDiffModel().getRightRoots().get(0).eResource().getContents().add(newOne);
+ // } else if(origin != null) {
+ // origin.eResource().getContents().add(newOne);
+ // } else {
+ // // FIXME throw exception : couldn't merge this
+ // }
+ // // we should now have a look for RemovedReferencesLinks needing elements to apply
+ // final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ // while(siblings.hasNext()) {
+ // final Object op = siblings.next();
+ // if(op instanceof ReferenceChangeLeftTarget) {
+ // final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // // now if I'm in the target References I should put my copy in the origin
+ // if(link.getRightTarget() != null && link.getRightTarget() == element) {
+ // link.setLeftTarget(newOne);
+ // }
+ // } else if(op instanceof ReferenceOrderChange) {
+ // final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ // if(link.getRightElement() == origin && link.getReference() == ref) {
+ // final ListIterator<EObject> targetIterator = link.getRightTarget().listIterator();
+ // boolean replaced = false;
+ // while(!replaced && targetIterator.hasNext()) {
+ // final EObject target = targetIterator.next();
+ // if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(element))) {
+ // targetIterator.set(newOne);
+ // replaced = true;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+
+ //TODO verify that I use this method in the transactional version
+ /**
+ * The native implementation, duplicated Code from {@link ModelElementChangeLeftTargetMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ if(!applyInOrigin) {
+ return diff.getRequires();
+ }
+ return super.getDependencies(applyInOrigin);
+ }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ final EObject element = theDiff.getLeftElement();
+ return PapyrusMergeCommandProvider.INSTANCE.getDestroyCommand(domain, element);
+ //removeDanglingReferences(parent); not used
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ CompoundCommand cmd = new CompoundCommand("Command CModelElementChangeLeftTargetMerger#getDoUndoInTargetCommand"); //$NON-NLS-1$
+ final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ // we should copy the element to the Origin one.
+ final EObject origin = theDiff.getRightParent();
+ final EObject element = theDiff.getLeftElement();
+ final ICommand copyCommand = getCopyWithReferenceCommand(element);
+ cmd.append(new GMFtoEMFCommandWrapper(copyCommand));
+ final EObject newOne = (EObject)copyCommand.getCommandResult().getReturnValue();
+ final EReference ref = element.eContainmentFeature();
+ if(ref != null) {
+ try {
+ int elementIndex = -1;
+ if(ref.isMany()) {
+ final Object containmentRefVal = element.eContainer().eGet(ref);
+ if(containmentRefVal instanceof List<?>) {
+ @SuppressWarnings("unchecked")
+ final List<EObject> listVal = (List<EObject>)containmentRefVal;
+ elementIndex = listVal.indexOf(element);
+ }
+ }
+ // EFactory.eAdd(origin, ref.getName(), newOne, elementIndex, true);
+ // setXMIID(newOne, getXMIID(element));
+ cmd.append(PapyrusEFactory.getEAddCommand(domain, origin, ref.getName(), newOne, elementIndex, true));
+ cmd.append(new CopyXMIIDCommand(element, newOne));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ } else if(origin == null && getDiffModel().getRightRoots().size() > 0) {
+ // getDiffModel().getRightRoots().get(0).eResource().getContents().add(newOne);
+ cmd.append(new AddToResourceCommand(getDiffModel().getRightRoots().get(0).eResource(), newOne));
+ } else if(origin != null) {
+ // origin.eResource().getContents().add(newOne);
+ cmd.append(new AddToResourceCommand(origin.eResource(), newOne));
+ } else {
+ // FIXME throw exception : couldn't merge this
+ }
+ cmd.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // we should now have a look for RemovedReferencesLinks needing elements to apply
+ final DiffModel diffModel = getDiffModel();//see bug 385263: [UML Compare] NPE merging a DiffGroup owning a UMLStereotypeApplicationAddition/Removal
+ if(diffModel != null) {
+ final Iterator<EObject> siblings = diffModel.eAllContents();
+ while(siblings.hasNext()) {
+ final Object op = siblings.next();
+ if(op instanceof ReferenceChangeLeftTarget) {
+ final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getRightTarget() != null && link.getRightTarget() == element) {
+ link.setLeftTarget(newOne);
+ }
+ } else if(op instanceof ReferenceOrderChange) {
+ final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ if(link.getRightElement() == origin && link.getReference() == ref) {
+ final ListIterator<EObject> targetIterator = link.getRightTarget().listIterator();
+ boolean replaced = false;
+ while(!replaced && targetIterator.hasNext()) {
+ final EObject target = targetIterator.next();
+ if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(element))) {
+ targetIterator.set(newOne);
+ replaced = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }));
+
+ return cmd;
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeRightTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeRightTargetTransactionalMerger.java new file mode 100644 index 00000000000..28ecd6891ac --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ModelElementChangeRightTargetTransactionalMerger.java @@ -0,0 +1,235 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.CopyXMIIDCommand;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+/**
+ *
+ * Transactional version of the class {@link ModelElementChangeRightTargetMerger}
+ *
+ */
+
+public class ModelElementChangeRightTargetTransactionalMerger extends DefaultTransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link ModelElementChangeRightTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)this.diff;
+ // final EObject origin = theDiff.getLeftParent();
+ // final EObject element = theDiff.getRightElement();
+ // final EObject newOne = copy(element);
+ // final EReference ref = element.eContainmentFeature();
+ // if(ref != null) {
+ // try {
+ // int expectedIndex = -1;
+ // if(ref.isMany()) {
+ // final Object containmentRefVal = element.eContainer().eGet(ref);
+ // if(containmentRefVal instanceof List<?>) {
+ // @SuppressWarnings("unchecked")
+ // final List<EObject> listVal = (List<EObject>)containmentRefVal;
+ // expectedIndex = listVal.indexOf(element);
+ // }
+ // }
+ // EFactory.eAdd(origin, ref.getName(), newOne, expectedIndex, true);
+ // setXMIID(newOne, getXMIID(element));
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // } else if(origin == null && getDiffModel().getLeftRoots().size() > 0) {
+ // getDiffModel().getLeftRoots().get(0).eResource().getContents().add(newOne);
+ // } else if(origin != null) {
+ // origin.eResource().getContents().add(newOne);
+ // } else {
+ // // FIXME Throw exception : couldn't merge this
+ // }
+ // // we should now have a look for AddReferencesLinks needing this object
+ // final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ // while(siblings.hasNext()) {
+ // final DiffElement op = (DiffElement)siblings.next();
+ // if(op instanceof ReferenceChangeRightTarget) {
+ // final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // // now if I'm in the target References I should put my copy in the origin
+ // if(link.getLeftTarget() != null && link.getLeftTarget() == element) {
+ // link.setRightTarget(newOne);
+ // }
+ // } else if(op instanceof ReferenceOrderChange) {
+ // final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ // if(link.getLeftElement() == origin && link.getReference() == ref) {
+ // final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ // boolean replaced = false;
+ // while(!replaced && targetIterator.hasNext()) {
+ // final EObject target = targetIterator.next();
+ // if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(element))) {
+ // targetIterator.set(newOne);
+ // replaced = true;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ModelElementChangeRightTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)this.diff;
+ // final EObject element = theDiff.getRightElement();
+ // final EObject parent = theDiff.getRightElement().eContainer();
+ // EcoreUtil.remove(element);
+ // // now removes all the dangling references
+ // removeDanglingReferences(parent);
+ // }
+
+ /**
+ * The native implementation, duplicated Code from {@link ModelElementChangeRightTargetMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#canUndoInTarget()
+ */
+ @Override
+ public boolean canUndoInTarget() {
+ final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)this.diff;
+ final boolean isRightElementNotNull = theDiff.getRightElement() != null;
+ return isRightElementNotNull;
+ }
+
+ //TODO verify if I use this method
+ /**
+ * The native implementation, duplicated Code from {@link ModelElementChangeRightTargetMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ if(applyInOrigin) {
+ return diff.getRequires();
+ }
+ return super.getDependencies(applyInOrigin);
+ }
+
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ final CompoundCommand cmd = new CompoundCommand("Command CModelElementChangeRightTargetMerger#getDoApplyInOriginCommand"); //$NON-NLS-1$
+ final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)this.diff;
+ final EObject origin = theDiff.getLeftParent();
+ final EObject element = theDiff.getRightElement();
+ final ICommand copyCommand = getCopyWithReferenceCommand(element);
+ cmd.append(new GMFtoEMFCommandWrapper(copyCommand));
+ final EObject newOne = (EObject)copyCommand.getCommandResult().getReturnValue();
+ final EReference ref = element.eContainmentFeature();
+ if(ref != null) {
+ try {
+ int expectedIndex = -1;
+ if(ref.isMany()) {
+ final Object containmentRefVal = element.eContainer().eGet(ref);
+ if(containmentRefVal instanceof List<?>) {
+ @SuppressWarnings("unchecked")
+ final List<EObject> listVal = (List<EObject>)containmentRefVal;
+ expectedIndex = listVal.indexOf(element);
+ }
+ }
+ // EFactory.eAdd(origin, ref.getName(), newOne, expectedIndex, true);
+ // setXMIID(newOne, getXMIID(element));
+ cmd.append(PapyrusEFactory.getEAddCommand(domain, origin, ref.getName(), newOne, expectedIndex, true));
+ cmd.append(new CopyXMIIDCommand(element, newOne));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ } else if(origin == null && getDiffModel().getLeftRoots().size() > 0) {
+ cmd.append(new AddToResourceCommand(getDiffModel().getLeftRoots().get(0).eResource(), newOne));
+ } else if(origin != null) {
+ cmd.append(new AddToResourceCommand(origin.eResource(), newOne));
+ } else {
+ // FIXME Throw exception : couldn't merge this
+ }
+ cmd.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // we should now have a look for AddReferencesLinks needing this object
+ final DiffModel diffModel = getDiffModel();////see bug 385263: [UML Compare] NPE merging a DiffGroup owning a UMLStereotypeApplicationAddition/Removal
+ if(diffModel != null) {
+ final Iterator<EObject> siblings = diffModel.eAllContents();
+ while(siblings.hasNext()) {
+ final DiffElement op = (DiffElement)siblings.next();
+ if(op instanceof ReferenceChangeRightTarget) {
+ final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getLeftTarget() != null && link.getLeftTarget() == element) {
+ link.setRightTarget(newOne);
+ }
+ } else if(op instanceof ReferenceOrderChange) {
+ final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ if(link.getLeftElement() == origin && link.getReference() == ref) {
+ final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ boolean replaced = false;
+ while(!replaced && targetIterator.hasNext()) {
+ final EObject target = targetIterator.next();
+ if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(element))) {
+ targetIterator.set(newOne);
+ replaced = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }));
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ final ModelElementChangeRightTarget theDiff = (ModelElementChangeRightTarget)this.diff;
+ final EObject element = theDiff.getRightElement();
+ return PapyrusMergeCommandProvider.INSTANCE.getDestroyCommand(domain, element);
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/MoveModelElementTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/MoveModelElementTransactionalMerger.java new file mode 100644 index 00000000000..2d40055f550 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/MoveModelElementTransactionalMerger.java @@ -0,0 +1,226 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+
+/**
+ *
+ * Transactional version of the class {@link MoveModelElementMerger}
+ *
+ */
+public class MoveModelElementTransactionalMerger extends DefaultTransactionalMerger {//MoveModelElementMerger implements ITransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link MoveModelElementMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @SuppressWarnings("unchecked")
+ // @Override
+ // public void doApplyInOrigin() {
+ // final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ // final EObject leftTarget = theDiff.getLeftTarget();
+ // final EObject leftElement = theDiff.getLeftElement();
+ // final EReference ref = theDiff.getRightElement().eContainmentFeature();
+ // if(ref != null) {
+ // // ordering handling:
+ // int index = -1;
+ // final EObject rightElementParent = theDiff.getRightElement().eContainer();
+ // final Object rightRefValue = rightElementParent.eGet(ref);
+ // if(rightRefValue instanceof List) {
+ // final List<Object> refRightValueList = (List<Object>)rightRefValue;
+ // index = refRightValueList.indexOf(theDiff.getRightElement());
+ // }
+ //
+ // try {
+ // // We'll store the element's ID because moving an element deletes its XMI ID
+ // final String elementID = getXMIID(leftElement);
+ // EcoreUtil.remove(leftElement);
+ // EFactory.eAdd(leftTarget, ref.getName(), leftElement, index, true);
+ // // Sets anew the element's ID
+ // setXMIID(leftElement, elementID);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // } else {
+ // // shouldn't be here
+ // assert false;
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link MoveModelElementMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @SuppressWarnings("unchecked")
+ // @Override
+ // public void doUndoInTarget() {
+ // final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ // final EObject rightTarget = theDiff.getRightTarget();
+ // final EObject rightElement = theDiff.getRightElement();
+ // final EReference ref = theDiff.getLeftElement().eContainmentFeature();
+ // if(ref != null) {
+ // // ordering handling:
+ // int index = -1;
+ // final EObject leftElementParent = theDiff.getLeftElement().eContainer();
+ // final Object leftRefValue = leftElementParent.eGet(ref);
+ // if(leftRefValue instanceof List) {
+ // final List<Object> refLeftValueList = (List<Object>)leftRefValue;
+ // index = refLeftValueList.indexOf(theDiff.getLeftElement());
+ // }
+ //
+ // try {
+ // final String elementID = getXMIID(rightElement);
+ // EcoreUtil.remove(rightElement);
+ // EFactory.eAdd(rightTarget, ref.getName(), rightElement, index, true);
+ // setXMIID(rightElement, elementID);
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // } else {
+ // // shouldn't be here
+ // assert false;
+ // }
+ // }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ final CompoundCommand cmd = new CompoundCommand("CMoveModelElementMerger#getDoApplyInOriginCommand"); //$NON-NLS-1$
+ final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ final EObject leftTarget = theDiff.getLeftTarget();
+ final EObject leftElement = theDiff.getLeftElement();
+ final EReference ref = theDiff.getRightElement().eContainmentFeature();
+ if(ref != null) {
+ // ordering handling:
+ int index = -1;
+ final EObject rightElementParent = theDiff.getRightElement().eContainer();
+ final Object rightRefValue = rightElementParent.eGet(ref);
+ if(rightRefValue instanceof List) {
+ final List<Object> refRightValueList = (List<Object>)rightRefValue;
+ index = refRightValueList.indexOf(theDiff.getRightElement());
+ }
+
+
+ // We'll store the element's ID because moving an element deletes its XMI ID
+ final String elementID = getXMIID(leftElement);
+
+ if(rightRefValue instanceof List<?>) {
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveWithIndexCommand(domain, leftTarget, leftTarget, ref, leftElement, index, true));
+ } else {
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveCommand(domain, leftTarget, leftTarget, ref, leftElement));
+ }
+ cmd.append(getPreserveXMIIDCommand(domain, leftElement, elementID));
+
+ } else {
+ // shouldn't be here
+ cmd.append(UnexecutableCommand.INSTANCE);
+ }
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ final CompoundCommand cmd = new CompoundCommand("CMoveModelElementMerger#getDoUndoInTargetCommand"); //$NON-NLS-1$
+ final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ final EObject rightTarget = theDiff.getRightTarget();
+ final EObject rightElement = theDiff.getRightElement();
+ final EReference ref = theDiff.getLeftElement().eContainmentFeature();
+ if(ref != null) {
+ // ordering handling:
+ int index = -1;
+ final EObject leftElementParent = theDiff.getLeftElement().eContainer();
+ final Object leftRefValue = leftElementParent.eGet(ref);
+ if(leftRefValue instanceof List) {
+ final List<Object> refLeftValueList = (List<Object>)leftRefValue;
+ index = refLeftValueList.indexOf(theDiff.getLeftElement());
+ }
+ if(leftRefValue instanceof List<?>) {
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveWithIndexCommand(domain, rightTarget, rightTarget, ref, rightElement, index, true));
+ } else {
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveCommand(domain, rightTarget, rightTarget, ref, rightElement));
+ }
+ final String elementID = getXMIID(rightElement);
+ cmd.append(getPreserveXMIIDCommand(domain, rightElement, elementID));
+ } else {
+ // shouldn't be here
+ cmd.append(UnexecutableCommand.INSTANCE);
+ }
+ return cmd;
+ }
+
+
+ // public Command getMergeRequiredDifferencesCommand(final TransactionalEditingDomain domain, final boolean applyInOrigin) {
+ // // TODO the super method mergeRequiredDifferences should be rewritten to use cmd too
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // MoveModelElementTransactionalMerger.this.mergeRequiredDifferences(applyInOrigin);
+ // return null;
+ // }
+ // });
+ // }
+ //
+ // public Command getPostProcessCommand(final TransactionalEditingDomain domain) {
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // MoveModelElementTransactionalMerger.this.postProcess();
+ // return null;
+ // }
+ // });
+ // }
+
+ /**
+ * This command is not the the class PapyrusUMLMergeProvider because it only should be used to preserve the xmi_id after a move,
+ * but not to change the id
+ *
+ * @param domain
+ * @param element
+ * @param id
+ * @return
+ * the command to set the ID
+ */
+ private Command getPreserveXMIIDCommand(final TransactionalEditingDomain domain, final EObject element, final String id) {
+ //TODO change for an EMFCommand
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Set XMI Command", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ if(element != null && element.eResource() instanceof XMIResource) {
+ ((XMIResource)element.eResource()).setID(element, id);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ });
+
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeLeftTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeLeftTargetTransactionalMerger.java new file mode 100644 index 00000000000..c5c6b27e414 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeLeftTargetTransactionalMerger.java @@ -0,0 +1,274 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDependencyChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusCompareEObjectCopier;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeService;
+
+/**
+ *
+ * Transactional version of the class {@link ReferenceChangeLeftTargetMerger}
+ *
+ */
+public class ReferenceChangeLeftTargetTransactionalMerger extends DefaultTransactionalMerger {//ReferenceChangeLeftTargetMerger implements ITransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceChangeLeftTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final ReferenceChangeLeftTarget theDiff = (ReferenceChangeLeftTarget)this.diff;
+ // final EObject element = theDiff.getLeftElement();
+ // final EObject leftTarget = theDiff.getLeftTarget();
+ // try {
+ // EFactory.eRemove(element, theDiff.getReference().getName(), leftTarget);
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // // we should now have a look for AddReferencesLinks needing this object
+ // final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ // while(siblings.hasNext()) {
+ // final DiffElement op = (DiffElement)siblings.next();
+ // if(op instanceof ReferenceChangeLeftTarget) {
+ // final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // // now if I'm in the target References I should put my copy in the origin
+ // if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getLeftTarget().equals(element)) {
+ // removeFromContainer(link);
+ // }
+ // } else if(op instanceof ResourceDependencyChange) {
+ // final ResourceDependencyChange link = (ResourceDependencyChange)op;
+ // final Resource res = link.getRoots().get(0).eResource();
+ // if(res == leftTarget.eResource()) {
+ // EcoreUtil.remove(link);
+ // res.unload();
+ // }
+ // }
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceChangeLeftTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final ReferenceChangeLeftTarget theDiff = (ReferenceChangeLeftTarget)this.diff;
+ // final EReference reference = theDiff.getReference();
+ // final EObject element = theDiff.getRightElement();
+ // final EObject leftTarget = theDiff.getLeftTarget();
+ // final EObject rightTarget = theDiff.getRightTarget();
+ //
+ // int index = -1;
+ // if(reference.isMany()) {
+ // final EObject leftElement = theDiff.getLeftElement();
+ // final Object leftRefValue = leftElement.eGet(reference);
+ // if(leftRefValue instanceof List) {
+ // final List refLeftValueList = (List)leftRefValue;
+ // index = refLeftValueList.indexOf(leftTarget);
+ // }
+ // }
+ // final EObject copiedValue = MergeService.getCopier(diff).copyReferenceValue(reference, element, leftTarget, rightTarget, index);
+ //
+ // // we should now have a look for AddReferencesLinks needing this object
+ // final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ // while(siblings.hasNext()) {
+ // final DiffElement op = (DiffElement)siblings.next();
+ // if(op instanceof ReferenceChangeLeftTarget) {
+ // final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // // now if I'm in the target References I should put my copy in the origin
+ // if(link.getReference().equals(reference.getEOpposite()) && link.getLeftTarget().equals(element)) {
+ // removeFromContainer(link);
+ // }
+ // } else if(op instanceof ReferenceOrderChange) {
+ // final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ // if(link.getLeftElement() == element && link.getReference() == reference) {
+ // final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ // boolean replaced = false;
+ // while(!replaced && targetIterator.hasNext()) {
+ // final EObject target = targetIterator.next();
+ // if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(leftTarget))) {
+ // targetIterator.set(copiedValue);
+ // replaced = true;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+
+ //TODO : verify if I use this method
+ /**
+ * The native implementation, duplicated Code from {@link ReferenceChangeLeftTargetMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ if(!applyInOrigin) {
+ return diff.getRequires();
+ }
+ return super.getDependencies(applyInOrigin);
+ }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ final CompoundCommand cmd = new CompoundCommand("CReferenceChangeLeftTargetMerger#getDoApplyInOriginCommand"); //$NON-NLS-1$
+ final ReferenceChangeLeftTarget theDiff = (ReferenceChangeLeftTarget)this.diff;
+ final EObject element = theDiff.getLeftElement();
+ final EObject leftTarget = theDiff.getLeftTarget();
+ try {
+ cmd.append(PapyrusEFactory.getERemoveCommand(domain, element, theDiff.getReference().getName(), leftTarget));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ cmd.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final DiffModel diffModel = getDiffModel();
+ if(diffModel != null) {//383515: [UML Compare] NPE with ReferenceChangeRightTarget leftToRight and ReferenceChangeLeftTarget rightToLeft
+ // we should now have a look for AddReferencesLinks needing this object
+ final Iterator<EObject> siblings = diffModel.eAllContents();
+ while(siblings.hasNext()) {
+ final DiffElement op = (DiffElement)siblings.next();
+ if(op instanceof ReferenceChangeLeftTarget) {
+ final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getLeftTarget().equals(element)) {
+ removeFromContainer(link);
+ }
+ } else if(op instanceof ResourceDependencyChange) {
+ final ResourceDependencyChange link = (ResourceDependencyChange)op;
+ final Resource res = link.getRoots().get(0).eResource();
+ if(res == leftTarget.eResource()) {
+ EcoreUtil.remove(link);
+ res.unload();
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }));
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ final CompoundCommand cmd = new CompoundCommand();
+ final ReferenceChangeLeftTarget theDiff = (ReferenceChangeLeftTarget)this.diff;
+ final EReference reference = theDiff.getReference();
+ final EObject element = theDiff.getRightElement();
+ final EObject leftTarget = theDiff.getLeftTarget();
+ final EObject rightTarget = theDiff.getRightTarget();
+
+ int index = -1;
+ if(reference.isMany()) {
+ final EObject leftElement = theDiff.getLeftElement();
+ final Object leftRefValue = leftElement.eGet(reference);
+ if(leftRefValue instanceof List) {
+ final List<?> refLeftValueList = (List<?>)leftRefValue;
+ index = refLeftValueList.indexOf(leftTarget);
+ }
+ }
+ final PapyrusCompareEObjectCopier copier = (PapyrusCompareEObjectCopier)TransactionalMergeService.getCopier(diff);
+ Command copierCommand = copier.getCopyReferenceValueCommand(domain, reference, element, leftTarget, rightTarget, index);
+ cmd.append(copierCommand);
+ final AbstractTransactionalCommand updateDiffModelCommand = new AbstractTransactionalCommand(domain, "Update Diff Model", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final EObject copiedValue = copier.getCopiedValue(leftTarget);
+ final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ while(siblings.hasNext()) {
+ final DiffElement op = (DiffElement)siblings.next();
+ if(op instanceof ReferenceChangeLeftTarget) {
+ final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getReference().equals(reference.getEOpposite()) && link.getLeftTarget().equals(element)) {
+ removeFromContainer(link);
+ }
+ } else if(op instanceof ReferenceOrderChange) {
+ final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ if(link.getLeftElement() == element && link.getReference() == reference) {
+ final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ boolean replaced = false;
+ while(!replaced && targetIterator.hasNext()) {
+ final EObject target = targetIterator.next();
+ if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(leftTarget))) {
+ targetIterator.set(copiedValue);
+ replaced = true;
+ }
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ cmd.append(new GMFtoEMFCommandWrapper(updateDiffModelCommand));
+ return cmd;
+ }
+
+ // public Command getMergeRequiredDifferencesCommand(final TransactionalEditingDomain domain, final boolean applyInOrigin) {
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // ReferenceChangeLeftTargetTransactionalMerger.this.mergeRequiredDifferences(applyInOrigin);
+ // return null;
+ // }
+ // });
+ // }
+ //
+ // public Command getPostProcessCommand(final TransactionalEditingDomain domain) {
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // ReferenceChangeLeftTargetTransactionalMerger.this.postProcess();
+ // return null;
+ // }
+ // });
+ // }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeRightTargetTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeRightTargetTransactionalMerger.java new file mode 100644 index 00000000000..e50c2c80806 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceChangeRightTargetTransactionalMerger.java @@ -0,0 +1,277 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDependencyChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusCompareEObjectCopier;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeService;
+
+/**
+ *
+ * Transactional version of the class {@link ReferenceChangeRightTargetMerger}
+ *
+ */
+public class ReferenceChangeRightTargetTransactionalMerger extends DefaultTransactionalMerger {//ReferenceChangeRightTargetMerger implements ITransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceChangeRightTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final ReferenceChangeRightTarget theDiff = (ReferenceChangeRightTarget)this.diff;
+ // final EReference reference = theDiff.getReference();
+ // final EObject element = theDiff.getLeftElement();
+ // final EObject rightTarget = theDiff.getRightTarget();
+ // final EObject leftTarget = theDiff.getLeftTarget();
+ //
+ // // ordering handling:
+ // int index = -1;
+ // if(reference.isMany()) {
+ // final EObject rightElement = theDiff.getRightElement();
+ // final Object rightRefValue = rightElement.eGet(reference);
+ // if(rightRefValue instanceof List) {
+ // final List refRightValueList = (List)rightRefValue;
+ // index = refRightValueList.indexOf(rightTarget);
+ // }
+ // }
+ // final EObject copiedValue = MergeService.getCopier(diff).copyReferenceValue(reference, element, rightTarget, leftTarget, index);
+ //
+ // // We'll now look through this reference's eOpposite as they are already taken care of
+ // final Iterator<EObject> related = getDiffModel().eAllContents();
+ // while(related.hasNext()) {
+ // final DiffElement op = (DiffElement)related.next();
+ // if(op instanceof ReferenceChangeRightTarget) {
+ // final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // // If this is my eOpposite, delete it from the DiffModel (merged along with this one)
+ // if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getRightTarget().equals(element)) {
+ // removeFromContainer(link);
+ // }
+ // } else if(op instanceof ReferenceOrderChange) {
+ // final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ // if(link.getLeftElement() == element && link.getReference() == reference) {
+ // final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ // boolean replaced = false;
+ // while(!replaced && targetIterator.hasNext()) {
+ // final EObject target = targetIterator.next();
+ // if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(rightTarget))) {
+ // targetIterator.set(copiedValue);
+ // replaced = true;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceChangeRightTargetMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final ReferenceChangeRightTarget theDiff = (ReferenceChangeRightTarget)this.diff;
+ // final EObject element = theDiff.getRightElement();
+ // final EObject rightTarget = theDiff.getRightTarget();
+ // try {
+ // EFactory.eRemove(element, theDiff.getReference().getName(), rightTarget);
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // // we should now have a look for AddReferencesLinks needing this object
+ // final Iterator<EObject> related = getDiffModel().eAllContents();
+ // while(related.hasNext()) {
+ // final DiffElement op = (DiffElement)related.next();
+ // if(op instanceof ReferenceChangeRightTarget) {
+ // final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // // now if I'm in the target References I should put my copy in the origin
+ // if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getRightTarget().equals(element)) {
+ // removeFromContainer(link);
+ // }
+ // } else if(op instanceof ResourceDependencyChange) {
+ // final ResourceDependencyChange link = (ResourceDependencyChange)op;
+ // final Resource res = link.getRoots().get(0).eResource();
+ // if(res == rightTarget.eResource()) {
+ // EcoreUtil.remove(link);
+ // res.unload();
+ // }
+ // }
+ // }
+ // }
+
+ //TODO : verify that I use this method
+ /**
+ * The native implementation, duplicated Code from {@link ReferenceChangeRightTargetMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ if(applyInOrigin) {
+ return diff.getRequires();
+ }
+ return super.getDependencies(applyInOrigin);
+ }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ CompoundCommand cmd = new CompoundCommand("Undo In Target Command for CReferenceChangeRightTargetMerger#getDoApplyInOriginCommand"); //$NON-NLS-1$
+ final ReferenceChangeRightTarget theDiff = (ReferenceChangeRightTarget)this.diff;
+ final EReference reference = theDiff.getReference();
+ final EObject element = theDiff.getLeftElement();
+ final EObject rightTarget = theDiff.getRightTarget();
+ final EObject leftTarget = theDiff.getLeftTarget();
+
+ // ordering handling:
+ int index = -1;
+ if(reference.isMany()) {
+ final EObject rightElement = theDiff.getRightElement();
+ final Object rightRefValue = rightElement.eGet(reference);
+ if(rightRefValue instanceof List) {
+ final List<?> refRightValueList = (List<?>)rightRefValue;
+ index = refRightValueList.indexOf(rightTarget);
+ }
+ }
+ final PapyrusCompareEObjectCopier copier = (PapyrusCompareEObjectCopier)TransactionalMergeService.getCopier(diff);
+ cmd.append(copier.getCopyReferenceValueCommand(domain, reference, element, rightTarget, leftTarget, index));
+
+ cmd.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final EObject copiedValue = copier.getCopiedValue(rightTarget);
+ // We'll now look through this reference's eOpposite as they are already taken care of
+ final Iterator<EObject> related = getDiffModel().eAllContents();
+ while(related.hasNext()) {
+ final DiffElement op = (DiffElement)related.next();
+ if(op instanceof ReferenceChangeRightTarget) {
+ final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // If this is my eOpposite, delete it from the DiffModel (merged along with this one)
+ if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getRightTarget().equals(element)) {
+ removeFromContainer(link);
+ }
+ } else if(op instanceof ReferenceOrderChange) {
+ final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ if(link.getLeftElement() == element && link.getReference() == reference) {
+ final ListIterator<EObject> targetIterator = link.getLeftTarget().listIterator();
+ boolean replaced = false;
+ while(!replaced && targetIterator.hasNext()) {
+ final EObject target = targetIterator.next();
+ if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(rightTarget))) {
+ targetIterator.set(copiedValue);
+ replaced = true;
+ }
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }));
+
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ CompoundCommand cmd = new CompoundCommand("Undo In Target Command for CReferenceChangeRightTargetMerger#getDoUndoInTargetCommand"); //$NON-NLS-1$
+ final ReferenceChangeRightTarget theDiff = (ReferenceChangeRightTarget)this.diff;
+ final EObject element = theDiff.getRightElement();
+ final EObject rightTarget = theDiff.getRightTarget();
+ try {
+ cmd.append(PapyrusEFactory.getERemoveCommand(domain, element, theDiff.getReference().getName(), rightTarget));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ cmd.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final DiffModel diffModel = getDiffModel();
+ if(diffModel != null) {//383515: [UML Compare] NPE with ReferenceChangeRightTarget leftToRight and ReferenceChangeLeftTarget rightToLeft
+ // we should now have a look for AddReferencesLinks needing this object
+ final Iterator<EObject> related = diffModel.eAllContents();
+ while(related.hasNext()) {
+ final DiffElement op = (DiffElement)related.next();
+ if(op instanceof ReferenceChangeRightTarget) {
+ final ReferenceChangeRightTarget link = (ReferenceChangeRightTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getReference().equals(theDiff.getReference().getEOpposite()) && link.getRightTarget().equals(element)) {
+ removeFromContainer(link);
+ }
+ } else if(op instanceof ResourceDependencyChange) {
+ final ResourceDependencyChange link = (ResourceDependencyChange)op;
+ final Resource res = link.getRoots().get(0).eResource();
+ if(res == rightTarget.eResource()) {
+ EcoreUtil.remove(link);
+ res.unload();
+ }
+ }
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }));
+
+ return cmd;
+ }
+
+ // public Command getMergeRequiredDifferencesCommand(final TransactionalEditingDomain domain, final boolean applyInOrigin) {
+ // // TODO the super method mergeRequiredDifferences should be rewritten to use cmd too
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // ReferenceChangeRightTargetTransactionalMerger.this.mergeRequiredDifferences(applyInOrigin);
+ // return null;
+ // }
+ // });
+ // }
+ //
+ // public Command getPostProcessCommand(final TransactionalEditingDomain domain) {
+ // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Merge Required Differences", null) { //$NON-NLS-1$
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ // ReferenceChangeRightTargetTransactionalMerger.this.postProcess();
+ // return null;
+ // }
+ // });
+ // }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceOrderChangeTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceOrderChangeTransactionalMerger.java new file mode 100644 index 00000000000..3c849443364 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/ReferenceOrderChangeTransactionalMerger.java @@ -0,0 +1,128 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.merge.DefaultMerger;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+
+/**
+ *
+ * Transactional version of the class {@link ReferenceOrderChangeMerger}
+ *
+ */
+public class ReferenceOrderChangeTransactionalMerger extends DefaultTransactionalMerger {
+
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceOrderChangeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ // final EObject leftElement = theDiff.getLeftElement();
+ //
+ // final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getLeftTarget(), new Predicate<EObject>() {
+ //
+ // public boolean apply(EObject input) {
+ // return !input.eIsProxy() || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ // }
+ // }));
+ //
+ // try {
+ // EFactory.eSet(leftElement, theDiff.getReference().getName(), target);
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link ReferenceOrderChangeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ // final EObject rightElement = theDiff.getRightElement();
+ //
+ // final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getRightTarget(), new Predicate<EObject>() {
+ //
+ // public boolean apply(EObject input) {
+ // return !input.eIsProxy() || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ // }
+ // }));
+ //
+ // try {
+ // EFactory.eSet(rightElement, theDiff.getReference().getName(), target);
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ final EObject leftElement = theDiff.getLeftElement();
+
+ final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getLeftTarget(), new Predicate<EObject>() {
+
+ public boolean apply(final EObject input) {
+ return !input.eIsProxy() || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ }
+ }));
+
+ try {
+ cmd = PapyrusEFactory.getESetCommand(domain, leftElement, theDiff.getReference().getName(), target);
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ final EObject rightElement = theDiff.getRightElement();
+
+ final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getRightTarget(), new Predicate<EObject>() {
+
+ public boolean apply(final EObject input) {
+ return !input.eIsProxy() || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ }
+ }));
+
+ try {
+ cmd = PapyrusEFactory.getESetCommand(domain, rightElement, theDiff.getReference().getName(), target);
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateAttributeTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateAttributeTransactionalMerger.java new file mode 100644 index 00000000000..d623cf73d40 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateAttributeTransactionalMerger.java @@ -0,0 +1,101 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
+import org.eclipse.emf.compare.util.EFactory;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusEFactory;
+
+/**
+ *
+ * Transactional version of the class {@link UpdateAttributeMerger}
+ *
+ */
+public class UpdateAttributeTransactionalMerger extends DefaultTransactionalMerger {//UpdateAttributeMerger implements ITransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link UpdateAttributeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ // final EObject element = theDiff.getRightElement();
+ // final EObject origin = theDiff.getLeftElement();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // EFactory.eSet(origin, attr.getName(), EFactory.eGet(element, attr.getName()));
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link UpdateAttributeMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ // final EObject element = theDiff.getRightElement();
+ // final EObject origin = theDiff.getLeftElement();
+ // final EAttribute attr = theDiff.getAttribute();
+ // try {
+ // EFactory.eSet(element, attr.getName(), EFactory.eGet(origin, attr.getName()));
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ // }
+
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ final EObject element = theDiff.getRightElement();
+ final EObject origin = theDiff.getLeftElement();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ cmd = PapyrusEFactory.getESetCommand(domain, origin, attr.getName(), EFactory.eGet(element, attr.getName()));
+ } catch (FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ final EObject element = theDiff.getRightElement();
+ final EObject origin = theDiff.getLeftElement();
+ final EAttribute attr = theDiff.getAttribute();
+ try {
+ cmd = PapyrusEFactory.getESetCommand(domain, element, attr.getName(), EFactory.eGet(origin, attr.getName()));
+ } catch (FactoryException e) {
+ Activator.log.error(e);
+ }
+ return cmd;
+ }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateReferenceTransactionalMerger.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateReferenceTransactionalMerger.java new file mode 100644 index 00000000000..4b211ec345a --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/UpdateReferenceTransactionalMerger.java @@ -0,0 +1,164 @@ +/*****************************************************************************
+ * 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.diff.internal.merger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusCompareEObjectCopier;
+import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeService;
+
+/**
+ *
+ * Transactional version of the class {@link UpdateReferenceMerger}
+ *
+ */
+public class UpdateReferenceTransactionalMerger extends DefaultTransactionalMerger {
+
+ // /**
+ // * The native implementation, duplicated Code from {@link UpdateReferenceMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ // */
+ // @Override
+ // public void doApplyInOrigin() {
+ // final UpdateReference theDiff = (UpdateReference)this.diff;
+ // final EReference reference = theDiff.getReference();
+ // final EObject element = theDiff.getLeftElement();
+ // final EObject leftTarget = (EObject)theDiff.getRightElement().eGet(reference);
+ // final EObject matchedLeftTarget = theDiff.getLeftTarget();
+ //
+ // if(leftTarget == null) {
+ // // We're unsetting the value, no need to copy
+ // element.eUnset(reference);
+ // } else {
+ // MergeService.getCopier(diff).copyReferenceValue(reference, element, leftTarget, matchedLeftTarget, -1);
+ // }
+ // }
+ //
+ // /**
+ // * The native implementation, duplicated Code from {@link UpdateReferenceMerger} {@inheritDoc}
+ // *
+ // * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ // */
+ // @Override
+ // public void doUndoInTarget() {
+ // final UpdateReference theDiff = (UpdateReference)this.diff;
+ // final EReference reference = theDiff.getReference();
+ // final EObject element = theDiff.getRightElement();
+ // final EObject rightTarget = (EObject)theDiff.getLeftElement().eGet(reference);
+ // final EObject matchedRightTarget = theDiff.getRightTarget();
+ //
+ // if(rightTarget == null) {
+ // // We're unsetting the value, no need to copy
+ // element.eUnset(reference);
+ // } else {
+ // MergeService.getCopier(diff).copyReferenceValue(reference, element, rightTarget, matchedRightTarget, -1);
+ // }
+ // }
+
+ //TODO verify if I use this method
+ /**
+ * The native implementation, duplicated Code from {@link UpdateReferenceMerger} {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#getDependencies(boolean)
+ */
+ @Override
+ protected List<DiffElement> getDependencies(boolean applyInOrigin) {
+ final List<DiffElement> diffs = diff.getRequires();
+ final List<DiffElement> result = new ArrayList<DiffElement>();
+ for(DiffElement diffElement : diffs) {
+ if(applyInOrigin && diffElement instanceof ModelElementChangeRightTarget) {
+ result.add(diffElement);
+ } else if(!applyInOrigin && diffElement instanceof ModelElementChangeLeftTarget) {
+ result.add(diffElement);
+ }
+ }
+ return result;
+ }
+
+ public Command getDoApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final UpdateReference theDiff = (UpdateReference)this.diff;
+ final EReference reference = theDiff.getReference();
+ final EObject element = theDiff.getLeftElement();
+ final EObject leftTarget = (EObject)theDiff.getRightElement().eGet(reference);
+ final EObject matchedLeftTarget = theDiff.getLeftTarget();
+
+ if(leftTarget == null) {
+ if(FeatureMapUtil.isMany(element, reference)) {
+ //TODO : I didn't find an example to test this case.
+ throw new UnsupportedOperationException("Not Yet Supported"); //$NON-NLS-1$
+ } else {
+ final Object value = theDiff.getLeftElement().eGet(reference);
+ if(value instanceof EObject) {
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getDestroyReferenceCommand(domain, element, reference, (EObject)value, false);
+ } else {
+ //TODO : we don't use the ServiceEdit
+ //TODO : not tested
+ // element.eUnset(reference);
+ cmd = new SetCommand(domain, element, reference, null);
+ }
+ }
+ } else {
+ final PapyrusCompareEObjectCopier copier = (PapyrusCompareEObjectCopier)TransactionalMergeService.getCopier(diff);
+ cmd = copier.getCopyReferenceValueCommand(domain, reference, element, leftTarget, matchedLeftTarget, -1);
+ }
+ return cmd;
+ }
+
+
+ public Command getDoUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ Command cmd = null;
+ final UpdateReference theDiff = (UpdateReference)this.diff;
+ final EReference reference = theDiff.getReference();
+ final EObject element = theDiff.getRightElement();
+ final EObject rightTarget = (EObject)theDiff.getLeftElement().eGet(reference);
+ final EObject matchedRightTarget = theDiff.getRightTarget();
+
+ if(rightTarget == null) {
+ if(FeatureMapUtil.isMany(element, reference)) {
+ //TODO : I didn't find an example to test this case.
+ throw new UnsupportedOperationException("Not Yet Supported"); //$NON-NLS-1$
+ } else {
+ final Object value = theDiff.getRightElement().eGet(reference);
+ if(value instanceof EObject) {
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getDestroyReferenceCommand(domain, element, reference, (EObject)value, false);
+ } else {
+ //TODO : we don't use the ServiceEdit
+ //TODO : not tested
+ // element.eUnset(reference);
+ cmd = new SetCommand(domain, element, reference, null);
+ }
+ }
+ } else {
+ final PapyrusCompareEObjectCopier copier = (PapyrusCompareEObjectCopier)TransactionalMergeService.getCopier(diff);
+ cmd = copier.getCopyReferenceValueCommand(domain, reference, element, rightTarget, matchedRightTarget, -1);
+ }
+ return cmd;
+ }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/provider/DefaultTransactionalMergerProvider.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/provider/DefaultTransactionalMergerProvider.java new file mode 100644 index 00000000000..ee95e68275b --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/provider/DefaultTransactionalMergerProvider.java @@ -0,0 +1,83 @@ +/*****************************************************************************
+ * 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.diff.internal.provider;
+
+import java.util.Map;
+
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
+import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.AttributeChangeLeftTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.AttributeChangeRightTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.AttributeOrderChangeTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DiffGroupTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.ModelElementChangeLeftTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.ModelElementChangeRightTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.MoveModelElementTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.ReferenceChangeLeftTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.ReferenceChangeRightTargetTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.ReferenceOrderChangeTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.UpdateAttributeTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.UpdateReferenceTransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.util.PapyrusCompareMap;
+import org.eclipse.papyrus.infra.emf.compare.diff.merge.ITransactionalMerger;
+import org.eclipse.papyrus.infra.emf.compare.diff.provider.ITransactionalMergerProvider;
+
+
+public class DefaultTransactionalMergerProvider implements ITransactionalMergerProvider {
+
+ /**
+ * This map keeps a bridge between a given {@link DiffElement}'s class and the most accurate merger's
+ * class for that particular {@link DiffElement}.
+ */
+ private Map<Class<? extends DiffElement>, Class<? extends ITransactionalMerger>> mergerTypes;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergerProvider#getMergers()
+ */
+ public Map<Class<? extends DiffElement>, Class<? extends ITransactionalMerger>> getMergers() {
+ if(mergerTypes == null) {
+ mergerTypes = new PapyrusCompareMap<Class<? extends DiffElement>, Class<? extends ITransactionalMerger>>();
+ mergerTypes.put(DiffGroup.class, DiffGroupTransactionalMerger.class);
+ mergerTypes.put(ModelElementChangeRightTarget.class, ModelElementChangeRightTargetTransactionalMerger.class);
+ mergerTypes.put(ModelElementChangeLeftTarget.class, ModelElementChangeLeftTargetTransactionalMerger.class);
+ mergerTypes.put(MoveModelElement.class, MoveModelElementTransactionalMerger.class);
+ mergerTypes.put(ReferenceChangeRightTarget.class, ReferenceChangeRightTargetTransactionalMerger.class);
+ mergerTypes.put(ReferenceChangeLeftTarget.class, ReferenceChangeLeftTargetTransactionalMerger.class);
+ mergerTypes.put(UpdateReference.class, UpdateReferenceTransactionalMerger.class);
+ mergerTypes.put(AttributeChangeRightTarget.class, AttributeChangeRightTargetTransactionalMerger.class);
+ mergerTypes.put(AttributeChangeLeftTarget.class, AttributeChangeLeftTargetTransactionalMerger.class);
+ mergerTypes.put(UpdateAttribute.class, UpdateAttributeTransactionalMerger.class);
+ mergerTypes.put(ReferenceOrderChange.class, ReferenceOrderChangeTransactionalMerger.class);
+ mergerTypes.put(AttributeOrderChange.class, AttributeOrderChangeTransactionalMerger.class);
+ //TODO DiffExtensionMerger : not used for the moment
+ //TODO DefaultExtensionMerger : not used for the moment
+ }
+ return mergerTypes;
+ }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/CopyWithReferenceCommand.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/CopyWithReferenceCommand.java new file mode 100644 index 00000000000..7a7114408fd --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/CopyWithReferenceCommand.java @@ -0,0 +1,72 @@ +/*****************************************************************************
+ * 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.diff.internal.util;
+
+import java.util.Collections;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.compare.diff.merge.EMFCompareEObjectCopier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+
+/**
+ *
+ * This command allows to copy an EObject getting the copy before the command execution. (copyCommand.getCommandResult().getReturnValue();)
+ * The references and the XMI_Dis are copied during the command excetion
+ *
+ */
+public class CopyWithReferenceCommand extends AbstractTransactionalCommand {
+
+ /**
+ * The copied used to do the copy
+ */
+ final EMFCompareEObjectCopier copier;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * the editing domain
+ * @param diff
+ * the diffElement
+ * @param eObjectToCopy
+ * the object to copy
+ */
+ public CopyWithReferenceCommand(final TransactionalEditingDomain domain, final EMFCompareEObjectCopier copier, final EObject eObjectToCopy) {
+ super(domain, "CopyWithReferenceCommand", Collections.EMPTY_LIST); //$NON-NLS-1$
+ this.copier = copier;
+ final EObject copiedElement;
+ if(copier.containsKey(eObjectToCopy)) {
+ //385289: [UML Compare] Bad result after merginf UMLStereotypeApplicationAddition/Removal
+ //in some case, the elements are copied and merged twice!
+ copiedElement = this.copier.get(eObjectToCopy);
+ } else {
+ copiedElement = this.copier.copy(eObjectToCopy);
+ }
+ final CommandResult result = CommandResult.newOKCommandResult(copiedElement);
+ setResult(result);
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ this.copier.copyReferences();
+ this.copier.copyXMIIDs();
+ return getCommandResult();
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareEObjectCopier.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareEObjectCopier.java new file mode 100644 index 00000000000..3105d2fd810 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareEObjectCopier.java @@ -0,0 +1,440 @@ +/*****************************************************************************
+ * 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.diff.internal.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.diff.merge.EMFCompareEObjectCopier;
+import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
+import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import org.eclipse.emf.compare.diff.metamodel.DiffResourceSet;
+import org.eclipse.emf.compare.match.metamodel.Match2Elements;
+import org.eclipse.emf.compare.match.metamodel.MatchElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+import org.eclipse.papyrus.infra.emf.utils.ResourceUtils;
+
+/**
+ *
+ * This class copies the code of {@link EMFCompareEObjectCopier}, to do the actions with EMFCommands
+ *
+ */
+public class PapyrusCompareEObjectCopier extends EMFCompareEObjectCopier {
+
+ /**
+ * the serial UID
+ */
+ private static final long serialVersionUID = -6723632034214667973L;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diff
+ */
+ public PapyrusCompareEObjectCopier(final DiffResourceSet diff) {
+ super(diff);
+ throw new UnsupportedOperationException("not yet implemented");//we should initialize the map as it is done in the 2nd constructor //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diff
+ */
+ public PapyrusCompareEObjectCopier(final DiffModel diff) {
+ super(diff);
+ final EObject container = diff.eContainer();
+ if(container instanceof ComparisonResourceSnapshot) {
+ final ComparisonResourceSnapshot snapshot = (ComparisonResourceSnapshot)container;
+ final EList<MatchElement> matchedElements = snapshot.getMatch().getMatchedElements();
+ for(MatchElement current : matchedElements) {
+ if(current instanceof Match2Elements) {
+ initializeCopier((Match2Elements)current);
+
+ }
+ }
+ }
+ }
+
+ /**
+ * Initialize the copier with the couple of Object matched during the diff
+ * It is useful for comparison between stereotyped elements in the nested editor
+ * see bug 384490: [UML Compare] Comparison between stereotyped elements doesn't work in the nested Compare Editor
+ *
+ * @param matchElement
+ *
+ */
+ protected void initializeCopier(final Match2Elements matchElement) {
+ final EObject left = ((Match2Elements)matchElement).getLeftElement();
+ final EObject right = ((Match2Elements)matchElement).getRightElement();
+ put(left, right);
+ put(right, left);
+ for(final MatchElement current : matchElement.getSubMatchElements()) {
+ if(current instanceof Match2Elements) {
+ initializeCopier((Match2Elements)current);
+ }
+ }
+ }
+
+ /**
+ * Copy the XMi_ID only when the id doesn't exist in the target resource
+ *
+ * @see org.eclipse.emf.compare.diff.merge.EMFCompareEObjectCopier#copyXMIIDs()
+ *
+ */
+ @Override
+ public void copyXMIIDs() {
+ for(final Map.Entry<EObject, EObject> entry : entrySet()) {
+ final EObject original = entry.getKey();
+ final EObject copy = entry.getValue();
+ if(original.eResource() instanceof XMIResource && copy.eResource() instanceof XMIResource) {
+ final XMIResource originResource = (XMIResource)original.eResource();
+ final XMIResource copyResource = (XMIResource)copy.eResource();
+ if(originResource.getID(original) != null) {
+ if(original.eResource() == copy.eResource()) {
+ final String currentID = originResource.getID(original);
+ if(ResourceUtils.getAllResourceIds(copyResource).contains(currentID)) {
+ continue;
+ }
+ }
+ copyResource.setID(copy, originResource.getID(original));
+ final TreeIterator<EObject> originalIterator = original.eAllContents();
+ final TreeIterator<EObject> copyIterator = copy.eAllContents();
+ while(originalIterator.hasNext() && copyIterator.hasNext()) {
+ final EObject nextOriginalChild = originalIterator.next();
+ final EObject nextCopyChild = copyIterator.next();
+ if(nextOriginalChild.eResource() == nextCopyChild.eResource()) {
+ final String currentID = originResource.getID(nextOriginalChild);
+ if(ResourceUtils.getAllResourceIds(copyResource).contains(currentID)) {
+ continue;
+ }
+ }
+ copyResource.setID(nextCopyChild, originResource.getID(nextOriginalChild));
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Adapted from copyReferenceValue(EReference targetReference, EObject target, EObject value,
+ * EObject matchedValue, int index)
+ *
+ * @param targetReference
+ * @param target
+ * @param value
+ * @param matchedValue
+ * @param index
+ * @return
+ */
+ public Command getCopyReferenceValueCommand(final TransactionalEditingDomain domain, final EReference targetReference, final EObject target, final EObject value, final EObject matchedValue, final int index) {
+ EObject actualValue = value;
+ if(value == null && matchedValue != null) {
+ // handleLinkedResourceDependencyChange(matchedValue);
+ // actualValue = get(matchedValue);
+ //TODO
+ throw new UnsupportedOperationException("Not yet supported"); //$NON-NLS-1$
+ }
+ if(matchedValue != null) {
+ put(actualValue, matchedValue);
+
+ final Object referenceValue = target.eGet(targetReference);
+ if(referenceValue instanceof Collection<?>) {
+ //tested with ReferenceChangeLefttargetExample
+ return getAddAtIndexCommand(domain, target, targetReference, (Collection<EObject>)referenceValue, matchedValue, index);
+
+ } else {
+ //target.eSet(targetReference, matchedValue);
+ //tested with the project UpdateReferenceExample2
+ return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, target, targetReference, matchedValue);
+ }
+ }
+ //tested with ReferenceChangeLefttargetExample2
+ return getCopyValueReferenceCommand(domain, targetReference, target, actualValue, index);
+ }
+
+ private Command getCopyValueReferenceCommand(final TransactionalEditingDomain domain, final EReference targetReference, final EObject target, final EObject value, final int index) {
+ final Command copyValueCommand = new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ final EObject copy;
+ final EObject targetValue = PapyrusCompareEObjectCopier.this.get(value);
+ if(targetValue != null) {
+ copy = targetValue;
+ } else {
+ if(value.eResource() == null || value.eResource().getURI().isPlatformPlugin()) {
+ // We can't copy that object
+ copy = value;
+ } else {
+ copy = PapyrusCompareEObjectCopier.this.copy(value);
+ }
+ }
+ Command cmd = null;
+ final Object referenceValue = target.eGet(targetReference);
+ if(referenceValue instanceof List && targetReference.isMany()) {
+ if(copy.eIsProxy() && copy instanceof InternalEObject) {
+ // only add if the element is not already there.
+ final URI proxURI = ((InternalEObject)copy).eProxyURI();
+ boolean found = false;
+ final Iterator<EObject> it = ((List<EObject>)referenceValue).iterator();
+ while(!found && it.hasNext()) {
+ final EObject obj = it.next();
+ if(obj instanceof InternalEObject) {
+ found = proxURI.equals(((InternalEObject)obj).eProxyURI());
+ }
+ }
+ if(!found) {
+ final List<EObject> targetList = (List<EObject>)referenceValue;
+ //addAtIndex(targetList, copy, index);
+ //not tested
+ cmd = getAddAtIndexCommand(domain, target, targetReference, targetList, copy, index);
+ }
+ } else {
+ final List<EObject> targetList = (List<EObject>)referenceValue;
+ final int currentIndex = targetList.indexOf(copy);
+ if(currentIndex == -1) {
+ //addAtIndex(targetList, copy, index);
+ //not tested
+ cmd = getAddAtIndexCommand(domain, target, targetReference, targetList, copy, index);
+ } else {
+ // The order could be wrong in case of eOpposites
+ // movetoIndex(targetList, currentIndex, index);
+ cmd = getMoveAtIndexCommand(domain, target, targetList, targetReference, copy, currentIndex, index);
+ // throw new UnsupportedOperationException("Not yet supported");
+ }
+ }
+ } else {
+ if(copy.eIsProxy() && copy instanceof InternalEObject) {
+ // only change value if the URI changes
+ final URI proxURI = ((InternalEObject)copy).eProxyURI();
+ if(referenceValue instanceof InternalEObject) {
+ if(!proxURI.equals(((InternalEObject)referenceValue).eProxyURI())) {
+ //not tested
+ //target.eSet(targetReference, copy);
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, target, targetReference, copy);
+ }
+ }
+ } else {
+ //not tested
+ //target.eSet(targetReference, copy);
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, target, targetReference, copy);
+ }
+ }
+
+ if(cmd != null) {
+ cmd.execute();
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ });
+ return copyValueCommand;
+ }
+
+ /**
+ *
+ * @param key
+ * @return
+ * the copied object
+ */
+ public EObject getCopiedValue(final EObject key) {
+ return get(key);
+ }
+
+
+ private Command getMoveAtIndexCommand(final TransactionalEditingDomain domain, final EObject target, final List<EObject> targetList, final EReference targetReference, final EObject copy, final int currentIndex, final int expectedIndex) {
+ final List<EObject> newColl = new ArrayList<EObject>(targetList);
+ final int size = targetList.size();
+ if(size <= 1 || currentIndex < 0 || currentIndex >= size) {
+ // return;
+ //do nothing
+ } else if(expectedIndex != -1 && expectedIndex != currentIndex && expectedIndex <= size - 1) {
+ newColl.add(expectedIndex, newColl.remove(currentIndex));
+ }
+
+ return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, target, targetReference, newColl);
+ }
+
+ /**
+ * Returns the command to set the wanted object at the wanted index
+ *
+ * @param domain
+ * @param editedElement
+ * @param feature
+ * @param collection
+ * @param newValue
+ * @param index
+ * @return
+ */
+ private Command getAddAtIndexCommand(final TransactionalEditingDomain domain, final EObject editedElement, final EStructuralFeature feature, final Collection<EObject> collection, final EObject newValue, final int index) {
+ final List<EObject> newColl = new ArrayList<EObject>(collection);
+ final int listSize = collection.size();
+ if(index > -1 && index < listSize) {
+ newColl.add(index, newValue);
+ } else {
+ newColl.add(newValue);
+ }
+ attachRealPositionEAdapter(newValue, index);
+ reorderList(newColl);
+ return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, editedElement, feature, newColl);
+ }
+
+ /**
+ * Duplicate code from EFactory
+ * If we could not merge a given object at its expected position in a list, we'll attach an Adapter to it
+ * in order to "remember" that "expected" position. That will allow us to reorder the list later on if
+ * need be.
+ *
+ * @param object
+ * The object on which to attach an Adapter.
+ * @param expectedPosition
+ * The expected position of <code>object</code> in its list.
+ */
+ private void attachRealPositionEAdapter(final Object object, final int expectedPosition) {
+ if(object instanceof EObject) {
+ ((EObject)object).eAdapters().add(new PositionAdapter(expectedPosition));
+ }
+ }
+
+ /**
+ * Duplicate code from EFactory
+ * Reorders the given list if it contains EObjects associated with a PositionAdapter which are not located
+ * at their expected positions.
+ *
+ * @param list
+ * The list that is to be reordered.
+ * @param <T>
+ * type of the list's elements.
+ */
+ private <T> void reorderList(final List<T> list) {
+ final List<T> newList = new ArrayList<T>(list);
+ Collections.sort(newList, new EObjectComparator());
+ for(int i = 0; i < list.size(); i++) {
+ int oldIndex = list.indexOf(newList.get(i));
+ list.add(i, list.remove(oldIndex));
+ }
+ return;
+ }
+
+
+ /**
+ * This class exists in several classes of this plugin. It is not an error : the same obejct can be referenced by different
+ * feature and different position at the same time. So we need to have a class PositionAdapter for each context!
+ * duplicate code from Efactory
+ * This adapter will be used to remember the accurate position of an EObject in its target list.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+ private class PositionAdapter extends AdapterImpl {
+
+ /** The index at which we expect to find this object. */
+ private final int expectedIndex;
+
+ /**
+ * Creates our adapter.
+ *
+ * @param index
+ * The index at which we expect to find this object.
+ */
+ public PositionAdapter(final int index) {
+ this.expectedIndex = index;
+ }
+
+ /**
+ * Returns the index at which we expect to find this object.
+ *
+ * @return The index at which we expect to find this object.
+ */
+ public int getExpectedIndex() {
+ return expectedIndex;
+ }
+ }
+
+ /**
+ *
+ * This class allows to compare EObject using the PositionAdapter.
+ *
+ *
+ */
+ private class EObjectComparator<T> implements Comparator<T> {
+
+ /**
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ public int compare(final T o1, final T o2) {
+ if(o1 instanceof EObject && o2 instanceof EObject) {
+ final int position1 = getWantedPosition((EObject)o1);
+ final int position2 = getWantedPosition((EObject)o2);
+ if(position1 != -1 && position2 != -1) {
+ return position1 - position2;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ *
+ * @param obj1
+ * an EObject
+ * @return
+ * the wanted position for this object
+ */
+ private int getWantedPosition(final EObject obj1) {
+ final Iterator<Adapter> adapters = obj1.eAdapters().iterator();
+ int expectedIndex = -1;
+ while(expectedIndex == -1 && adapters.hasNext()) {
+ final Adapter adapter = adapters.next();
+ if(adapter instanceof PositionAdapter) {
+ expectedIndex = ((PositionAdapter)adapter).getExpectedIndex();
+ }
+ }
+ return expectedIndex;
+ }
+
+ }
+
+
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareMap.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareMap.java new file mode 100644 index 00000000000..a48c4b4d68e --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusCompareMap.java @@ -0,0 +1,104 @@ +/*****************************************************************************
+ * 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.diff.internal.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.papyrus.infra.emf.compare.diff.Activator;
+
+/**
+ * This map log an error when a wanted element is unknown in the map
+ *
+ * @author VL222926
+ *
+ * @param <K>
+ * @param <V>
+ */
+public class PapyrusCompareMap<K, V> extends HashMap<K, V> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the specified initial
+ * capacity and load factor.
+ *
+ * @param initialCapacity
+ * The initial capacity.
+ * @param loadFactor
+ * The load factor.
+ * @throws IllegalArgumentException
+ * if the initial capacity is negative
+ * or the load factor is nonpositive.
+ */
+ public PapyrusCompareMap(final int initialCapacity, final float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the specified initial
+ * capacity and the default load factor (0.75).
+ *
+ * @param initialCapacity
+ * the initial capacity.
+ * @throws IllegalArgumentException
+ * if the initial capacity is negative.
+ */
+ public PapyrusCompareMap(final int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the default initial capacity
+ * (16) and the default load factor (0.75).
+ */
+ public PapyrusCompareMap() {
+ super();
+ }
+
+ /**
+ * Constructs a new <tt>HashMap</tt> with the same mappings as the
+ * specified <tt>Map</tt>. The <tt>HashMap</tt> is created with
+ * default load factor (0.75) and an initial capacity sufficient to
+ * hold the mappings in the specified <tt>Map</tt>.
+ *
+ * @param m
+ * the map whose mappings are to be placed in this map.
+ * @throws NullPointerException
+ * if the specified map is null.
+ */
+ public PapyrusCompareMap(final Map<? extends K, ? extends V> m) {
+ super(m);
+ }
+
+ /**
+ * We display an error when a wanted element is not included in the Map
+ *
+ * @see java.util.HashMap#get(java.lang.Object)
+ *
+ * @param key
+ * @return
+ */
+ @Override
+ public V get(final Object key) {
+ V obj = super.get(key);
+ if(obj == null) {
+ Activator.log.error("The following element is unknown in the map : " + key, new NullPointerException()); //$NON-NLS-1$
+ }
+ return obj;
+ }
+}
diff --git a/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusEFactory.java b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusEFactory.java new file mode 100644 index 00000000000..0bb27cd9442 --- /dev/null +++ b/deprecated/uml-compare-1.X/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/util/PapyrusEFactory.java @@ -0,0 +1,297 @@ +/*****************************************************************************
+ * 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.diff.internal.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.compare.EMFCompareMessages;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.util.EFactory;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.compare.diff.internal.command.PapyrusMergeCommandProvider;
+
+//TODO : merge with thepapyrus table command factory?
+/**
+ *
+ * This class is adapted from {@link EFactory}
+ *
+ */
+/**
+ *
+ * This class is adapted from {@link EFactory}
+ *
+ */
+public class PapyrusEFactory {
+
+
+ private PapyrusEFactory() {
+ //nothing to do
+ }
+
+ public static final <T> Command getEAddCommand(final TransactionalEditingDomain domain, final EObject object, final String name, final T arg) throws FactoryException {
+ return getEAddCommand(domain, object, name, arg, -1);
+ }
+
+ public static final <T> Command getEAddCommand(final TransactionalEditingDomain domain, final EObject object, final String name, final T arg, final int elementIndex) throws FactoryException {
+ return getEAddCommand(domain, object, name, arg, elementIndex, false);
+ }
+
+ public static final <T> Command getEAddCommand(final TransactionalEditingDomain domain, final EObject object, final String name, final T arg, final int elementIndex, final boolean reorder) throws FactoryException {
+ Command returnedCommand = null;
+ final EStructuralFeature feature = eStructuralFeature(object, name);
+ if(feature.isMany() && arg != null) {
+ final Object manyValue = object.eGet(feature); |