NoteEditPart unregisteredVisuals() error

Started by Whinard, July 31, 2017, 08:31:51 AM

Previous topic - Next topic

Whinard

Hello,

I am creating a DiagramModelNote to display information in the view. I am creating it via:
note = IArchimateFactory.eINSTANCE.createDiagramModelNote();

I am then changing some information about the note then adding it to the view
*dmac is a DiagramModelConnection that the note will be positioned next to*

note.setContent(split[1] + "%");
note.setName(split[0]);
note.setFillColor("#bbbbbb");
note.setBorderType(2);
note.setAdapter(null, dmac);
dmac.getDiagramModel().getChildren().add(note);


But, when I try to move this note into a group by clicking and dragging it in the view, I recieve a NullPointerException
Here is the stack trace

!ENTRY org.eclipse.ui 4 0 2017-07-31 09:19:57.533
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.unregisterVisuals(AbstractGraphicalEditPart.java:938)
at org.eclipse.gef.editparts.AbstractEditPart.unregister(AbstractEditPart.java:1163)
at org.eclipse.gef.editparts.AbstractEditPart.removeNotify(AbstractEditPart.java:949)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNotify(AbstractGraphicalEditPart.java:823)
at org.eclipse.gef.editparts.AbstractEditPart.removeChild(AbstractEditPart.java:880)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:793)
at com.archimatetool.editor.diagram.editparts.AbstractDiagramPart.eCoreChanged(AbstractDiagramPart.java:83)
at com.archimatetool.editor.diagram.editparts.ArchimateDiagramPart.eCoreChanged(ArchimateDiagramPart.java:52)
at com.archimatetool.editor.diagram.editparts.AbstractDiagramPart$1.notifyChanged(AbstractDiagramPart.java:56)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.remove(NotifyingListImpl.java:713)
at org.eclipse.emf.common.util.AbstractEList.remove(AbstractEList.java:462)
at com.archimatetool.editor.diagram.policies.BasicContainerEditPolicy$RemoveObjectCommand.execute(BasicContainerEditPolicy.java:72)
at org.eclipse.gef.commands.CompoundCommand.execute(CompoundCommand.java:129)
at org.eclipse.gef.commands.CompoundCommand.execute(CompoundCommand.java:129)
at org.eclipse.gef.commands.CommandStack.execute(CommandStack.java:228)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
at org.eclipse.gef.tools.DragEditPartsTracker.performDrag(DragEditPartsTracker.java:538)
at org.eclipse.gef.tools.DragEditPartsTracker.handleButtonUp(DragEditPartsTracker.java:393)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1200)
at org.eclipse.gef.tools.SelectionTool.mouseUp(SelectionTool.java:574)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:301)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:380)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:548)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:221)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at com.archimatetool.editor.Application.start(Application.java:87)
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:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
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:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)


Any help as to why this is happening is appreciated.

Billy


Phil Beauvoir

Have you given the Note some Bounds?

note.setBounds(bounds);
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Whinard

Yes, sorry, I must have left that out of my post.

note.setBounds(findLocationX(((IDiagramModelObject) dmac.getSource()), ((IDiagramModelObject) dmac.getTarget())), findLocationY(((IDiagramModelObject) dmac.getSource()), ((IDiagramModelObject) dmac.getTarget())), NOTE_CONNECTION_WIDTH, NOTE_CONNECTION_HEIGHT);

Phil Beauvoir

I'd put a breakpoint at that line and find out what is null. It will either be the getViewer() part or the getVisualPartMap() part of that line. This may provide a clue.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Whinard

Thank you,

I have determined that it is getVisualPartMap(), now time to figure out why it is null

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Whinard

I have a class called PriceLabel that contains the information of one of the notes that I am creating. Within this class is a method called makeLabel that initializes the note and adds it to the view as shown above.