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

From Eclipsepedia

Jump to: navigation, search
Line 1: Line 1:
The API has to allow to launch a graphical comparison of models, specifying the filters to activate and the grouping configuration to use.  
+
The API has to allow to open or refresh an eclipse view (Structure View) from the result of a model comparison and to display the differences in relation to a given filtering and grouping configuration.
  
 
It is the service class: CompareServices which contains this API:  
 
It is the service class: CompareServices which contains this API:  

Revision as of 09:08, 13 October 2011

The API has to allow to open or refresh an eclipse view (Structure View) from the result of a model comparison and to display the differences in relation to a given filtering and grouping configuration.

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

These last methods can be called without filtering and grouping configuration. It is equivalent to put filters and group to null value.

  • void openView(final ComparisonSnapshot input)
    
  • void openView(IEditorPart editor)