Question

I am creating my own GEF based graphical editor. It creates error markers when validation fails and the editor has a gotoMarker method to find and active the marker. This all works.

Only problem is that I get a RuntimeException when double clicking on the marker (when clicking 'GoTo' from the context menu there is no problem) The message is as follows:

java.lang.RuntimeException: WARNING: Prevented recursive attempt to activate part org.eclipse.ui.views.ProblemView while still in the middle of activating part namespace.myEditorID`

Part of the corresponding stacktrace shows:

at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3586)
...
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1245)
at org.eclipse.swt.internal.gtk.OS._gtk_enumerate_printers(Native Method)
at org.eclipse.swt.internal.gtk.OS.gtk_enumerate_printers(OS.java:9296)
at org.eclipse.swt.printing.Printer.getPrinterList(Printer.java:98)
at org.eclipse.gef.ui.actions.PrintAction.calculateEnabled(PrintAction.java:45)
at org.eclipse.gef.ui.actions.WorkbenchPartAction.isEnabled(WorkbenchPartAction.java:123)
...

The complete stacktrace is a bit long, so it is available at pastebin.

This gave me the idea to disable the printing action in ActionBarContributor.declareGlobalActionKeys by removing:

addGlobalActionKey(ActionFactory.PRINT.getId());

This solves the RuntimeException...?!

I do not see the relation between the Printing action and going to the corresponding object after clicking on a marker. Leaving the Printing action disabled, of course, is not a solution.

So what can I do to keep the Printing action available and prevent these RuntimeExceptions?

Was it helpful?

Solution

As a test ,I refer to the url:https://bugs.eclipse.org/bugs/show_bug.cgi?id=154112 and I overrid my EditorPart's setFocus method like:

@Override
public void setFocus() {
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus();
}

and then it works well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top