[Pydev-code] Can we add an action to the context menu of the PyDev editor?
Brought to you by:
fabioz
|
From: Florian S. <flo...@gm...> - 2007-11-27 05:49:40
|
Hi everyone,
I have a plug-in that extends org.eclipse.ui.popupMenus
in order to add an action to the context menu of the PyDev
editor. Here's the relevant portion of my plugin.xml file:
<viewerContribution
id="org.eclipse.olm.editor_extensions.python_add_comment"
targetID="#PythonEditorContext">
<action
class="org.eclipse.olm.pinkhippo.editor_extensions.AddCommentDelegate"
icon="icons/sample.gif"
id="org.eclipse.olm.editor_extensions.editor_actions.add_comment"
label="Add Comment"
menubarPath="additions"/>
</viewerContribution>
Unfortunately, the code that handles this action and implements
IEditorActionDelegate has to access the editor, in the following way:
...
public void run(IAction action) {
if( editor.getEditorInput() != null &&
editor.getEditorInput() instanceof IFileEditorInput &&
editor instanceof AbstractTextEditor){
...
I say 'unfortunately', because PyDev seems to be complaining
about illegal access of some internal module. Here's the error message:
Error received...
tried to access field
org.python.pydev.ui.pythonpathconf.InterpreterInfo.modulesManager from
class com.python.pydev.analysis.additionalinfo.builders.InterpreterObserver
tried to access field
org.python.pydev.ui.pythonpathconf.InterpreterInfo.modulesManager from
class com.python.pydev.analysis.additionalinfo.builders.InterpreterObserver
java.lang.IllegalAccessError: tried to access field
org.python.pydev.ui.pythonpathconf.InterpreterInfo.modulesManager from
class com.python.pydev.analysis.additionalinfo.builders.InterpreterObserver
at com.python.pydev.analysis.additionalinfo.builders.InterpreterObserver.notifyDefaultPythonpathRestored(InterpreterObserver.java:58)
at com.python.pydev.analysis.additionalinfo.builders.InterpreterObserver$1.run(InterpreterObserver.java:96)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Moreover, since this error occurs the action that I tried to insert in the
context menu of the PyDev editor never appears there. The same code
runs perfectly for the context menu of the Java editor (i.e.
#CompilationUnitEditorContext
as the targetID).
Can anyone tell me what I am doing wrong here?
Is it possible to extend the context menu of the PyDev editor?
Thanks,
Florian
PS: I am running Eclipse 3.2 on Linux, Ubuntu 7.04
and PyDev 1.3.8.
|