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 插入到某个分组中
相关推荐
代码AI弗森20 小时前
一文理清楚“算力申请 / 成本测算 / 并发评估”
java·服务器·数据库
Old Uncle Tom20 小时前
OpenClaw 记忆系统 -- 记忆预加载
java·数据结构·算法·agent
小小小米粒20 小时前
Collection单列集合、Map(Key - Value)双列集合,多继承实现。
java·开发语言·windows
摇滚侠21 小时前
expdp 查看帮助
java·数据库·oracle
:12121 小时前
java基础
java·开发语言
曹牧1 天前
Spring:@RequestMapping注解,匹配的顺序与上下文无关
java·后端·spring
daixin88481 天前
cursor无法正常使用gpt5.5等模型解决方案
java·redis·cursor
韦禾水1 天前
记录一次项目部署到tomcat的异常
java·tomcat
曦月合一1 天前
树莓派安装jdk、tomcat、vnc、谷歌浏览器开机自启等环境配置
java·tomcat·树莓派
此剑之势丶愈斩愈烈1 天前
openssl 自建证书
java