Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 460610

Summary: Have a bidirectional Link With Editor
Product: [Modeling] Sirius Reporter: Maxime Porhel <maxime.porhel>
Component: CoreAssignee: Florian Barbin <florian.barbin>
Status: CLOSED FIXED QA Contact: Maxime Porhel <maxime.porhel>
Severity: enhancement    
Priority: P1 CC: etienne.juliot, florian.barbin, frederic.madiot, laurent.fasani, laurent.redor, pierre-charles.david
Version: 2.0.0Keywords: triaged
Target Milestone: 3.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/52492
https://git.eclipse.org/r/52614
https://git.eclipse.org/r/52805
https://git.eclipse.org/r/53246
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=8e2f39d01c8dc08b4c986a795a969c739e370951
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=b072e3d4be8077b2934fd74ee1fb0932d4501b88
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=bf04a73d6efa05ddc069c6e518b3331f69dda132
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d9bfff3b9751c874ef604a6013b18d0478c055d7
https://git.eclipse.org/r/53856
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=c53b0f75fcca110f7f0e1e54d0e4eff446c8153d
https://git.eclipse.org/r/53883
https://git.eclipse.org/r/54319
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=99d08188a34dd5269fca743074d293938195d3e2
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=3e5fe2d5f3a1cba05c084490c9f43a4c62dbec15
https://git.eclipse.org/r/54864
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=5f9a6586707fa1a349c9494bb7da9628652007a0
https://git.eclipse.org/r/55064
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=7762524a2c12eeb95d7a8c34df474bfb3793a2e0
Whiteboard:

Description Maxime Porhel CLA 2015-02-23 10:43:44 EST
The main idea of this bugzilla is to make the link with editor bi-directional in Sirius: when a DRepresentationElement/DRepresentation is selected in a Sirius editor (Diagram, Tree or Table), if the link editor is active, the corresponding semantic element should be selected in the model explorer view. The semantic element is the DSemanticDecorator.getTarget() result.

Current behavior: 
 . Selection of an element in the explorer:
     . semantic element -> selection of the corresponding element in the active representation (if existent).
     . representation node -> set focus to the corresponding editor
 . Selection of an element in a representation -> no selection change in explorer
 . Set focus on the editor -> focus and selection of the representation node in the explorer


If the semantic element is not visible in the model explorer, we should expand the tree to make it visible. If the model element is expanded but not visible, we should scroll to make it visible (this should already be handled by the CNF).



Additional question: When the user select an element in the model explorer view and if there is no selection target in the active no selection, should we have the same behavior than JDT : try to find another opened dialect editor which know the selection, activate it and then set the selection ?


Note: the link with editor support is implemented in org.eclipse.sirius.ui.tools.internal.views.common.navigator.SessionLinkHelper


Note: it seems that when the user selects a semantic element in the model explorer, the the corresponding DDiagramElement (for example) is selected, but when the user sets the focus on the editor, the propertyies view still displays the previous selection of the editor. The problem might needs to have its own bugzilla (choice will be made during analysis of this ticket or during implementation).
Comment 1 Maxime Porhel CLA 2015-02-23 10:59:18 EST
The Link with editor support works with the ILinkHelper interface.
See https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/ILinkHelper.java or http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fui%2Fnavigator%2FILinkHelper.html

The findSelection method is called only when the user activate an editor by clicking on the corresponding tab.
The activateEditor method is called when the user clic on an element in a CommonViewer with active Link with editor support.


The feature we want looks like the outline behavior: in a diagram editor powered by Sirius, the outline can display the overview of the diagram or a tree which shows semantic element displayed on the diagram regarding the diagram structure (and not the model structure). The selection synchronization between editor and outline is bi-directional.


So we want to extends the behavior of the link with editor: 
 . The new behavior must be active only when the link with editor is active
 . It has to handle the cases not supported by the ILinkHelper and must not react to the basic/standard ILinkHelper cases
   . When the focus is set to a new editor: let the link with editor works.
   . When changing the selection in the active editor
      . selection of the editor (diagram background) -> selection of the diagram/tree/table node in the model browser (placed under the semantic element which holds the representation)
      . selection of an element in the representation -> selection of the corresponding semantic element in the model browser
      . we have to pay attention to selections loops: when the selection in the model explorer comes from the synchronization from editor selection, the link with editor must not react !
Comment 2 Maxime Porhel CLA 2015-07-24 05:36:19 EDT
Initial ideas: 
. " When the user uses the "link with Editor" button and select a shape, the semantic model should expand itself and focus on the selected object."

The choice was made to synchronize the selection between an opened dialect editor and the model explorer.
. The actual behavior is consistent for the view to editor direction.
 . The editor to view behavior should be :
   . when selecting the editor -> selection of the diagram in the model browser (placed under the semantic element which holds the diagram)
   . when selecting an element in the representation -> selection of the model element in the model browser
Comment 3 Eclipse Genie CLA 2015-07-24 09:16:07 EDT
New Gerrit change created: https://git.eclipse.org/r/52492
Comment 4 Eclipse Genie CLA 2015-07-27 10:55:59 EDT
New Gerrit change created: https://git.eclipse.org/r/52614
Comment 5 Eclipse Genie CLA 2015-07-29 11:03:30 EDT
New Gerrit change created: https://git.eclipse.org/r/52805
Comment 6 Eclipse Genie CLA 2015-08-05 11:12:23 EDT
New Gerrit change created: https://git.eclipse.org/r/53246
Comment 11 Laurent Redor CLA 2015-08-14 03:24:41 EDT
All corresponding commits have been pushed.
Comment 12 Laurent Redor CLA 2015-08-14 11:35:55 EDT
Here is a bug:
* Open a session with 2 representations
* Activate the "link with editor" in the Model Explorer view
* Open the first representation
* Select something in the representation --> OK: the corresponding element is selected in the Model Explorer view.
* Click on the second representation in the Model Explorer view --> KO: The first representation is automatically selected
Comment 13 Maxime Porhel CLA 2015-08-17 03:49:50 EDT
Here is another bug: 
 . Open new RecurDiag from Bug 472036
 . Select aaaa
 . Select az : both the region and the region container are selected: user has to reclick the element he really wanted to select.
Comment 14 Eclipse Genie CLA 2015-08-17 04:02:46 EDT
New Gerrit change created: https://git.eclipse.org/r/53856
Comment 15 Maxime Porhel CLA 2015-08-17 04:10:03 EDT
The same issue will occurs for diagrams with relative edge mappings whose semantic element is the semantic element of the source.
Comment 17 Eclipse Genie CLA 2015-08-17 09:27:55 EDT
New Gerrit change created: https://git.eclipse.org/r/53883
Comment 20 Frederic Madiot CLA 2015-08-27 04:34:51 EDT
When the user click on an element in the model explorer which can't be selected graphically (for example the type of a EAttribute, or the inheritance between two EClasses) the graphical selection is not updated. 

With this case the selection in the model browser and in the diagram doesn't match. This can be confusing.

When selecting this kind of element in the Model Browser, the current selected elements in the diagram should be deselected.
Comment 22 Eclipse Genie CLA 2015-09-02 04:17:10 EDT
New Gerrit change created: https://git.eclipse.org/r/55064
Comment 24 Laurent Fasani CLA 2015-10-14 05:17:22 EDT
validated
Comment 25 Maxime Porhel CLA 2015-10-14 05:56:55 EDT
Validated on Sirius 3.1.0-S20151008-082237
Comment 26 Pierre-Charles David CLA 2015-10-16 09:12:12 EDT
Available in Sirius 3.1.0.