资源更改插件为eclipse [英] Resource Change Plugin for eclipse

查看:115
本文介绍了资源更改插件为eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个RCP应用程序,通过扩展 CommonNavigator 来检测自己的视图中的资源更改。

I created an RCP application which detects resource change in its own view by extending CommonNavigator.

public abstract class NavigatorView extends CommonNavigator  implements
    IResourceChangeListener {
public void createPartControl(Composite parent) {
 super.createPartControl(parent);
 hookResourceChangeCommand(); // my resource tracking function.
 }
}

但现在我需要为此创建一个插件检测eclipse中项目资源管理器的资源变化。我现在不能创建一个视图,我需要检测已经存在的视图。我应该怎么做?

But now I need to create a plugin for this which detects resource change in project explorer in eclipse itself. I cannot create a view now and I need to detect already existing view. How should I do it ?

推荐答案

请完全删除您创建的视图。您不应该在UI中执行任何操作,如果要跟踪资源更改,因为资源是工作空间概念的一部分,并且工作空间通常无头(即没有UI)。

Please completely remove the view that you created. You should not do anything in the UI, if you want to track resource changes, as resources are part of the workspace concept, and the workspace is generally headless (that is without UI).

而是使用下面的代码(取自资源更改监听器教程):

Instead use the code below (taken from the resource change listener tutorial):

IWorkspace workspace = ResourcesPlugin.getWorkspace();
   IResourceChangeListener listener = new IResourceChangeListener() {
      public void resourceChanged(IResourceChangeEvent event) {
         System.out.println("Something changed!");
      }
   };
   workspace.addResourceChangeListener(listener);

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

这篇关于资源更改插件为eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆