如何在 Eclipse 中订阅 OpenProject 事件?
我正在开发一个 Eclipse 插件。
我一直在阅读如何使用接口 IResourceChangeListener,并使用 PRE_CLOSE
事件类型。以下文本摘自 Eclipse 帮助:
通知听众项目即将关闭。本次活动 可用于从数据中提取并保存必要的信息 项目的内存表示(例如会话属性) 在关闭之前。 (当项目关闭时,内存中 代表已处置)。工作区被锁定(没有资源可以 在此活动期间进行更新)。该事件包含的项目是 正在关闭。
我没有找到如何在项目即将打开时收到通知。
I'm developing an Eclipse plugin.
I have been reading how to subscribe get notification when a project is about to be closed, using the interface IResourceChangeListener, and using the PRE_CLOSE
event type. The following text has been taken from the Eclipse help:
Notifies listeners that a project is about to be closed. This event
can be used to extract and save necessary information from the
in-memory representation (e.g., session properties) of a project
before it is closed. (When a project is closed, the in-memory
representation is disposed). The workspace is locked (no resources can
be updated) during this event. The event contains the project that is
being closed.
I didn't found how to be notified when a project is about to be opened.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以创建自己的
IResourceChangeListener
并通过IResourceDelta.OPEN
过滤增量类型,这仅影响 IProjects,并且在打开和关闭项目时都会触发:有用的链接:
http://www.eclipse.org/articles/Article-Resource -deltas/resource-deltas.html
You can create your own
IResourceChangeListener
and filter the kind of delta byIResourceDelta.OPEN
, which only affects to IProjects, and it's fired both when opening and closing a project:Useful link:
http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html
我知道这个问题早已得到解答,但我想用一个工作代码片段来更新它,以防万一有人需要它。我在 Eclipse Luna、Indigo 和 Kepler 上测试了它。
I know this question has been long answered, but I want to update it with a working code snippet, just in case anybody will need it. I tested it on Eclipse Luna, Indigo, and Kepler.
IResourceChangeEvent
是POST_CHANGE
和相关的IResourceDelta
类型是IResourceDelta.CHANGED
和标志包括IResourceDelta.OPEN
。IResourceChangeEvent
isPOST_CHANGE
and relatedIResourceDelta
kind isIResourceDelta.CHANGED
and flags includeIResourceDelta.OPEN
.