Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EMF Compare/API Viewer FilteringGrouping"

Line 8: Line 8:
 
It enables to open the structure view from a comparion result (snapshot) with a given filtering and grouping configuration.  
 
It enables to open the structure view from a comparion result (snapshot) with a given filtering and grouping configuration.  
  
Here is an exemple to call this method:  
+
Here is an example to call this method:  
 
<pre>
 
<pre>
 
final List&lt;IDifferenceFilter&gt; filters = DifferenceFilterRegistry.INSTANCE.getFilters(DifferenceFilterRegistry.FILTERING_ADDED_ELEMENTS_ID);
 
final List&lt;IDifferenceFilter&gt; filters = DifferenceFilterRegistry.INSTANCE.getFilters(DifferenceFilterRegistry.FILTERING_ADDED_ELEMENTS_ID);
Line 25: Line 25:
  
 
}
 
}
 +
</pre>
 +
 +
The API can be called from an existing opened EMF Compare editor:
 +
*<pre>void openView(IEditorPart editor, final List&lt;IDifferenceFilter&gt; filters, final IDifferenceGroupingFacility group)
 +
</pre>
 +
Here is an example to call this method:
 +
<pre>
 +
IEditorPart editor = null;
 +
 +
final IWorkbench workbench = PlatformUI.getWorkbench();
 +
 +
if (workbench != null) {
 +
 +
&nbsp; final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
 +
 +
&nbsp; if (workbenchWindow != null) {
 +
 +
&nbsp;&nbsp;  final IWorkbenchPage page = workbenchWindow.getActivePage();
 +
 +
&nbsp;&nbsp;  if (page != null) {
 +
 +
&nbsp;&nbsp;&nbsp;  final IEditorReference[] editors = page.getEditorReferences();
 +
 +
&nbsp;&nbsp;&nbsp;  for (IEditorReference iEditorReference : editors) {
 +
 +
&nbsp;&nbsp;&nbsp;&nbsp;    if (editorInput.equals(iEditorReference.getEditorInput())) {
 +
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    editor = iEditorReference.getEditor(true);
 +
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    break;
 +
 +
&nbsp;&nbsp;&nbsp;&nbsp;    }
 +
 +
&nbsp;&nbsp;&nbsp;  }
 +
 +
&nbsp;&nbsp;  }
 +
 +
&nbsp; }
 +
 +
}
 +
 +
CompareServices.openView(editor, null, null);
 
</pre>
 
</pre>

Revision as of 05:12, 13 October 2011

The API has to allow to launch a graphical comparison of models, specifying the filters to activate and the grouping configuration to use.

It is the service class: CompareServices which contains this API:

  • void openView(final ComparisonSnapshot input, final List<IDifferenceFilter> filters, final IDifferenceGroupingFacility group)

It enables to open the structure view from a comparion result (snapshot) with a given filtering and grouping configuration.

Here is an example to call this method:

final List<IDifferenceFilter> filters = DifferenceFilterRegistry.INSTANCE.getFilters(DifferenceFilterRegistry.FILTERING_ADDED_ELEMENTS_ID);

final ISelectionProvider provider = editor.getEditorSite().getSelectionProvider(); 

if (provider instanceof IInputProvider) {

  final Object root = ((IInputProvider)provider).getInput(); 

  if (root instanceof ComparisonSnapshot) { 

    CompareServices.openView((ComparisonSnapshot)root, filters, null);

  } 

}

The API can be called from an existing opened EMF Compare editor:

  • void openView(IEditorPart editor, final List<IDifferenceFilter> filters, final IDifferenceGroupingFacility group)

Here is an example to call this method:

IEditorPart editor = null;

final IWorkbench workbench = PlatformUI.getWorkbench();

if (workbench != null) {

  final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();

  if (workbenchWindow != null) {

    final IWorkbenchPage page = workbenchWindow.getActivePage();

    if (page != null) {

      final IEditorReference[] editors = page.getEditorReferences();

      for (IEditorReference iEditorReference : editors) {

        if (editorInput.equals(iEditorReference.getEditorInput())) {

          editor = iEditorReference.getEditor(true);

          break;

        }

      }

    }

  }

}

CompareServices.openView(editor, null, null);

Back to the top