自动执行eclipse插件 [英] Executing eclipse plugin automatically

查看:131
本文介绍了自动执行eclipse插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个eclipse插件,在eclipse工作台关闭时删除一些文件。我从 Hello,World命令插件项目开始,并添加了一个 IWorkbenchListener ,如这个toppic Eclipse关闭挂钩能够停止终止。当我在eclipse菜单栏(由此插件添加)中按下一个特殊按钮时,会添加该监听器。

I try to create an eclipse plugin which deletes some files when eclipse workbench is closed. I started with the Hello, World command plugin project and added a IWorkbenchListener like mentioned in this toppic Eclipse shut down hook able to stop the termination. The listener is added when I press a special button in the eclipse menu bar (which is added by this plugin).

如何自动添加这个 IWorkbenchListener ,而不需要点击任何菜单项?

How can I automatically add this IWorkbenchListener, without the need of clicking on any menu entry?

推荐答案

使用 org.eclipse.ui.startup 扩展点来指定一个实现 org.eclipse.ui.IStartup 的类。这将在Eclipse初始化过程中被调用。

Use the org.eclipse.ui.startup extension point to specify a class that implements org.eclipse.ui.IStartup. This will be called early on during Eclipse initialization.

所以在 plugin.xml 中:

<extension
     point="org.eclipse.ui.startup">
  <startup
        class="your class implementing IStartup"/>
</extension>

类:

public class Startup implements IStartup
{
  @Override
  public void earlyStartup()
  {
    // you action
  }
}

这篇关于自动执行eclipse插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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