Bug 498773

Summary: NPE on copy Layout Action with Custom Tab-bar from developer documentation
Product: [Modeling] Sirius Reporter: Axel RICHARD <axel.richard>
Component: DiagramAssignee: Project Inbox <sirius.diagram-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: julien.dupont, maxime.porhel, pierre-charles.david
Version: 4.0.0Keywords: triaged
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Sample project to reproduce the issue none

Description Axel RICHARD CLA 2016-07-28 09:55:20 EDT
The copy layout action throws a NullPointerException with the custom tab-bar from https://www.eclipse.org/sirius/doc/developer/extensions-provide_tabbar_extensions.html#contributeFullTabbar
Comment 1 Julien Dupont CLA 2016-07-28 09:59:09 EDT
Hi Axel, 

Could you provide an example to reproduce problem please?

Thanks.

Regards,
Comment 2 Axel RICHARD CLA 2016-07-28 10:03:39 EDT
Julien,

The example is in the documentation.

Regards,
Comment 3 Maxime Porhel CLA 2016-07-28 10:30:14 EDT
See also org.eclipse.sirius.tests.swtbot.tabbar.TabbarContributorExtensionTest

The tests checks that the contribution is effective but the provided actions are not tested (and the path to update them might be different)


For exemple with CopyLayoutAction (CopyFormatAction on master),
* Create a plugin project and setup a tabbar contributor following the documentation (use the provided sample)
* Launch a runtime
* Open any diagram
* Select one or several diagram elements. 
* Clic on the tabbar action 
> the NPE occurs on CopyLayoutAction(DiagramAction).getDiagramCommandStack because getWorkbenchPart() returns null. 

Note that during getCommand(), in debug mode the getDiagramCommandStack() returns the command stack without error
Note that the error does not occur anymore as soon as we comment the extension and relaunch the runtime.



Additional issue: we should also add a sample to rebuild exactly the same tabbar (order, element). The current sample adds the copy layout action for diagram selection and the paste layout action for the diagram element selection, those actions have never been tested in these contexts.
Comment 4 Pierre-Charles David CLA 2018-09-27 04:18:02 EDT
Created attachment 276016 [details]
Sample project to reproduce the issue

Steps to reproduce:
1. Import the attached project
2. Launch a runtime
3. Create a Sirius diagram
4. Select an element on the diagram: the tabbar contributor should be taken into account and produce a tabbar with a single "Copy Format" action.
5. Click on the action in the tabbar => an error dialog opens indicating an NPE.
6. Set the focus in the Model Explorer view and then back into the diagram
7. Re-click on the action in the tabbar: the error does not occur anymore. The action has no user-visible effect, but in the debugger it's possible to confirm the underlying command is indeed executed.