当前位置: 首页 > ai >正文

Eclipse 插件开发 6 右键菜单

Eclipse 插件开发 6 右键菜单

  • 1 plugin.xml
  • 2 SampleHandler.java
  • 3 Activator.java

1 plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin><!-- 定义命令 --><extension point="org.eclipse.ui.commands"><command id="HelloWorldPlugin.commands.helloCommand" name="测试"></command></extension><!-- 定义右键菜单 --><extension point="org.eclipse.ui.menus"><menuContribution locationURI="popup:org.eclipse.ui.popup.any"><command commandId="HelloWorldPlugin.commands.helloCommand" label="测试" style="push"></command></menuContribution></extension><!-- 定义命令处理器 --><extension point="org.eclipse.ui.handlers"><handler class="com.xu.work04.handlers.SampleHandler" commandId="HelloWorldPlugin.commands.helloCommand"></handler></extension></plugin>

2 SampleHandler.java

package com.xu.work04.handlers;import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;public class SampleHandler extends AbstractHandler {@Overridepublic Object execute(ExecutionEvent event) throws ExecutionException {IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);MessageDialog.openInformation( window.getShell(), "Work04", "右击菜单弹出框!");return null;}}

3 Activator.java

package com.xu.work04;import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;/*** The activator class controls the plug-in life cycle*/
public class Activator extends AbstractUIPlugin {// The plug-in IDpublic static final String PLUGIN_ID = "com.xu.work04"; //$NON-NLS-1$// The shared instanceprivate static Activator plugin;/*** The constructor*/public Activator() {}@Overridepublic void start(BundleContext context) throws Exception {super.start(context);plugin = this;}@Overridepublic void stop(BundleContext context) throws Exception {plugin = null;super.stop(context);}/*** Returns the shared instance** @return the shared instance*/public static Activator getDefault() {return plugin;}}

在这里插入图片描述
在这里插入图片描述

http://www.xdnf.cn/news/5158.html

相关文章:

  • 从 JMS 到 ActiveMQ:API 设计与扩展机制分析(三)
  • 单脉冲前视成像多目标分辨算法——论文阅读
  • stm32之IIC
  • 基于STM32的居家环境监测报警Proteus仿真+程序设计+设计报告+讲解视频
  • 利用多AI协作实现AI编辑器高效开发:创新架构与实践基本构想
  • DeepSeek 实现趣味心理测试应用开发教程
  • JAVA自动装箱拆箱
  • 车载电子电器架构 --- 汽车网关概述
  • 【计算机视觉】OpenCV实战项目:Athlete-Pose-Detection 运动员姿态检测系统:基于OpenCV的实时运动分析技术
  • [面试]SoC验证工程师面试常见问题(五)TLM通信篇
  • 引言:Client Hello 为何是 HTTPS 安全的核心?
  • 前端HTMX技术详细解释
  • 第十七次博客打卡
  • AZScreenRecorder最新版:功能强大、操作简便的手机录屏软件
  • 网络编程套接字
  • [白话文] 从百草园RLHF到三味书屋DPO
  • 全栈开发实战:FastAPI + React + MongoDB 构建现代Web应用
  • MCP协议:大模型与外部工具交互的标准化创新方案
  • 从零开始跑通3DGS教程:(四)修改(缩放、空间变换)colmap生成的sfm结果
  • SpringBoot框架开发网络安全科普系统开发实现
  • 分布式事务快速入门
  • 小程序多线程实战
  • 功能齐全的菜谱管理器Tamari
  • [论文阅读]BadPrompt: Backdoor Attacks on Continuous Prompts
  • 23、Next.js:时空传送门——React 19 全栈框架
  • window 显示驱动开发-线性伸缩空间段
  • 简单网络交换、路由二
  • JavaWeb:JDBC
  • 关于ffmpeg的简介和使用总结
  • Kotlin Android LeakCanary内存泄漏检测实战