Eclipse Listener to detect File changes?

自古美人都是妖i 提交于 2020-01-06 13:56:20

问题


I am searching a listener in Eclipse, that will detect if a file is changed externally by third party software, like MKS.

I used IResourceChangeListener and it worked. But problem is, it also listens other changes of the file. For example, when I delete the markers, it also listens and execute the codes I wanted after listening.

Is there any Listener, which listens only if the file is changed (newly opened/refreshed) by third party software?

Updated:

My code:

public class Startup implements IStartup {

       IWorkspace workspace = ResourcesPlugin.getWorkspace();
       IResourceChangeListener listener = new IResourceChangeListener() {

        public void resourceChanged(IResourceChangeEvent event) {


               if(event.getType() == IResourceChangeEvent.POST_CHANGE && IResourceDelta.MARKERS!=0){  //Filtering listener


                System.out.println("Listener code should be implemented here");  


              }


               System.out.println("listener is working");  //This line always get executed. That means the listener is working


           }
       };



    @Override
    public void earlyStartup() {
       workspace.addResourceChangeListener(listener,IResourceChangeEvent.POST_CHANGE);

       //... some time later one ...
      // workspace.removeResourceChangeListener(listener);
    }


}

来源:https://stackoverflow.com/questions/27420787/eclipse-listener-to-detect-file-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!