是否可以在 Eclipse 中跟踪资源只读属性?
我现在正在使用 Eclipse 资源,并且对是否可以处理文件只读属性更改感兴趣?例如,用户在应用程序外部更改文件只读属性,然后我可以在我的应用程序中处理此属性更改事件。
I am working with eclipse resources right now and interested whether it is possible to handle file read-only property change ? For example user changes file read-only property outside application and then I can handle this property change event in my application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为不可能自动完成,因为 Eclipse 资源并不总是与文件系统同步。更具体地说,文件更改不会直接触发 Eclipse 资源中的事件。仅当读取资源时才会刷新文件。
也许如果你不断刷新,这是可能的,但这可能会产生相当大的开销。刷新后,可以监听资源的变化 - 这就是构建器和资源监听器的用途。
I don't think, it is possible to do it automatically, as Eclipse resources do not synchronize all the time with the file system. More specifically, file changes do not trigger events in the Eclipse resources directly. Files are refreshed only when the resources are read.
Maybe if you are refreshing continously, it would be possible, but that can have quite an overhead. After a refresh it is possible to listen to changes in resources - thats what Builders and resource listeners are for.
比 Zoltan 的回答更准确:
不,不可能直接这样做。但是,可以定期刷新工作区并查找您感兴趣的更改。
现在,如果只读更改发生在工作区内部,您将不必执行 #1,并且 #2(资源更改侦听器)将自动运行。
To be more precise than Zoltan's answer:
No, it is not possible to do this directly. However, it is possible to periodically refresh the workspace and look for changes that you are interested in.
Now, if the Read-only changes happen from inside the workspace, you will not have to do #1, and #2 (the resource change listener) will run automatically.