Eclipse PluginDevelopment:如何为 IFolder 设置 ProblemMarker?
开发 Eclipse 插件时,为空 IFolders 设置 ProblemMarker 的最佳方法是什么? 我想要实现的目标如下: 我使用自己的项目类型,并且我希望包资源管理器中的某些文件夹在空时被标记和装饰有警告。
我能做的就是在打开 eclipse 时添加标记。但我不知道发生变化时如何更新标记。
我尝试了这种方式:
使用方法: public void resourceChanged(IResourceChangeEvent event) (每当工作区中的某些内容发生更改时调用)
我检查文件夹是否为空(有效),
然后在 IFile 实例上添加 ProblemMarker。 (不起作用,因为添加 ProblemMarker 在方法 resourceChanged 中被锁定) 这是因为更改标记会触发 resourceChanged 事件。
那么解决问题的通常方法是什么呢? 我猜有一个,因为在 Eclipse 中,每当您在包资源管理器中更改某些内容时,装饰器都会立即更新。
When developing an Eclipse Plugin, what is the best way to set a ProblemMarker for empty IFolders?
What I am trying to achieve is the following:
Im using an own project type, and I want certain Folders in the Package Explorer to be marked and decorated with a warning when they are empty.
What I can do is to add markers when opening eclipse. But I dont know how to update the markers when changes occur.
I tried it this way:
using method : public void resourceChanged(IResourceChangeEvent event) (is called whenever something in workspace is changed)
I was checking the folders if they are empty (works)
then adding a ProblemMarker on the IFile instances. (does not work, because adding a ProblemMarker is locked while being in method resourceChanged)
This is because changing markers fires a resourceChanged event.
So what is the usual way to solve the problem?
I guess there is one because in eclipse whenever you change something in the package explorer the decorators are updated instantly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试创建一个生成器来检查问题并根据需要创建标记。
这篇文章可以帮助您
You could try to create a Builder which checks for problems and creates the markers as needed.
This article could help you