Re: [Pydev-code] Writing to the Eclipse status area from a Jython Pydev extension
Brought to you by:
fabioz
From: Fabio Z. <fa...@gm...> - 2006-05-20 15:44:07
|
Hi Don, On 5/19/06, Don Taylor <nos...@gm...> wrote: > > > When I run your code outside the action listener then it works, but when > it is inside the action listeners run() then it does not display anything= . > Well, the problem is that you need to run it from an UI-thread. The code below shows a helper to do it: if cmd =3D=3D 'onCreateActions': from org.eclipse.jface.action import Action from org.python.pydev.core.docutils import PySelection from org.eclipse.ui.texteditor import IEditorStatusLine from org.eclipse.swt.widgets import Display from java.lang import Runnable #------------------------------------------------ HELPER TO RUN THINGS IN THE UI class RunInUi(Runnable): '''Helper class that implements a Runnable (just so that we can pass it to the Java side). It simply calls some callable. ''' def __init__(self, c): self.callable =3D c def run(self): self.callable() def runInUi(callable): ''' @param callable: the callable that will be run in the UI ''' Display.getDefault().asyncExec(RunInUi(callable)) #------------------------------------------------ END HELPER TO RUN THINGS IN THE UI class ExampleCommand3(Action): def run(self): def callable(): statusLine =3D editor.getAdapter(IEditorStatusLine) if statusLine is not None: statusLine.setMessage(True, "foo", None) runInUi(callable) editor.addOfflineActionListener("e", ExampleCommand3(), 'Example on how to bind script action', False) |