何时选择“生成激活器..."创建新的 Eclipse 插件项目时 [英] When to choose "Generate an activator..." when creating a new Eclipse plugin project

查看:26
本文介绍了何时选择“生成激活器..."创建新的 Eclipse 插件项目时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多 Eclipse RCP 教程都是从显而易见的第一步开始的:创建一个新的插件项目..."

There are lots of Eclipse RCP tutorials that begin with the obvious first step: "Create a new plugin project..."

似乎大约.其中 70% 指定检查生成一个激活器,一个控制插件生命周期的 Java 类".其他人特别说不要检查那个切换.

It seems that approx. 70% of them specify checking the "Generate an activator, a Java class that controls the plug-in life cycle". The others specifically say don't check that toggle.

替代文字 http://img179.imageshack.us/img179/6710/newpluginoptions.png

我不清楚生成激活器类对你有什么作用,什么时候需要,什么时候不需要.

Its not clear to me, what generating an activator class does for you, when you need one, and when you don't.

作为一个突出的选项,您每次创建新插件项目时都会获得(它似乎默认设置为打开),这个选项在我找到的任何地方都没有得到很好的解释.

For being a prominent option you get every time you create a new plugin project (it seems to be set on by default) this option isn't very well explained anywhere that I have found.

在创建 Eclipse 插件项目时选择此选项有什么建议/经验法则?

Any advice/rules of thumb on choosing this option when creating Eclipse plugin projects?

推荐答案

一种方法是查看生成的类.原来它是 AbstractUIPlugin.查看 JavaDoc,它提供了偏好管理、图像注册等服务.如果你需要这些,你可能想要使用它.它是 Plugin 的子类,有点意思.

One way to find out is to look at the generated class. Turns out that it is a subclass of AbstractUIPlugin. Check out the JavaDoc, it provides services like preference management, image registry and the like. If you need any of this, you may want to use it. It is a subclass of Plugin, which kind of makes sense.

此外,它还实现了 BundleActivator,其中有一些有用的 JavaDoc.这为您提供了 start() 和 stop() 的存根,允许您在此处挂钩自己的代码.它还生成一个静态便捷方法 getDefault(),它为您提供了 Activator.仅此而已.

Also, it implements BundleActivator, which has some useful JavaDoc. This provides you with stubs for start() and stop(), which allows you to hook your own code in here. It also generates a static convenience method getDefault(), which gives you the Activator. And that's all there is to it.

这篇关于何时选择“生成激活器..."创建新的 Eclipse 插件项目时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆