Community
Participate
Working Groups
Right-clicking on diagram nodes in my editor will through NPE here: java.lang.NullPointerException at org.eclipse.sapphire.ui.swt.graphiti.editor.SapphireDiagramEditorContextMenuProvider.buildContextMenu(SapphireDiagramEditorContextMenuProvider.java:51) at org.eclipse.gef.ContextMenuProvider.menuAboutToShow(ContextMenuProvider.java:63) at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:338) at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469) at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:465) at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:491) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:241)
I looked a bit more and noticed that when I click on the different nodes the selectionChanged in the SapphireDiagramEditor it not working as I think it was intended. line 178 of SapphireDiagramEditor shows this: if (activeEditor instanceof MultiPageEditorPart) { int activePage = ((MultiPageEditorPart) activeEditor).getActivePage(); if (activePage != 0) { // Editor is active but the diagram sub editor is not // its active page editorIsActive = false; } } In my case (diagram editor is the 2nd page, so activePage will always == 1) the editorIsActive is set to false and so the selection is never selectionParts set and will stay null.
Here is what I have replaced in my workspace and it works as epxected and re-enables the context menu (no NPEs): if ( activeEditor instanceof FormEditor ) { if ( !( this.equals( ( (FormEditor) activeEditor ).getActiveEditor() ) ) ) {
Greg, I've tried out your code snippet and it seemed to work for me (In my editor diagram is the first page). I've checked your code in. Thanks!
The stack trace is no longer applicable. I have submitted Greg's code snippet which should work for the case where the diagram editor is not the first page of a multipage editor.
Verified with latest build.
Closing.