Bug 427871 - Replace the IChangeListener installed in DDiagramEditorImpl by a more efficient mechanism
Summary: Replace the IChangeListener installed in DDiagramEditorImpl by a more efficie...
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 1.0.0M5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0.0   Edit
Assignee: Maxime Porhel CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance, triaged
Depends on:
Blocks: 427872 428545 442515
  Show dependency tree
 
Reported: 2014-02-11 04:33 EST by Pierre-Charles David CLA
Modified: 2015-01-26 10:11 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2014-02-11 04:33:57 EST
DDiagramEditorImpl isntalls an IChangeListener on its model in hookGraphicalViewer():

changeListener = ChangeListenerFactory.INSTANCE.getNewChangeListener();
semantic.eAdapters().add(changeListener);

This is a rather costly mechanism (it installs an EMF ContentAdapter on the whole representation), and it is only used by SelectionCommandAppender to detect and auto-select newly-created edit parts after the execution of a tool.

It could probably be replaced by a single post-commit listener to detect newly created DDiagramElements. The part about identifying the corresponding EditParts must happen later, so the post-commit listener should probably store the information about newly created elements, and SelectionCommandAppender should get its list from there instead of from TriggerOperation.run()'s first argument.
Comment 1 Pierre-Charles David CLA 2014-02-19 08:55:35 EST
It would be nice if the "auto-select newly created elements" behavior could be generalized to all dialects (incl. tables and trees). This should be possible using DialectUIServices.setSelection(DialectEditor, List<DRepresentationElement>).
Comment 2 Maxime Porhel CLA 2014-06-24 05:36:52 EDT
As proposed by Pierre-Charles, we could:

- remove the DDiagramEditorImpl.changeListener

- create a post commit listener to detect the creation of new DRepresentationElements, get their parent representation, and call DialectUIServices.setSelection(DialectEditor, List<DRepresentationElement>) ont the corresponding dialect editor. We have several solutions: one post commit listener per opened dialect editor or better I think: one common listener for each session (only one analysis is done for each transaction).

The documentation about how to replace the IChangeListener mecanism will not be created in this bugzilla but during the correction of Bug 427872


Notes: 
- org.eclipse.sirius.ui.business.api.dialect.DialectEditor.getRepresentation() allow to get the representation of a DialectEditor
- org.eclipse.sirius.ui.business.api.session.IEditingSession.getEditors() allows to get the opened editors of a session.
- The post-commit listener could be created org.eclipse.sirius.ui.business.internal.session.EditingSession.initListeners()
Comment 3 Maxime Porhel CLA 2014-06-24 05:53:55 EDT
org.eclipse.sirius.tools.api.ui.IExternalJavaAction2 should at least be deprecated.
Comment 4 Maxime Porhel CLA 2014-07-28 09:24:39 EDT
See 
. https://git.eclipse.org/r/30592 : remove calls to SelectionCommandAppender (diagram only)
. https://git.eclipse.org/r/30593 : creates a post commit listener, which, if the active editor is a DialectEdito, detects its newly created DRepresentationElements, and set the selection in with an ayncExec. The editpart refresh is done by a post commit listener installed by the editor after the agnostic "selector", hence it is triggered after. It calls the refresh of edit parts in a sync exec call, so the selection async runnable is called after.
Comment 5 Maxime Porhel CLA 2014-08-04 10:02:40 EDT
Correct on master by commits b0a17fac77b3864456f7826782b07132886f5683 and 09f1d33be1450eaf456ec5f57eadd6dd74eab2b8
Comment 6 Maxime Porhel CLA 2014-08-13 10:11:01 EDT
See previous comment.

The post commit listener add in this bug now selects newly created DRepresentationElements in the current active dialect editor.
Comment 7 Maxime Porhel CLA 2014-08-27 09:48:44 EDT
The dialect agnostic post commit listener causes performance issues with Tree representations (see Bug 442515).

I reopen this issue as it introduced the SelectCreatedDRepresentationElementsListener mechanism.
I will propose a new patch set to remove the dialect agnostic aspect and make it diagram specific back (the previous SelectionAppender mechanism and its IChangeListener was present only for Diagram representations).

The central and unified selection behavior will be treated in a further issue (See bug 428545 for example). 

And Bug 442515 might be closed (as duplicate ? of the current issue) when the next patch will be accepted and the performance issue corrected.
Comment 8 Maxime Porhel CLA 2014-08-29 05:15:58 EDT
Corrected by commit c5d0071dbffdb6f2bfdc6586d173532d83adb883. See https://git.eclipse.org/r/#/c/32407/ for the corresponding review.

The auto-selection of created elements is only done on DDiagramEditors (as with the previous mechanism with the IChangeListener) but with a post commit listener. 

The mechanism has not been activated on Tree and Table due to observed performance issues (bug 442515).
Comment 9 Pierre-Charles David CLA 2014-10-27 06:51:43 EDT
Available in Sirius 2.0.0.