Jump to: navigation, search

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

(7 intermediate revisions by one other user not shown)
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 create a new viewer (Structure Viewer) from the result of a model comparison and to display the differences in relation to a given filtering and grouping configuration. The content of this viewer can be updated calling setInput(Object) method or modifying its filtering and grouping configuration through setDifferenceFilters(List<IDifferenceFilter>) and setDifferenceGroupingFacility(IDifferenceGroupingFacility).
  
 
It is the service class: CompareServices which contains this API:  
 
It is the service class: CompareServices which contains this API:  
  
*<pre>void openView(final ComparisonSnapshot input, final List&lt;IDifferenceFilter&gt; filters, final IDifferenceGroupingFacility group)
+
*<pre>StructureViewer getStructureViewer(Composite parent, ComparisonSnapshot input)
 
</pre>
 
</pre>
  
It enables to open the structure view from a comparion result (snapshot) with a given filtering and grouping configuration.  
+
It is used to create and retrieve a viewer for the parent composite (for example, the control of a ViewPane) and from the result of a model comparison as input (ComparisonSnapshot).
  
Here is an exemple to call this method:  
+
The same thing, but with filters and grouping configuration to initialize the viewer:
  
----
+
*<pre>StructureViewer getStructureViewer(Composite parent, ComparisonSnapshot input, List<IDifferenceFilter> filters, IDifferenceGroupingFacility groupingFacility)
 +
</pre>
 +
 
 +
Here is an example to return a viewer for "parent" with a filter on added elements:
  
 +
<pre>
 +
final List&lt;IDifferenceFilter&gt; filters = DifferenceFilterRegistry.INSTANCE.getFilters(DifferenceFilterRegistry.FILTERING_ADDED_ELEMENTS_ID);
 +
 +
final ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
 +
 +
if (provider instanceof IInputProvider) {
 +
 +
&nbsp; final Object root = ((IInputProvider)provider).getInput();
 +
 +
&nbsp; if (root instanceof ComparisonSnapshot) {
 +
 +
&nbsp;&nbsp;&nbsp; return getStructureViewer(parent, root, filters, null);
 +
 +
&nbsp; }
 +
 +
}
 +
</pre>
 +
 +
 +
 +
Below, an API to open a view based on this viewer:
 +
 +
*<pre>void openView(final ComparisonSnapshot input, final List&lt;IDifferenceFilter&gt; filters, final IDifferenceGroupingFacility group)
 +
</pre>
 +
 +
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:
 +
<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 27: Line 59:
  
 
}
 
}
 +
</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>
 +
 +
These last methods can be called without filtering and grouping configuration. It is equivalent to put filters and group to null value.
 +
*<pre>void openView(final ComparisonSnapshot input)
 +
</pre>
 +
*<pre>void openView(IEditorPart editor)
 +
</pre>
  
----
+
[[Category:Modeling]] [[Category:EMF Compare]]

Revision as of 02:55, 18 October 2012

The API has to allow to create a new viewer (Structure Viewer) from the result of a model comparison and to display the differences in relation to a given filtering and grouping configuration. The content of this viewer can be updated calling setInput(Object) method or modifying its filtering and grouping configuration through setDifferenceFilters(List<IDifferenceFilter>) and setDifferenceGroupingFacility(IDifferenceGroupingFacility).

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

  • StructureViewer getStructureViewer(Composite parent, ComparisonSnapshot input)
    

It is used to create and retrieve a viewer for the parent composite (for example, the control of a ViewPane) and from the result of a model comparison as input (ComparisonSnapshot).

The same thing, but with filters and grouping configuration to initialize the viewer:

  • StructureViewer getStructureViewer(Composite parent, ComparisonSnapshot input, List<IDifferenceFilter> filters, IDifferenceGroupingFacility groupingFacility)
    

Here is an example to return a viewer for "parent" with a filter on added elements:

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

    return getStructureViewer(parent, root, filters, null);

  } 

}


Below, an API to open a view based on this viewer:

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