Difference between revisions of "EMF Compare/API OpenEditorWithSelection"

From Eclipsepedia

Jump to: navigation, search
Line 10: Line 10:
  
 
final IFile right = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC2.ecorediag");
 
final IFile right = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC2.ecorediag");
 
 
final IFile left = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC1.ecorediag");
 
final IFile left = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC1.ecorediag");
  
Line 22: Line 21:
 
  uris.add(id);
 
  uris.add(id);
 
}
 
}
 +
 
CompareServices.openEditor(input, uris);
 
CompareServices.openEditor(input, uris);
</pre>
+
</pre>  
 +
An other example to call this API in order to compare two model versions from the history of a GIT repository:
 +
<pre>final IFile model = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/org.eclipse.emf.compare.diff/model/diff.ecore"));
  
An other example to call this API in order to compare two model versions from the history of a GIT repository:
 
<pre>
 
final IFile model = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/org.eclipse.emf.compare.diff/model/diff.ecore"));
 
 
final String commitName1 = "322349c45b00f6fe2bc9675772dfc51d37d5741e";
 
final String commitName1 = "322349c45b00f6fe2bc9675772dfc51d37d5741e";
 
final String commitName2 = "48df5626b7c4e5cb8d584b21865a548ef9ae437e";
 
final String commitName2 = "48df5626b7c4e5cb8d584b21865a548ef9ae437e";
 +
 
GitCompareEditorInput input = new GitCompareEditorInput(commitName1, commitName2, model);
 
GitCompareEditorInput input = new GitCompareEditorInput(commitName1, commitName2, model);
 +
 
final List&lt;String&gt; uris = new ArrayList&lt;String&gt;();
 
final List&lt;String&gt; uris = new ArrayList&lt;String&gt;();
 
for (String id&nbsp;: new String[] {"//DiffElement/requires"}) {
 
for (String id&nbsp;: new String[] {"//DiffElement/requires"}) {
 
  uris.add(id);
 
  uris.add(id);
 
}
 
}
 +
 
CompareServices.openEditor(input, uris);
 
CompareServices.openEditor(input, uris);
 
</pre>
 
</pre>

Revision as of 08:05, 13 October 2011

The API enables to compute differences between models and open an EMF Compare editor from the result of the comparison and to select the differences about given model object identifiers.

  • void openEditor(final CompareEditorInput input, List<String> objectIds)
    

The input may be any input, instance of CompareEditorInput.

Here is an example to call this API in order to compare local models (ecoretools diagrams):

final IWorkbenchPage workBenchPage = TeamUIPlugin.getActivePage();

final IFile right = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC2.ecorediag");
final IFile left = ResourcesPlugin.getWorkspace().getRoot().getFile("/org.eclipse.emf.compare.diagram.ui.tests/TC01_Added_nodes/TC1.ecorediag");

final ITypedElement iLeft = SaveablesCompareEditorInput.createFileElement(left);
final ITypedElement iRight = SaveablesCompareEditorInput.createFileElement(right);

final CompareEditorInput input = new SaveablesCompareEditorInput(null, iLeft, iRight, workBenchPage);

final List<String> uris = new ArrayList<String>();
for (String id : new String[] {"_sEwyAKfOEeC-6Yy0go4yvQ", "//EClass0" }) {
 uris.add(id);
}

CompareServices.openEditor(input, uris);

An other example to call this API in order to compare two model versions from the history of a GIT repository:

final IFile model = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/org.eclipse.emf.compare.diff/model/diff.ecore"));

final String commitName1 = "322349c45b00f6fe2bc9675772dfc51d37d5741e";
final String commitName2 = "48df5626b7c4e5cb8d584b21865a548ef9ae437e";

GitCompareEditorInput input = new GitCompareEditorInput(commitName1, commitName2, model);

final List<String> uris = new ArrayList<String>();
for (String id : new String[] {"//DiffElement/requires"}) {
 uris.add(id);
}

CompareServices.openEditor(input, uris);