Jump to: navigation, search

Difference between revisions of "EMF Compare/API OpenEditorWithSelection"

Line 30: Line 30:
 
final String commitName2 = "48df5626b7c4e5cb8d584b21865a548ef9ae437e";
 
final String commitName2 = "48df5626b7c4e5cb8d584b21865a548ef9ae437e";
  
GitCompareEditorInput input = new GitCompareEditorInput(commitName1, commitName2, model);
+
final CompareEditorInput input = new GitCompareEditorInput(commitName1, commitName2, model);
  
 
final List<String> uris = new ArrayList<String>();
 
final List<String> uris = new ArrayList<String>();

Revision as of 08:06, 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";

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