Events 如何在EclipseRCP中刷新properties视图?

Events 如何在EclipseRCP中刷新properties视图?,events,properties,eclipse-rcp,Events,Properties,Eclipse Rcp,我正在使用RCP中的properties视图,即org.eclipse.ui.views.properties.PropertySheet 我希望能够以编程方式刷新这些属性的内容。RCP似乎是针对只有当选择改变时才会改变的用例 是否有任何方法可以触发一个虚拟事件来刷新它(没有丑陋的UI工件,例如在部件之间切换)?主要问题是API在properties视图中隐藏了所有页面(PropertySheetPage),从而隐藏了查看器(PropertySheetViewer) 好消息是,您可以告诉prop

我正在使用RCP中的properties视图,即
org.eclipse.ui.views.properties.PropertySheet

我希望能够以编程方式刷新这些属性的内容。RCP似乎是针对只有当选择改变时才会改变的用例


是否有任何方法可以触发一个虚拟事件来刷新它(没有丑陋的UI工件,例如在部件之间切换)?

主要问题是API在properties视图中隐藏了所有页面(PropertySheetPage),从而隐藏了查看器(PropertySheetViewer)

好消息是,您可以告诉properties视图使用您想要的页面。因此,我提供了默认情况下通常使用的页面(PropertySheetPage),除非我提供它时,我保留了对它的引用(显然),然后您可以调用
propertySheetPageRef.refresh()
来更新模型(谢天谢地,这个方法是公开的)


更正geejay的回答:getAdapter方法在视图中(不在显示属性的对象中)

示例实现(在视图的类中):

public Object getAdapter(Class adapter) {
        if (adapter == IPropertySource.class) {
            return resultProvider;
        } else if (adapter == IPropertySheetPage.class) {
            return propertySheetPage;
        }
        return null;
    }
//IPropertySheetPage doesn't implement refresh()
private PropertySheetPage propertyPage;

/**
 * If called from UI thread, refreshes property page from model
 * (an IPropertySource). If called from non-UI thread, does nothing.
 */
public void refreshPropertyPage() {
    if (propertyPage != null) {
        propertyPage.refresh();
    }
}

@Override
public Object getAdapter(Class adapter) {
    if (adapter == IPropertySheetPage.class) {
        if (propertyPage == null) {
            propertyPage = new PropertySheetPage();
        }
        return propertyPage;
    }
    //use platform's adapter manager for other classes
    return super.getAdapter(adapter);
}