Thread: [Pydev-code] Writing to the Eclipse status area from a Jython Pydev extension
Brought to you by:
fabioz
From: Don T. <nos...@gm...> - 2006-05-19 16:20:30
|
Fabio: I am trying to write a message to the status area on the bottom of the Eclipse screen, but I can't get it working. This is what I have so far: if cmd == 'onCreateActions': ... from org.eclipse.jface.action import StatusLineManager ... self.statusLine = StatusLineManager() self.statusLine.setMessage("hello") self.statusLine.update(True) Maybe I need to call createControl() but I don't know what to supply as the 'parent' parameter. Any pointers will be appreciated. Don. |
From: Fabio Z. <fa...@gm...> - 2006-05-19 17:08:34
|
Actually, you probably want to ask the status manager to the editor. Something as below (untested): statusLine =3D editor.getAdapter(IEditorStatusLine.class); if statusLine is not None: statusLine.setMessage(False, "foo", None) On 5/19/06, Don Taylor <nos...@gm...> wrote: > > Fabio: > > I am trying to write a message to the status area on the bottom of the > Eclipse screen, but I can't get it working. > > This is what I have so far: > > if cmd =3D=3D 'onCreateActions': > ... > from org.eclipse.jface.action import StatusLineManager > > ... > > self.statusLine =3D StatusLineManager() > self.statusLine.setMessage("hello") > self.statusLine.update(True) > > Maybe I need to call createControl() but I don't know what to supply as > the 'parent' parameter. > > Any pointers will be appreciated. > > Don. > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code > |
From: Don T. <nos...@gm...> - 2006-05-19 18:36:40
|
Fabio Zadrozny wrote: > Actually, you probably want to ask the status manager to the editor. > Something as below (untested): > > statusLine = editor.getAdapter(IEditorStatusLine.class); > if statusLine is not None: > statusLine.setMessage(False, "foo", None) > Fabio: My code looks like this: if cmd == 'onCreateActions': from org.eclipse.jface.action import Action from org.python.pydev.core.docutils import PySelection from org.eclipse.ui.texteditor import IEditorStatusLine #-Paragrapher--------------------------------------------------------------- class Paragrapher: ''' Provides tools to process a paragraph of text in the Pydev editor. ''' def __init__(self): self.selection = PySelection(editor) self.document = editor.getDocument() self.statusLine = editor.getAdapter(IEditorStatusLine) print "statusLine %s" % self.statusLine if self.statusLine is not None: self.statusLine.setMessage(False, "foo", None) When I run this I get: statusLine org.eclipse.ui.texteditor.EditorStatusLine@1133f56 on the console - which I think is good? But I don't see my message showing up anywhere. DOn. |
From: Fabio Z. <fa...@gm...> - 2006-05-19 18:51:53
|
Strange, I just tested it here and it worked... it appears in the lower-lef= t corner for me (and if you pass the setMessage with the first parameter True= , it will appear in red). The script I tested here is: pyedit_test.py ------------------------------------------------------------- if False: editor =3D '' from org.eclipse.ui.texteditor import IEditorStatusLine statusLine =3D editor.getAdapter(IEditorStatusLine) if statusLine is not None: statusLine.setMessage(True, "foo", None) ----------------------------------------------------------------- -- Fabio On 5/19/06, Don Taylor <nos...@gm...> wrote: > > Fabio Zadrozny wrote: > > Actually, you probably want to ask the status manager to the editor. > > Something as below (untested): > > > > statusLine =3D editor.getAdapter(IEditorStatusLine.class); > > if statusLine is not None: > > statusLine.setMessage(False, "foo", None) > > > Fabio: > > My code looks like this: > > 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 > > > #-Paragrapher------------------------------------------------------------= --- > > class Paragrapher: > ''' Provides tools to process a paragraph of text in the Pydev > editor. > > ''' > def __init__(self): > > self.selection =3D PySelection(editor) > self.document =3D editor.getDocument() > > self.statusLine =3D editor.getAdapter(IEditorStatusLine) > print "statusLine %s" % self.statusLine > if self.statusLine is not None: > self.statusLine.setMessage(False, "foo", None) > > > When I run this I get: > > statusLine org.eclipse.ui.texteditor.EditorStatusLine@1133f56 > > on the console - which I think is good? > > But I don't see my message showing up anywhere. > > DOn. > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code > |
From: Don T. <nos...@gm...> - 2006-05-19 19:40:45
|
Fabio Zadrozny wrote: > Strange, I just tested it here and it worked... it appears in the > lower-left corner for me (and if you pass the setMessage with the first > parameter True, it will appear in red). > > > The script I tested here is: > pyedit_test.py > ------------------------------------------------------------- > > if False: > editor = '' > > from org.eclipse.ui.texteditor import IEditorStatusLine > > statusLine = editor.getAdapter(IEditorStatusLine) > if statusLine is not None: > statusLine.setMessage(True, "foo", None) > ----------------------------------------------------------------- Hmmm... 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. Don. |
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) |
From: Don T. <nos...@gm...> - 2006-05-21 04:03:07
|
Fabio Zadrozny wrote: > Well, the problem is that you need to run it from an UI-thread. The code > below shows a helper to do it: > Fabio: Thanks very much, works great. Don. |