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

EMF Compare/Specifications/LogicalModelView

< EMF Compare
Revision as of 05:43, 13 October 2014 by Axel.richard.obeo.fr (Talk | contribs) (How to compute/recompute/retrieve the logical model ?)

Logical Model View

Functional specification

EMF Compare does not act simply on the selected files, but on their whole logical model (a given model can be split through multiple files through EMF control action). Thanks to that, if you try and compare a model file that reference other model files, the comparison will still be able to take these "other" files into account. For example, if you try and compare a genmodel file (that depends on its underlying ecore file), then both files will be taken into account for the comparison.

The EMF compare Logical Model View allows to see, for a given model (or set of models), the resulting logical model computed by EMF Compare.

EMF Compare LogicalModelView Spec 01.png

  • All models that are part of the logical model will be display as a flat list.
  • The list will be non editable.
  • The model (or set of models) used to compute the logical model will be highlighted in a specific color (to be determined), to remember to the user which model(s) are at the origin of the logical model displayed.
  • A contextual menu with classic actions (as those in the Package Explorer View) will be available for each item of the list.
  • A new action will be added to this contextual menu : Show In Package Explorer. It will allow to select the corresponding model in the Package Explorer (if it is present).
  • A button Link with Editor and Selection will be added in the toolbar of the view. This button will synchronize the Logical Model View to the active editor or the selected element in the Package Explorer View.
    • The editors taken into account to populate the View will be: EMF Compare's comparison models editor, Papyrus editors, and EMF Reflective Model editors.
    • Any EMF model selected in the Package Explorer View will populate the View.
    • This button will be disabled by default.
    • When the Logical Model View is opened for the first time, the button is disabled, and no model is displayed in the view, even if one is selected in the Package Explorer View or the active editor.
    • When the button is enabled, the synchronization becomes active.
    • When the button is disabled, the synchronization becomes inactive. The last logical model computed and displayed in the View will remains until the button was enabled again and a new editor be active or a model was selected, or else the View was closed.

EMF Compare LogicalModelView Spec 03.png

Axis of evolution

As an axis of evolution, the models displayed in the Logical Model View could be presented as trees.

EMF Compare LogicalModelView Spec 02.png

A View Menu button could be added to switch the presentation between flat list and trees.

EMF Compare LogicalModelView Spec 04.png

Technical specification

How to listen to active editor ?

Eclipse allows to listen to active editors with the org.eclipse.ui.IPartService.
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();

service.addPartListener(new IPartListener() {	

		@Override
		public void partOpened(IWorkbenchPart part) {

		}

		@Override
		public void partDeactivated(IWorkbenchPart part) {
		
		}
					
		@Override
		public void partClosed(IWorkbenchPart part) {
	
		}
					
		@Override
		public void partBroughtToTop(IWorkbenchPart part) {
			
		}
					
		@Override
		public void partActivated(IWorkbenchPart part) {

		}

});

How to listen to current selection ?

Eclipse allows to listen to the current selection with the org.eclipse.ui.ISelectionService.
ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();

service.addPostSelectionListener(new ISelectionListener() {	

		@Override
		public void selectionChanged(IWorkbenchPart part, ISelection selection) {

		}

});

How to compute/recompute/retrieve the logical model ?

In case of an active Editor of type EMF Compare

In this case, the logical model has already been computed. We have to retrieve it.

In case of an active Editor of type Papyrus

In this case, we have to compute the logical model.

In case of an active Editor of type EMF Reflective Model

In this case, we have to compute the logical model.

The first step is to retrieve the file (org.eclipse.core.resources.IFile) corresponding to the editor.

In case of a selected model in the Package Explorer View

In this case, we have to compute the logical model.

The first step is to retrieve the file (org.eclipse.core.resources.IFile) corresponding to the selection.

Compute the logical model

IFiles are IResources. We can create org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement from IResources. LocalResourceTypedElement implements ITypedElement.

An org.eclipse.emf.compare.ide.ui.internal.logical.ComparisonScopeBuilder (org.eclipse.emf.compare.scope.IComparisonScope) has to be created with :

ComparisonScopeBuilder.create(ICompareContainer container, ITypedElement left, ITypedElement right, ITypedElement origin, IProgressMonitor monitor);

Then with this IComparisonScope, the methods Notifier getLeft(), Notifier getRight, and Notifier getOrigin() allow to retrieve ResourceSets that contains the IResource we want to display in the View.

How to display the result of the logical model as a flat view / trees ?

The Common Navigator Framework (CNF) seems to be the appropriate way to display elements in the viewer. The CNF uses the idea of Navigator Content Extensions (NCE) which can refer to a content provider, a label provider and a contextual menu. The Package Explorer View uses the CNF. It will allow us to reuse the label provider and the contextual menu of the Package Explorer View.

More links:

Back to the top