Eclipse 插件开发 2

Eclipse 插件开发 2

  • [1 插件配置](#1 插件配置)

1 插件配置

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

      <extension point="org.eclipse.ui.commands">
            <category id="com.xu.learn.commands.category" name="Sample Category">
            </category>
            <command categoryId="com.xu.learn.commands.category" name="Sample Command" id="com.xu.learn.commands.sampleCommand">
            </command>
      </extension>

      <extension point="org.eclipse.ui.handlers">
            <handler class="com.xu.learn.handlers.SampleHandler" commandId="com.xu.learn.commands.sampleCommand">
            </handler>
      </extension>

      <extension point="org.eclipse.ui.bindings">
            <key commandId="com.xu.learn.commands.sampleCommand" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" contextId="org.eclipse.ui.contexts.window" sequence="M1+6">
            </key>
      </extension>

      <extension point="org.eclipse.ui.menus">
            <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
                  <menu id="com.xu.learn.menus.sampleMenu" label="Sample Menu" mnemonic="M">
                        <command commandId="com.xu.learn.commands.sampleCommand" id="com.xu.learn.menus.sampleCommand" mnemonic="S">
                        </command>
                  </menu>
            </menuContribution>
            <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
                  <toolbar id="com.xu.learn.toolbars.sampleToolbar">
                        <command id="com.xu.learn.toolbars.sampleCommand" commandId="com.xu.learn.commands.sampleCommand" icon="icons/sample.png" tooltip="Say hello world">
                        </command>
                  </toolbar>
            </menuContribution>
      </extension>

</plugin>

常见 locationURI 类型及含义

类型前缀 示例 含义
menu: menu:org.eclipse.ui.main.menu 主菜单栏(File、Edit、Window 那一栏)
toolbar: toolbar:org.eclipse.ui.main.toolbar 主工具栏
popup: popup:org.eclipse.ui.popup.any 右键菜单(弹出菜单)
viewmenu: viewmenu:your.view.id 视图右上角菜单(下拉三角按钮)
trim: trim:org.eclipse.ui.trim.status 插入到 Eclipse 的"修饰栏",比如状态栏等
menuContributionRoot [特殊用法] 直接创建一套菜单(很少用)

可选参数

参数 含义
?after=additions 在系统默认项后插入
?before=... 在某项之前插入
?groupId=xxx 插入到某个分组中
相关推荐
码路飞2 小时前
GPT-5.3 Instant 终于学会好好说话了,顺手对比了下同天发布的 Gemini 3.1 Flash-Lite
java·javascript
SimonKing3 小时前
OpenCode AI编程助手如何添加Skills,优化项目!
java·后端·程序员
Seven974 小时前
剑指offer-80、⼆叉树中和为某⼀值的路径(二)
java
怒放吧德德16 小时前
Netty 4.2 入门指南:从概念到第一个程序
java·后端·netty
雨中飘荡的记忆17 小时前
大流量下库存扣减的数据库瓶颈:Redis分片缓存解决方案
java·redis·后端
心之语歌20 小时前
基于注解+拦截器的API动态路由实现方案
java·后端
华仔啊21 小时前
Stream 代码越写越难看?JDFrame 让 Java 逻辑回归优雅
java·后端
ray_liang21 小时前
用六边形架构与整洁架构对比是伪命题?
java·架构
Ray Liang1 天前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
Java水解1 天前
Java 中间件:Dubbo 服务降级(Mock 机制)
java·后端