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

Bug 552839

Summary: Deleting the container of semantic element of a representation do not close the editor
Product: [Modeling] Sirius Reporter: Arthur Daussy <arthur.daussy>
Component: DiagramAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact: Jessy Mallet <jessy.mallet>
Severity: normal    
Priority: P3 CC: jessy.mallet, maxime.porhel
Version: 6.3.0   
Target Milestone: 6.3.1   
Hardware: PC   
OS: Windows 10   
See Also: https://git.eclipse.org/r/152337
https://git.eclipse.org/r/153017
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=be8a21ba0b76db52e9a8ae1915516d5ce57a2b86
https://git.eclipse.org/r/154035
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=8ec1596af6caca26d68bd7e5430c311c11e6d735
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ada6fb823f10da2fef07b6c435d4ef2332315af4
https://git.eclipse.org/r/154416
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=7fad2af245a7082b01ab95007b547f0534459761
Whiteboard:
Bug Depends on:    
Bug Blocks: 553182, 558025, 558026    
Attachments:
Description Flags
ProjectToReproduce
none
Result after deletion
none
NPE1
none
NPE2 none

Description Arthur Daussy CLA 2019-11-08 08:38:20 EST
Created attachment 280570 [details]
ProjectToReproduce

When a "Delete from the model" action ends by deleting the container of the semantic target of the current opened editor representation, the session seems broken. Here are the list of the following symptoms:

* The editor is still open
* There is no * inidcating that the session is dirty
* The semantic elements are removed but the representation descriptor remains (see screenshot)
* Moving elements in the opened editor ends up with:

Caused by: java.lang.NullPointerException
	at org.eclipse.emf.transaction.RecordingCommand.getActiveTransaction(RecordingCommand.java:250)

The expected behavior would be:

* The editor should be closed
* The representation should be properly deleted
* The semantic elements should be properly deleted

To reproduce:

* Import "org.eclipse.sirius.sample.ecore.design"
* Launch a runtime
* Import the provided project (see attachment)
* Open the unique diagram
* In the opened editor select the package "P1_1_1" and use the action "Delete from model"
Comment 1 Arthur Daussy CLA 2019-11-08 08:39:41 EST
Created attachment 280571 [details]
Result after deletion
Comment 2 Arthur Daussy CLA 2019-11-08 09:14:48 EST
This bug is also true if the deletion occurs from the aird editor.
Comment 3 Eclipse Genie CLA 2019-11-08 10:35:48 EST
New Gerrit change created: https://git.eclipse.org/r/152337
Comment 4 Arthur Daussy CLA 2019-11-19 06:08:53 EST
In pure Sirius environment (no team), it appears that the symptoms are slightly differents.

In that case, after the deletion the editor is closed and the semantics element are deleted. However it raises 2 NPE 

------------------------------
java.lang.NullPointerException
	at org.eclipse.sirius.diagram.business.api.query.ToolSectionQuery.getOperationActions(ToolSectionQuery.java:83)
-------------------------------

and 

-------------------------------
java.lang.NullPointerException
	at org.eclipse.sirius.diagram.business.api.query.ToolSectionQuery.getOperationActions(ToolSectionQuery.java:83)
-------------------------------
Comment 5 Arthur Daussy CLA 2019-11-19 06:09:43 EST
This behavior is not reproduce when the step to reproduce are written in JUnit plugin test
Comment 6 Arthur Daussy CLA 2019-11-19 06:10:02 EST
Created attachment 280697 [details]
NPE1
Comment 7 Arthur Daussy CLA 2019-11-19 06:10:20 EST
Created attachment 280698 [details]
NPE2
Comment 8 Eclipse Genie CLA 2019-11-20 03:13:01 EST
New Gerrit change created: https://git.eclipse.org/r/153017
Comment 9 Arthur Daussy CLA 2019-11-20 03:18:34 EST
After investigation it appears that the 2 problems coexist. The same manipulation has a different outcome depending on the bundles available in the platform. In pure Sirius environment only the NPE appears. If the running platform has extra plugins such as (Collab or CDO native plugins) the first problem appears. 

A possible expplaination is that the order of registration of the ResourceSet listeners differs in the 2 cases. As such the way the target feature of the DRepresenationDescriptor is unset differs. In one case it is removed by unsetting the feature whereas in the other the feature is set to null. In order to handle both case, the 2 events sould be catched to close the editor.

See:

https://git.eclipse.org/r/153017 [552839] Catch new events to close the opened editor on deletion
Comment 11 Eclipse Genie CLA 2019-12-06 13:20:35 EST
New Gerrit change created: https://git.eclipse.org/r/154035
Comment 14 Eclipse Genie CLA 2019-12-12 09:13:23 EST
New Gerrit change created: https://git.eclipse.org/r/154416
Comment 16 Jessy Mallet CLA 2020-03-31 05:00:15 EDT
Validated with Sirius 6.3.1.202003201424
Comment 17 Pierre-Charles David CLA 2020-06-19 10:22:29 EDT
Available in Sirius 6.3.1 (part of Eclipse 2020-06). See https://wiki.eclipse.org/Sirius/6.3.1 for details on the release.