简体   繁体   English

Eclipse插件开发:在IFile删除和setcontents之前的监听器?

[英]Eclipse plugin Development : Listener before IFile delete and setcontents?

I am creating set of eclipse plugins that requires marshalling and unmarshalling of xml.So i have created custom builder to validate these xml which will be executed each time file is changed or deleted.I got my builder to be executed on delete and change event but my problem is that after change or delete file does not exists so i cant unmarshall the file. 我正在创建一组需要编组和解组xml的eclipse插件。所以我创建了自定义构建器来验证这些xml,每次更改或删除文件时都会执行。我让我的构建器在删除和更改事件时执行但是我的问题是,更改或删除文件后不存在所以我不能解组该文件。

In short i want to validate xml in eclipse if its dependent file is changed in any way.So i will be requiring both old and new state of resource.For this i may be requiring some kind of pre-delete or pre-change IFile listeners. 总之,我想在eclipse中验证xml,如果它的依赖文件以任何方式改变。所以我将要求新旧资源状态。为此我可能需要某种预删除或预更改IFile监听器。

can somebody guide me in right direction??? 有人可以指导我正确的方向吗?

Thanks. 谢谢。

Use org.eclipse.core.resources.IResourceChangeListener to listen for all changes to resources in the workspace. 使用org.eclipse.core.resources.IResourceChangeListener监听工作空间中资源的所有更改。

Set up the listener with: 设置监听器:

ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);

The listener is given an IResourceChangeEvent when resources change which contains an IResourceDelta . 当资源改变时,监听器被赋予IResourceChangeEvent ,其中包含IResourceDelta The delta may describes changes to several resources. 增量可以描述对多个资源的更改。

If IFile contents are modified using the keep history flag then the previous file contents can be retrieved using IFile.getHistory 如果使用keep history标志修改了IFile内容,则可以使用IFile.getHistory检索先前的文件内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM