ResourceTracking and IResourceDeltaVisitor

本文介绍如何在Eclipse中监听资源变化,包括注册资源变化监听器、查找资源变化节点及遍历资源变化的方法。通过具体代码示例展示了如何实现文件、文件夹及项目的增删改查操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Any change taking place in IResource will invoke the IResource Tracking. It may be caused by mannual operation like adding/remove/rename file by mouse, or eclipse operation like building.

  1. Register resourceChangedListener
  2.  

  3. find IResourceDelta

    Each IResourceDelta is tree node, which represents a IResource

    1.   Filter the type (Eclipse Platform Level) 

      This part of work is proceed in resourceChanged(IResourceChangeEvent event) method which is only method of  IResourceChangeListener interface

       

    2. Find IResourceDelta

      event.getDelta() return the root of resourceDelta. Generally, it represents the project where the change takes place.
  4.  

  5. Traverse resourceDelta(Eclipse project level) 

    This part of work is prcessed in visit(IResourceDelta delta)method, which is the only method of IResourceDeltaVisitor interface, we can set the return value which is boolean to notify whether the traversaling proceeds. visit will be invoked whenever traversal meets a IResourceDelta. so we need to hander all types of IResource.

    sometime we are only interested in certain kinds of changes lick content change, we can achieve it by following way

    In a word, comapred to resourceChanged(IResourceChangeEvent event), visitor focus on the things taking place during the traversal process.  Besides that, each traversed node is below the visitor caller which is a IResourceDelta also .

 

  1.  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值