Bug 511036 - NullPointerException for label edit on mappings with no Label Expression
Summary: NullPointerException for label edit on mappings with no Label Expression
Status: CLOSED INVALID
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 4.1.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-01-25 10:02 EST by Axel RICHARD CLA
Modified: 2017-03-22 06:21 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel RICHARD CLA 2017-01-25 10:02:01 EST
The origin problem has been raised here : https://github.com/ObeoNetwork/UML-Designer/issues/665

When clicking two times on a relationship a java null pointer appear in console in debug mode.
Steps:

With UML Designer 7, in a class diagram create Two classes and a Generalization between classes.
click on the generalization a first time to select it.
click a second time on the same element. (as if we try to direct edit the element)
the same error seems to appear for all connection without label expression (interface realization, ...)
Stack trace:

!ENTRY org.eclipse.ui 4 0 2015-05-5 14:13:18.587
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart.performDirectEdit(AbstractGeneratedDiagramNameEditPart.java:279)
at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart$2.run(AbstractGeneratedDiagramNameEditPart.java:310)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart.performDirectEditRequest(AbstractGeneratedDiagramNameEditPart.java:301)
at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNameEditPart.performRequest(AbstractDiagramNameEditPart.java:288)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.performDirectEditRequest(ConnectionEditPart.java:1500)
at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart.performRequest(AbstractDiagramEdgeEditPart.java:868)
at org.eclipse.gef.tools.DelayedDirectEditHelper.run(DelayedDirectEditHelper.java:108)
at org.eclipse.swt.widgets.Display.runTimer(Display.java:4273)
at org.eclipse.swt.widgets.Display.messageProc(Display.java:3360)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Axel RICHARD CLA 2017-01-25 10:03:08 EST
A possible workaround is to create a specific Direct Edit Tool for these mappings. This specific DirectEditTool do nothing.
Comment 2 Steve Monnier CLA 2017-03-10 09:25:19 EST
Hello Axel,

Can you provide a sample? I created a quick sample but have not been able to reproduce the exception.

Regards,
Steve
Comment 3 Pierre-Charles David CLA 2017-03-22 04:57:13 EDT
Reproduced using UML Designer 7.1.0. The line numbers in the stack are a little different:

java.lang.NullPointerException
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart.performDirectEdit(AbstractGeneratedDiagramNameEditPart.java:306)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart$2.run(AbstractGeneratedDiagramNameEditPart.java:339)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart.performDirectEditRequest(AbstractGeneratedDiagramNameEditPart.java:329)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNameEditPart.performRequest(AbstractDiagramNameEditPart.java:233)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.performDirectEditRequest(ConnectionEditPart.java:1500)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart.performRequest(AbstractDiagramEdgeEditPart.java:751)

The code in question is:

    protected void performDirectEdit() {
        getManager().show();
    }

so in this situation getManager() returns null. Its code is:

    protected DirectEditManager getManager() {
        if (manager == null) {
            setManager(new TextDirectEditManager(this, SiriusEditPartFactory.getTextCellEditorClass(this), SiriusEditPartFactory.getTextCellEditorLocator(this)));
        }
        return manager;
    }

but setManager() is overridden in AbstractDEdgeNameEditPart in a way that allows it to ignore the manager and not actually set the "this.manager" field if direct-edit is seen as not available.
Comment 4 Pierre-Charles David CLA 2017-03-22 05:10:21 EDT
Like Steve, I can't reproduce it in plain Sirius on a simple test case (at least on master). Either is was fixed since then, or we need a more complex example to match the UML Designer case closer.
Comment 5 Pierre-Charles David CLA 2017-03-22 05:38:23 EDT
Can't reproduce on UML Designer master (49a05acfecb2ed9c62ee6796e57312bcc8ec29e4) with Sirius master (fd45868c116805919c041bdc2e099cdc9b3fde35).
Comment 6 Pierre-Charles David CLA 2017-03-22 06:19:18 EDT
It seems the problem is that UML Designer explicitly overrides the isDirectEditEnabled() method for these parts to always return true: https://github.com/ObeoNetwork/UML-Designer/blob/master/plugins/org.obeonetwork.dsl.uml2.design/src/org/obeonetwork/dsl/uml2/design/internal/editpart/UMLEditPartProvider.java#L174

When testing in plain Sirius, we never go as far as AbstractGeneratedDiagramNameEditPart.performDirectEdit: in AbstractDiagramEdgeEditPart.performRequest we test for isDirectEditEnabled, and return false in this case. UML Designer's override forces the code to continue even though we shouldn't.

The fix seems to be to remove the isDirectEditEnabled() override in the case of DEdgeNameEditPart. It may be necessary for begin/end label parts (even though a direct "return true" possibly also makes them subject to this bug), but I don't think it is for the "standard"/center label on an edge.

Feel free to reopen if you can find a reproduction case in plain Sirius, but as it is the issue (and the fix) seem to be on the UML Designer side.
Comment 7 Axel RICHARD CLA 2017-03-22 06:21:31 EDT
Ok thank you very much Pierre-Charles for the investigation.