ResourceTracking and IResourceDeltaVisitor

来源:互联网 发布:mac玩手游问道 编辑:程序博客网 时间:2024/06/06 17:31

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 .

 

     

原创粉丝点击