Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » NullPointerException when dragging tab to a new location with custom perspectives
NullPointerException when dragging tab to a new location with custom perspectives [message #1779771] Fri, 12 January 2018 11:36
Márk Mátray is currently offline Márk MátrayFriend
Messages: 2
Registered: January 2018
Junior Member
I made an IPartListener so when I change between different file types I can change perspective automatically. But when I drag an editor tab to a new location, it iterates over the other tabs it crossed. Now I think because of this, the editors getting activated and eclipse wants to change perspectives too fast. And I get a new tab added named: Drag Placerholder which is an ErrorViewPart. My code:

 PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        workbenchWindow.getPartService().addPartListener(new IPartListener() {                
            @Override
            public void partActivated(IWorkbenchPart part) {
                if (part instanceof MyEditor && MyEditor.isAutomaticPerspectiveChangeEnabled()) {
                    MyEditor editor = (MyEditor) part;
                    try {
                        editor.changePerspective();
                    } catch (WorkbenchException e) {
                        ErrorHandler.handleUnexpectedError(e);
                    }
                } 
            }
        }
 }


I tried it with IPartListener2's Visible/Activated method too, and making the method synchronized, same thing happens. The changePerspective method checks if the perspective is other than the one given for the editor, if it is then changes the perspective like so:

IWorkbench workbench = PlatformUI.getWorkbench();
workbench.showPerspective(someID, workbench.getActiveWorkbenchWindow());


I attached some pics, if I drag file1.abc after file3.xyz and the files between would use other perspective, I end up with a 4th tab and a NullPointerException

index.php/fa/31787/0/
index.php/fa/31788/0/

What causes it and what should I do?

Stacktrace:

Unhandled event loop exception
java.lang.NullPointerException
at org.eclipse.e4.ui.workbench.addons.dndaddon.DragAgent.dragFinished(DragAgent.java:171)
at org.eclipse.e4.ui.workbench.addons.dndaddon.PartDragAgent.dragFinished(PartDragAgent.java:93)
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.finishDrag(DnDManager.java:285)
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.startDrag(DnDManager.java:252)
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager$1.dragDetected(DnDManager.java:89)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:128)
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 org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
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)
  • Attachment: pic01.png
    (Size: 3.57KB, Downloaded 141 times)
  • Attachment: pic02.png
    (Size: 3.41KB, Downloaded 116 times)
Previous Topic:Error Dialog Box
Next Topic:mvn install failing due to dependency com.sun:tools:jar:1.8.0
Goto Forum:
  


Current Time: Sat Oct 20 00:56:11 GMT 2018

Powered by FUDForum. Page generated in 0.02763 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top