Hey Guys,
There are some really cool features provided in the Compare editors and I was trying to use it in my tool. For most part they work fine but when the Compare Editor(compares Java files) is selected for the first time it throws a Null Pointer Exception.
In my implementation the Compare Editor along with a GEF editor resides inside a MultiPageEditor created using the MultiPageEditorPart.
But a null pointer exception is thrown the first time I click inside the Compare Editor. The exception happens in the code shown below where we try "getEditorSite().getActionBarContributor()" in the AbstractTextEditor Class. From what I understand the embedded editors dont need their individual implementation of EditorActionBarContributor and only the parent MultiPageEditor has an implementation of the contributor.
The code below explicitly needs the contributor. Is there something I am not doing correctly or is there a way to bypass this.
private void setActionActivation(boolean state) {
if (state) {
.........
.........
getEditorSite().getActionBarContributor().setActiveEditor(th is);
} else {
getEditorSite().getActionBarContributor().setActiveEditor(nu ll);
............
}
}
Root exception:
java.lang.NullPointerException
at org.eclipse.ui.texteditor.AbstractTextEditor.setActionActiva tion(AbstractTextEditor.java:5096)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setActions Activated(JavaEditor.java:2816)
at org.eclipse.jdt.internal.ui.compare.JavaMergeViewer$Compilat ionUnitEditorAdapter.setActionsActivated(JavaMergeViewer.jav a:593)
at org.eclipse.jdt.internal.ui.compare.JavaMergeViewer.setActio nsActivated(JavaMergeViewer.java:503)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$31.ru n(TextMergeViewer.java:2599)
at org.eclipse.compare.internal.CompareHandlerService.updatePan eActionHandlers(CompareHandlerService.java:150)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.conne ctContributedActions(TextMergeViewer.java:2596)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.setAc tiveViewer(TextMergeViewer.java:2507)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.acces s$59(TextMergeViewer.java:2506)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$27.fo cusLost(TextMergeViewer.java:2474)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:143)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1379)
at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java: 2963)
at org.eclipse.swt.widgets.Canvas.sendFocusEvent(Canvas.java:62 )
at org.eclipse.swt.widgets.Display.checkFocus(Display.java:617)
at org.eclipse.swt.widgets.Display.applicationDidResignActive(D isplay.java:4481)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java :4682)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationSendEvent(Display .java:4589)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java :4666)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApp lication.java:115)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3281)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
[Updated on: Thu, 05 May 2011 17:10]
Report message to a moderator