1、插件类Activator.java
该类主要创建整个插件对象,是插件的全局对象。可以通过该类的静态方法getDefault()获得插件对象的引用,然后可以获得插件的各种信息,其中包括插件对应的Bundle文件信息和工作台对象等。
package
myfirstrcp;
import
org.eclipse.jface.resource.ImageDescriptor;
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 ID
public static final String PLUGIN_ID = "com.zhangjun.MyFirstRCP";
// The shared instance
//插件类的对象,为静态对象
private static Activator plugin;

/** *//**
* The constructor构造方法
*/
public Activator() ...{
plugin = this;
}

/** *//**
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
//装载Bundle文件并启动插件
public void start(BundleContext context) throws Exception ...{
super.start(context);
}

/** *//**

本文详细介绍了Eclipse RCP的运行基本原理,从Activator.java开始,讲解了如何创建插件对象并获取插件信息。接着阐述了Application.java在配置文件中如何指定应用程序扩展点,以及如何创建Display对象和Workbench。ApplicationWorkbenchAdvisor和ApplicationWorkbenchWindowAdvisor分别负责设定默认透视图和创建工作台窗口。最后,通过ApplicationActionBarAdvisor添加操作项,创建菜单栏、工具栏和状态栏,以及透视图Perspective的角色。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



