Plug-in 创建插件项目

来源:互联网 发布:软件开发的学校 编辑:程序博客网 时间:2024/06/05 05:33

Plug-in 创建插件项目

首先申明下,本文为笔者学习《Eclipse插件开发学习笔记》的笔记,并加入笔者自己的理解和归纳总结。

创建Plug-in项目

在Eclipse里,依次选择【File】->【New】->【Project】,选择【Plug-in Project】选项。


在配置里面选择生成"Activator"类用来控制插件的生命周期。


Activator类被默认实现,继承AbstractUIPlugin。其中start和stop方法,分别会在启动和停止时调用。

public class Activator extends AbstractUIPlugin {// The plug-in IDpublic static final String PLUGIN_ID = "com.plugin.blog.demo"; //$NON-NLS-1$// The shared instanceprivate static Activator plugin;/** * The constructor */public Activator() {}/* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */public void start(BundleContext context) throws Exception {super.start(context);plugin = this;}/* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */public 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;}}

原创粉丝点击