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

Bug 435363

Summary: DeleteFromDiagram menu is no more available for Notes and Text
Product: [Modeling] Sirius Reporter: Maxime Porhel <maxime.porhel>
Component: DiagramAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: pierre-charles.david
Version: 1.0.0Keywords: triaged
Target Milestone: 2.0.0   
Hardware: PC   
OS: Windows NT   
Whiteboard:
Attachments:
Description Flags
Contextual menu (before)
none
Contextual menu (after first step) none

Description Maxime Porhel CLA 2014-05-21 04:25:28 EDT
Open a Sirius diagram
Create a Note and a Text
The contextual menu action edit/Delete from diagram is no more available on Note and Text. 

It is a regression introduced by commit 0d56d070231a34d8796921ac63d3b392c08e0601 in Bug 434474. It was done to avoid to provide the Sirius Delete from model action to other GMF editors like Papyrus. 

We restricted the contribution to ISiriusEditParts, but in a Sirius Diagram editor, we should provide it for NoteEditPart and TextEditPart too. 

We should change this "org.eclipse.sirius.diagram.ui.edit.parts.ViewNodeEditPartMenu" org.eclipse.ui.popupMenus extension into a org.eclipse.ui.menu extension. It will allow to define a proper visibleWhen expression (or try to provide the action to the Sirius diagram editor context menu only with the id org.eclipse.sirius.diagram.ui.popup).
Comment 1 Maxime Porhel CLA 2014-05-22 04:00:55 EDT
See https://git.eclipse.org/r/27081 

First step: it changes the path of copyLayoutAction and pasteLayoutAction which are put in the copyGroup of the contextual menu whereas a copyLayoutGroup has been created. It also creates a deleteFromGroup to place the DeleteFromDiagram and DeleteFromMode actions: DeleteFromDiagram was previously added before the copy layout group (the separator between both delete from actions).
Comment 2 Maxime Porhel CLA 2014-05-22 04:02:19 EDT
Created attachment 243379 [details]
Contextual menu (before)
Comment 3 Maxime Porhel CLA 2014-05-22 04:29:56 EDT
For the next step, I have to provide the DeleteFromDiagram action to Note/TextEditPart in Sirius only. 

For that, we could use org.eclipse.ui.menus or org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders. 

A first try with org.eclipse.ui.menus shows some ClassCastException in the GMF EditMenu ActionMenuManager which does not handle the e4 HandledActionManager. See Bug . 

A second try with org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders allows to place the delete from diagram action at the right place, but I do not have the accelerator  in the label yet and the enablement is not updated. I am trying to change the action implementation to get these elements. 

While it is not corrected, the delete from diagram is not available/displayed for Note/TextEditParts but it is available from the tabbar. Furthermore, since Bug 433474, the Sirius delete from diagram si no more displayed on non Sirius diagram editors.
Comment 4 Maxime Porhel CLA 2014-05-22 04:30:19 EDT
Created attachment 243380 [details]
Contextual menu (after first step)
Comment 5 Maxime Porhel CLA 2014-05-22 09:38:27 EDT
Note that 
 . DeleteFromModel should be deactivated for NoteAttachment
 . DeleteFromDiagram should work on NoteAttchament. 
If these problems are not side effect of the menus declarations, new bugzilla issues will be created later.
Comment 6 Pierre-Charles David CLA 2014-05-27 10:24:05 EDT
Moving to 2.0.0. Not critical enough to do this this close to the 1.0.0 release. Note that it is still possible to delete the notes and text elements using the actions from the tabbar.
Comment 7 Pierre-Charles David CLA 2014-06-05 11:15:59 EDT
When we fix this, we should remember the re-enable the corresponding automated tests.
Comment 8 Maxime Porhel CLA 2014-08-07 11:03:21 EDT
See https://git.eclipse.org/r/31204

This commit removes the default deleteFromDiagram only for the ISiriusEditPart 
and for other parts (Note, Text, NoteAttachment it moves the default 
DeleteFromDiagram action to the edit>deleteGroup. The keyboard shortcut is not 
displayed as it not the same action, but it works. 
Another solution could be to create our own SiriusNote/Text/NoteAttachment 
editpart, created from our edit part provider, exending the GMF parts but with 
the inheritance to ISiriusEditPart to get the Sirius deleteFromDiagram menu. 
But there could be other impacts in the code.
Comment 9 Maxime Porhel CLA 2014-08-07 12:53:55 EDT
I have retried with org.eclipse.ui.menus, but this time I get something weird: I would like to use the visibleWhen with the activeEditorId and the ActiveSelection, but it is never displayed, and without visibleWhen, when I tried to correclty define the location of my menu (in the editMenu after the deleteFromGroup separator and before the deleteFromModel action), the MUIMenu seems well constructed but my delete from diagram appears after the deleteFromModel action. 

I propose to take the menu without accelerator displayed and to open another bug to get the accelerator back and to review the deleteFromModel and deleteFromDiagral action declarations.
Comment 10 Maxime Porhel CLA 2014-08-07 13:33:08 EDT
The menu is added and not inserted at its index because HandledMenuItemImpl.getParent() currently returns null in org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer l.619:
 
> MElementContainer<MUIElement> parent = model.getParent();
>  // technically this shouldn't happen
>  if (parent == null) {
>  parentManager.add(menuManager);

Looking in debug, eContainer is not null and the menu item seems to be well contained in the "children" feature but UIElementImpl.getParent return null.
Comment 11 Maxime Porhel CLA 2014-09-19 04:12:15 EDT
https://git.eclipse.org/r/31204 has bene accepted and merged in commit b60c11419cef88bb52889bdde7f2b149e81641ed


(In reply to Maxime Porhel from comment #8)
> See https://git.eclipse.org/r/31204
> 
> This commit removes the default deleteFromDiagram only for the
> ISiriusEditPart 
> and for other parts (Note, Text, NoteAttachment it moves the default 
> DeleteFromDiagram action to the edit>deleteGroup. The keyboard shortcut is
> not 
> displayed as it not the same action, but it works. 
> Another solution could be to create our own SiriusNote/Text/NoteAttachment 
> editpart, created from our edit part provider, exending the GMF parts but
> with 
> the inheritance to ISiriusEditPart to get the Sirius deleteFromDiagram menu. 
> But there could be other impacts in the code.
Comment 12 Maxime Porhel CLA 2014-09-23 04:44:36 EDT
The issue is corrected on Sirius. The DeleteFromDiagram menu is now available for Notes and Text. 

A nwe bug will be created to deal with the potential e4 bug.
Comment 13 Pierre-Charles David CLA 2014-10-27 06:51:31 EDT
Available in Sirius 2.0.0.