开发者

IResource.refreshLocal(IResource.DEPTH_INFINITE, null); is not refreshing

开发者 https://www.devze.com 2023-03-20 06:50 出处:网络
After doing manipulatio开发者_开发知识库n in my tree viewer, when I\'m calling this api IResource.refreshLocal(IResource.DEPTH_INFINITE, null); it is not refreshing the UI. Is there any alternative wa

After doing manipulatio开发者_开发知识库n in my tree viewer, when I'm calling this api IResource.refreshLocal(IResource.DEPTH_INFINITE, null); it is not refreshing the UI. Is there any alternative way by which I can refresh my tree?


If you are doing a custom tree viewer that depends on the resource changes, then refreshing the resources will not result in changes in the viewer: the content provider will not be re-executed on resource changes. If you want to refresh a custom viewer, you have to register a resourcechangelistener that will call the refresh or update methods of the viewer.

However, if you are using Common Navigator Framework (CNF) with the built-in resource support, it should refresh itself.

Update: The CNF should be configured as follows (that is extracted from my working solution):

<extension
   point="org.eclipse.ui.navigator.viewer">
  <viewerContentBinding 
     viewerId="org.eclipse.viatra2.navigator">
    <includes>
      <contentExtension 
    pattern="org.eclipse.ui.navigator.resourceContent" />                     
      <contentExtension 
    pattern="org.eclipse.ui.navigator.resources.filters.*"/>
    </includes>
...
</extension>


For custom models added into Navigator use:

if (viewPart instanceof CommonNavigator) {
  CommonViewer viewer = ((CommonNavigator) viewPart).getCommonViewer();
  viewer.refresh();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消