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

西门子 Teamcenter13 Eclipse RCP 开发 1 工具栏

西门子 Teamcenter13 Eclipse RCP 开发 1 工具栏

  • 1 配置文件
  • 2 插件控制
  • 3 命令框架

1 配置文件

在 Teamcenter 13 + Eclipse RCP 开发中,plugin.xml 是插件的核心配置文件,定义了插件的:

1、唯一身份(ID、版本)。
2、所依赖的其他插件。
3、注册的扩展点(Extensions)。
4、提供的功能,比如菜单项、视图、编辑器、命令、图标、语言包等。

内容plugin.xml 的角色
插件身份定义 id、版本、启动类
插件依赖MANIFEST.MF 中定义(与 plugin.xml 配合)
扩展注册注册视图、菜单、命令、动作等
Teamcenter 支持使用 Teamcenter 自定义扩展点,实现插件集成
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin><extension point="org.eclipse.ui.menus"><menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar"><toolbar id="com.example.toolbar"><command commandId="com.example.commands.helloCommand" icon="icons/sample.png" tooltip="点我执行命令" label="按钮名称" style="push"></command></toolbar></menuContribution></extension><extension point="org.eclipse.ui.handlers"><handler class="com.xu.work.tool1.handlers.SampleHandler" commandId="com.example.commands.helloCommand"></handler></extension></plugin>

2 插件控制

在使用 Siemens Teamcenter 13 进行 Eclipse RCP 插件开发 时,Activator.java 是插件生命周期管理的关键类。这个类通常由 Eclipse PDE 插件开发环境自动生成,并实现了 org.osgi.framework.BundleActivator 接口或继承了 AbstractUIPlugin(用户界面) / Plugin(后台应用)。

序号作用
1控制插件的生命周期:包括启动(start())和停止(stop())。
2提供插件范围的共享资源访问:例如共享的图标、配置文件、日志工具等。
3保存插件实例(单例):方便在其他地方访问插件上下文。
package com.xu.work.tool1;import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;/*** 插件激活器类,控制插件的生命周期*/
public class Activator extends AbstractUIPlugin {/*** 插件ID常量,通常与MANIFEST.MF中的Bundle-SymbolicName一致*/public static final String PLUGIN_ID = "com.xu.work.tool1"; //$NON-NLS-1$/*** 单例实例引用*/private static Activator plugin;/*** 构造函数*/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);}/*** 返回此插件的共享实例** @return 共享实例*/public static Activator getDefault() {return plugin;}}

3 命令框架

它是命令框架(Command Framework)的基础,用来处理 UI 中的命令(Command)。
当用户点击菜单或按钮,Eclipse 会根据 plugin.xml 中绑定的命令,调用对应的 Handler 类的 execute() 方法。

package com.xu.work.tool1.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(),"Tool1","Hello, Eclipse world");return null;}}

在这里插入图片描述

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

相关文章:

  • 双目立体视觉
  • MCP本地高效与云端实时:stdio 与 HTTP+SSE 传输机制深度对比
  • 工业场景轮式巡检机器人纯视觉识别导航的优势剖析与前景展望
  • 医院网络安全托管服务(MSS)深度解读与实践路径
  • Vue 3 实现后端 Excel 文件流导出功能(Blob 下载详解)
  • Day 21 训练
  • [Harmony]获取资源文件中.txt文件中的字符串
  • U-Mail邮件系统的安全性和可扩展性
  • 【python】字典:: a list of dictionaries
  • 硬盘坏了电脑会出现哪些明显现象?机械和固态可不一样
  • 【C/C++】深度解析C++ Allocator:优化内存管理的关键
  • 对心理幸福感含义的探索 | 幸福就是一切吗?
  • ArcGIS Pro调用多期历史影像
  • 桃芯ingchips——windows HID键盘例程无法同时连接两个,但是安卓手机可以的问题
  • K8S Gateway AB测试、蓝绿发布、金丝雀(灰度)发布
  • ubuntu服务器版启动卡在start job is running for wait for...to be Configured
  • leetcode0767. 重构字符串-medium
  • 第一个优化
  • 【测试工具】selenium和playwright如何选择去构建自动化平台
  • STC8H系列单片机STC8H_H头文件功能注释
  • Linux进程通讯和原子性
  • MYSQL基本命令
  • 商业架构 2.0 时代:ZKmall开源商城前瞻性设计如何让 B2B2C 平台领先同行 10 年?
  • Quic如何实现udp可靠传输
  • TypeScript:类
  • 康复训练:VR 老年虚拟仿真,趣味助力恢复​
  • 计算机网络--第一章(上)
  • C语言_自动义类型:联合和枚举
  • CK3588下安装linuxdeployqt qt6 arm64
  • 前端流行框架Vue3教程:17. _组件数据传递