简体   繁体   English

Eclipse插件,无论角度如何

[英]Eclipse plug-in regardless of perspective

I'm currently working on a plug-in for eclipse. 我目前正在开发用于Eclipse的插件。 Right now it only works for the Java perspective but I want to know if there is the possibility to make it work regardless of what perspective I'm using. 现在,它仅适用于Java透视图,但是我想知道是否有可能使之不管我使用的是哪种透视图。

For instance I'm trying to make it work for PyDev. 例如,我正在尝试使其适用于PyDev。

I want my plug-in to execute an action when I right click on a file from the package explorer. 我希望我的插件在包浏览器中的文件上单击鼠标右键时执行一个操作。

If it is not possible I would appreciate any advice on how to change my plug-in so as to work on PyDev. 如果不可能的话,我将对如何更改插件以在PyDev上运行提供任何建议。

Thanks in advance! 提前致谢!

The package explorer is not restricted to a particular perspective so that is not the problem. 程序包浏览器不限于特定的角度,所以这不是问题。 More likely PyDev is using a different view which just looks similar. PyDev更可能使用看起来相似的不同视图。

If you are using the org.eclipse.ui.menus extension point to contribute to the context menu you can specify that the contribution is for any context menu and use the <visibleWhen> to control when it shown. 如果您使用org.eclipse.ui.menus扩展点为上下文菜单添加内容,则可以指定该内容适用于任何上下文菜单,并使用<visibleWhen>来控制其显示时间。 For example: 例如:

<extension
     point="org.eclipse.ui.menus">
  <menuContribution
        locationURI="popup:org.eclipse.ui.popup.any">
     <command
           commandId="org.eclipse.ui.examples.contributions.view.edit"
           mnemonic="%contributions.view.edit.mnemonic">
         <visibleWhen
                 checkEnabled="false">
             <iterate ifEmpty="false">
                 <adapt
                       type="org.eclipse.core.resources.IFile">
                 </adapt>
            </iterate>
         </visibleWhen>
      </command>
  </menuContribution>

The location popup:org.eclipse.ui.popup.any is a special id to specify any popup menu. 位置popup:org.eclipse.ui.popup.any是一个特殊的ID,用于指定任何弹出菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM