diff options
author | lgoubet | 2011-03-09 09:34:18 +0000 |
---|---|---|
committer | lgoubet | 2011-03-09 09:34:18 +0000 |
commit | 72802f28aa3503599bf85513128c4cffc7a67427 (patch) | |
tree | 82e53b846bd7beadb428604712573aa8acdb4d4d | |
parent | 6f3f8caa4ed68cb3de1f66c47282745f4a49e9fa (diff) | |
download | org.eclipse.emf.compare-72802f28aa3503599bf85513128c4cffc7a67427.tar.gz org.eclipse.emf.compare-72802f28aa3503599bf85513128c4cffc7a67427.tar.xz org.eclipse.emf.compare-72802f28aa3503599bf85513128c4cffc7a67427.zip |
Adding copyright notice
4 files changed, 131 insertions, 55 deletions
diff --git a/plugins/org.eclipse.emf.compare.mpatch.common/src/org/eclipse/emf/compare/mpatch/common/util/CommonGmfUtils.java b/plugins/org.eclipse.emf.compare.mpatch.common/src/org/eclipse/emf/compare/mpatch/common/util/CommonGmfUtils.java index 932d6ac28..88c4352a5 100644 --- a/plugins/org.eclipse.emf.compare.mpatch.common/src/org/eclipse/emf/compare/mpatch/common/util/CommonGmfUtils.java +++ b/plugins/org.eclipse.emf.compare.mpatch.common/src/org/eclipse/emf/compare/mpatch/common/util/CommonGmfUtils.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2010 Technical University of Denmark. + * 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: + * Patrick Koenemann, DTU Informatics - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.mpatch.common.util; import org.eclipse.emf.common.util.URI; @@ -8,12 +18,10 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.ui.IEditorInput; /** - * Internally used to locate GMF-based diagram editor input. - * - * Please note that this class is optional! It might not be loaded if GMF is not loaded! + * Internally used to locate GMF-based diagram editor input. Please note that this class is optional! It might + * not be loaded if GMF is not loaded! * * @author Patrick Koenemann (pk@imm.dtu.dk) - * */ public class CommonGmfUtils { @@ -22,25 +30,28 @@ public class CommonGmfUtils { * * @param editorInput * The editor input. - * @return The {@link URI} of the model to which the diagram editor belongs or <code>null</code> if none is found. + * @return The {@link URI} of the model to which the diagram editor belongs or <code>null</code> if none + * is found. */ static URI getUriFromEditorInput(IEditorInput editorInput) { if (editorInput instanceof IDiagramEditorInput) { - final IDiagramEditorInput diagramEditorInput = (IDiagramEditorInput) editorInput; + final IDiagramEditorInput diagramEditorInput = (IDiagramEditorInput)editorInput; final Diagram diagram = diagramEditorInput.getDiagram(); // is the element set and is that our model? if (diagram.getElement() != null) { final Resource resource = diagram.getElement().eResource(); - if (resource != null && resource.getURI() != null) + if (resource != null && resource.getURI() != null) { return resource.getURI(); + } } // RSA, for instance, stores diagrams in annotations. if (diagram.eContainer() != null && diagram.eContainer() instanceof EAnnotation) { final Resource resource = diagram.eResource(); - if (resource != null && resource.getURI() != null) + if (resource != null && resource.getURI() != null) { return resource.getURI(); + } } } return null; diff --git a/plugins/org.eclipse.emf.compare.mpatch.emfdiff2mpatch.generic/symrefsrc/org/eclipse/emf/compare/mpatch/symrefs/util/LevenshteinDistance.java b/plugins/org.eclipse.emf.compare.mpatch.emfdiff2mpatch.generic/symrefsrc/org/eclipse/emf/compare/mpatch/symrefs/util/LevenshteinDistance.java index 51cf400c6..d64b2aba1 100644 --- a/plugins/org.eclipse.emf.compare.mpatch.emfdiff2mpatch.generic/symrefsrc/org/eclipse/emf/compare/mpatch/symrefs/util/LevenshteinDistance.java +++ b/plugins/org.eclipse.emf.compare.mpatch.emfdiff2mpatch.generic/symrefsrc/org/eclipse/emf/compare/mpatch/symrefs/util/LevenshteinDistance.java @@ -1,17 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2010 Technical University of Denmark. + * 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: + * Patrick Koenemann, DTU Informatics - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.mpatch.symrefs.util; /** * Copied from http://www.merriampark.com/ld.htm#JAVA (2010-06-01) - * * <p> - * "Levenshtein distance (LD) is a measure of the similarity between two strings, which we will refer to as the source - * string (s) and the target string (t). The distance is the number of deletions, insertions, or substitutions required - * to transform s into t. For example, + * "Levenshtein distance (LD) is a measure of the similarity between two strings, which we will refer to as + * the source string (s) and the target string (t). The distance is the number of deletions, insertions, or + * substitutions required to transform s into t. For example, * <ul> - * <li>If s is "test" and t is "test", then LD(s,t) = 0, because no transformations are needed. The strings are already - * identical. - * <li>If s is "test" and t is "tent", then LD(s,t) = 1, because one substitution (change "s" to "n") is sufficient to - * transform s into t. + * <li>If s is "test" and t is "test", then LD(s,t) = 0, because no transformations are needed. The strings + * are already identical. + * <li>If s is "test" and t is "tent", then LD(s,t) = 1, because one substitution (change "s" to "n") is + * sufficient to transform s into t. * </ul> * The greater the Levenshtein distance, the more different the strings are." * </p> @@ -48,17 +57,21 @@ public class LevenshteinDistance { // Step 1 n = s.length(); m = t.length(); - if (n == 0) + if (n == 0) { return m; - if (m == 0) + } + if (m == 0) { return n; + } d = new int[n + 1][m + 1]; // Step 2 - for (i = 0; i <= n; i++) + for (i = 0; i <= n; i++) { d[i][0] = i; - for (j = 0; j <= m; j++) + } + for (j = 0; j <= m; j++) { d[0][j] = j; + } // Step 3 for (i = 1; i <= n; i++) { @@ -69,10 +82,11 @@ public class LevenshteinDistance { t_j = t.charAt(j - 1); // Step 5 - if (s_i == t_j) + if (s_i == t_j) { cost = 0; - else + } else { cost = 1; + } // Step 6 d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost); @@ -82,7 +96,7 @@ public class LevenshteinDistance { // Step 7 return d[n][m]; } - + public static void main(String[] args) { System.out.println(calculateDistance("person", "season")); } diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/DanglingReferenceOnTwoAdds.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/DanglingReferenceOnTwoAdds.java index 6855323bc..432cab987 100644 --- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/DanglingReferenceOnTwoAdds.java +++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/DanglingReferenceOnTwoAdds.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2010 Technical University of Denmark. + * 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: + * Patrick Koenemann, DTU Informatics - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.tests.merge; import org.eclipse.emf.common.util.EList; diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/unit/match/engine/TwoWayModelMatchFragments.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/unit/match/engine/TwoWayModelMatchFragments.java index 80829cc1b..f0a5ccf28 100644 --- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/unit/match/engine/TwoWayModelMatchFragments.java +++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/unit/match/engine/TwoWayModelMatchFragments.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2010 Technical University of Denmark. + * 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: + * Patrick Koenemann, DTU Informatics - initial API and implementation + *******************************************************************************/ package org.eclipse.emf.compare.tests.unit.match.engine; import java.util.Collections; @@ -19,7 +29,7 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; public class TwoWayModelMatchFragments extends TestCase { /** Current VM's encoding name. */ private static final String ENCODING_STRING = System.getProperty("file.encoding"); - + /** Current machine's line separator. */ private static final String LINE_SEPARATOR = System.getProperty("line.separator"); @@ -28,37 +38,68 @@ public class TwoWayModelMatchFragments extends TestCase { super.setUp(); } - String expected = "<?xml version=\"1.0\" encoding=\"" + ENCODING_STRING + "\"?>" + LINE_SEPARATOR - + "<diff:DiffModel xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:diff=\"http://www.eclipse.org/emf/compare/diff/1.1\">" + LINE_SEPARATOR - + " <ownedElements xsi:type=\"diff:DiffGroup\">" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:UpdateAttribute\">" + LINE_SEPARATOR - + " <attribute href=\"http://www.eclipse.org/emf/2002/Ecore#//ENamedElement/name\"/>" + LINE_SEPARATOR - + " <leftElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#//ClassInParent\"/>" + LINE_SEPARATOR - + " <rightElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#/\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + LINE_SEPARATOR - + " <subDiffElements xsi:type=\"diff:ReferenceChangeRightTarget\">" + LINE_SEPARATOR - + " <reference href=\"http://www.eclipse.org/emf/2002/Ecore#//EClass/eSuperTypes\"/>" + LINE_SEPARATOR - + " <rightElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#//ClassInChild\"/>" + LINE_SEPARATOR - + " <leftElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/child.ecore#//ClassInChild\"/>" + LINE_SEPARATOR - + " <rightTarget href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + LINE_SEPARATOR - + " <leftTarget href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#//ClassInParent\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#//ClassInChild\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#/\"/>" + LINE_SEPARATOR - + " </subDiffElements>" + LINE_SEPARATOR - + " </ownedElements>" + LINE_SEPARATOR - + " <leftRoots href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#/\"/>" + LINE_SEPARATOR - + " <rightRoots href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#/\"/>" + LINE_SEPARATOR - + "</diff:DiffModel>" + LINE_SEPARATOR; + String expected = "<?xml version=\"1.0\" encoding=\"" + + ENCODING_STRING + + "\"?>" + + LINE_SEPARATOR + + "<diff:DiffModel xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:diff=\"http://www.eclipse.org/emf/compare/diff/1.1\">" + + LINE_SEPARATOR + + " <ownedElements xsi:type=\"diff:DiffGroup\">" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:UpdateAttribute\">" + + LINE_SEPARATOR + + " <attribute href=\"http://www.eclipse.org/emf/2002/Ecore#//ENamedElement/name\"/>" + + LINE_SEPARATOR + + " <leftElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#//ClassInParent\"/>" + + LINE_SEPARATOR + + " <rightElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#/\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:DiffGroup\">" + + LINE_SEPARATOR + + " <subDiffElements xsi:type=\"diff:ReferenceChangeRightTarget\">" + + LINE_SEPARATOR + + " <reference href=\"http://www.eclipse.org/emf/2002/Ecore#//EClass/eSuperTypes\"/>" + + LINE_SEPARATOR + + " <rightElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#//ClassInChild\"/>" + + LINE_SEPARATOR + + " <leftElement href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/child.ecore#//ClassInChild\"/>" + + LINE_SEPARATOR + + " <rightTarget href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#//ClassInParentRenamed\"/>" + + LINE_SEPARATOR + + " <leftTarget href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#//ClassInParent\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#//ClassInChild\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " <rightParent href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/child.ecore#/\"/>" + + LINE_SEPARATOR + + " </subDiffElements>" + + LINE_SEPARATOR + + " </ownedElements>" + + LINE_SEPARATOR + + " <leftRoots href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v1/parent.ecore#/\"/>" + + LINE_SEPARATOR + + " <rightRoots href=\"platform:/plugin/org.eclipse.emf.compare.tests/inputs/fragment/v2/parent.ecore#/\"/>" + + LINE_SEPARATOR + "</diff:DiffModel>" + LINE_SEPARATOR; public void testFragmentedEcoresResourceSetMatch() throws Exception { ResourceSet leftSet = new ResourceSetImpl(); |