Plugin eclipse auto start in product

落花浮王杯 提交于 2019-12-31 07:22:05

问题


I am trying to create a plugin that loads different resources taken from the loaded project. I am trying to register to ResourceChangeListener of the workspace in an early stage, so that I get notification of the resources that are added to the workspace. The earlyStartup of org.eclipse.ui is too late(If the projects are already loaded to the workspace). How or which extension point can I use in order register my listener in a time that I can listen to the workspace resource changes ?

Thanks, Clint


回答1:


You should investigate having a workspace save participant to handle situations before your plug-in is started normally. Few plug-ins are important enough to warrant always starting up that early without any user involvement.

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_saving.htm




回答2:


If you want to know the resources (i.e. projects) that are open in a workspace, you can just get the IWorkspace and look at the project contained in it.

IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot rootResource = workspace.getRoot();

Then you should be able to just traverse this tree structure to find out about all the resources. Hope this helps.

Here are some resources:

  • Resources and File System
  • Resource Changes in Eclipse



回答3:


You can try to use the "org.eclipse.ui.services" extension point as follows:

<extension point="org.eclipse.ui.services">
  <sourceProvider provider="com.plugin.YourClass"></sourceProvider>
</extension>

YourClass is a class extends org.eclipse.ui.AbstractSourceProvider

Then your plugin will startup very early!



来源:https://stackoverflow.com/questions/6722963/plugin-eclipse-auto-start-in-product

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!