Search code examples
eclipseeclipse-plugineclipse-rcpeclipse-cdt

How to make eclipse cdt UI Blocking code run in background and show the result in an editor after finishing the run?


In Eclipse CDT at DefaultBinaryFileEditor class, in the method getStorage there is a comment that tells the line objdump.getOutput(limitBytes) is a UI blocking call...

How can I make it run in background without UI Blocking to process longer files than it is stated with parameter int limitBytes = 6*1024*1024;

I can access org.eclipse.cdt.utils.Objdump class' getOutput method via plugin.xml extension point "org.eclipse.cdt.core.BinaryParser"...

I tried to replace the class that is used in extension point "org.eclipse.ui.editors" in editor tag with id "org.eclipse.cdt.ui.binaryEditor" via my plugin.xml, but this did not worked.


Solution

  • I put a boolean flag to outer class and in inner class BinaryFileEditorInput in method getStorage I put a Job and before this job works I created an empty fStorage = new FileStorage. I return this empty fstorage. So first the editor gets blank. Then when the objdump.getOutput(limitBytes) method returns in job, I set the fStorage to the returned output. I simply call the outer class'es refresh method. I put a reference of created outer class to inner static class in outerclasses constructor. This way I can access the refresh method. Also I moved fStorage varible to outerclass because refresh method triggers creating a new inner class so it overrides the valuable fStorage variable.

    Finally If you want to update the opened elf file editor when you build the project again, assign the boolean variable and fStorage to first values in method resourceChanged before calling refresh method.