是否可以在 Eclipse 中跟踪资源只读属性?

发布于 2024-10-20 10:34:37 字数 91 浏览 0 评论 0原文

我现在正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

述情 2024-10-27 10:34:37

我认为不可能自动完成,因为 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.

闻呓 2024-10-27 10:34:37

比 Zoltan 的回答更准确:

不,不可能直接这样做。但是,可以定期刷新工作区并查找您感兴趣的更改。

  1. 创建并计划每 XXX 秒运行一次的作业。此作业将运行 IProject.refreshLocal(IResource.DEPTH_INFINITE, null)。运行此操作后,它将重新安排自己在另外 XXX 秒后运行。
  2. 添加一个 IResourceChangeListener 来侦听您感兴趣的更改。

现在,如果只读更改发生在工作区内部,您将不必执行 #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.

  1. Create and schedule a Job that runs every XXX seconds. This job will run IProject.refreshLocal(IResource.DEPTH_INFINITE, null). After running this operation, it will re-schedule itself to run in another XXX seconds.
  2. Add an IResourceChangeListener that listens for the changes 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文