Difference between revisions of "EMF Compare/API OpenEditorWithSelection"

From Eclipsepedia

Jump to: navigation, search
Line 1: Line 1:
= THIS PAGE IS OUTDATED AND IS NOT SCHEDULED TO BE UPDATED =
+
{{Template:EMF Compare Archived Notice}}
  
 
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. It is the service class: CompareServices which contains this API:  
 
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. It is the service class: CompareServices which contains this API:  
Line 45: Line 45:
 
*<pre>void setSelection(List<String> objectIds, IEditorPart editor)
 
*<pre>void setSelection(List<String> objectIds, IEditorPart editor)
 
</pre>
 
</pre>
 
[[Category:EMF Compare OUTDATED]]
 

Revision as of 11:35, 5 March 2014


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. It is the service class: CompareServices which contains this API:

  • 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";

final CompareEditorInput 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);

If there is an available opened EMF Compare editor, the selection of the differences can be updated afterwards. For that, it exists an other API:

  • void setSelection(List<String> objectIds, IEditorPart editor)