Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » NullPointerException when dragging tab to a new location with custom perspectives
NullPointerException when dragging tab to a new location with custom perspectives [message #1779769] Fri, 12 January 2018 11:06
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() {                
            public void partActivated(IWorkbenchPart part) {
                if (part instanceof MyEditor && MyEditor.isAutomaticPerspectiveChangeEnabled()) {
                    MyEditor editor = (MyEditor) part;
                    try {
                    } catch (WorkbenchException 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 after and the files between would use other perspective, I end up with a 4th tab and a NullPointerException


What causes it and what should I do?


Unhandled event loop exception
at org.eclipse.e4.ui.workbench.addons.dndaddon.DragAgent.dragFinished(
at org.eclipse.e4.ui.workbench.addons.dndaddon.PartDragAgent.dragFinished(
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.finishDrag(
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.startDrag(
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager$1.dragDetected(
at org.eclipse.swt.widgets.TypedListener.handleEvent(
at org.eclipse.swt.widgets.EventTable.sendEvent(
at org.eclipse.swt.widgets.Display.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Display.runDeferredEvents(
at org.eclipse.swt.widgets.Display.readAndDispatch(
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$
at org.eclipse.core.databinding.observable.Realm.runWithDefault(
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(
at org.eclipse.ui.internal.Workbench$
at org.eclipse.core.databinding.observable.Realm.runWithDefault(
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
at org.eclipse.ui.internal.ide.application.IDEApplication.start(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
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(
at org.eclipse.equinox.launcher.Main.basicRun(
at org.eclipse.equinox.launcher.Main.main(
  • Attachment: pic01.png
    (Size: 3.57KB, Downloaded 251 times)
  • Attachment: pic02.png
    (Size: 3.41KB, Downloaded 243 times)
Previous Topic:MacOS and Launching a new Eclipse Application
Next Topic:View generated by wizard crashes
Goto Forum:

Current Time: Thu Oct 06 15:35:16 GMT 2022

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

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

Back to the top