How to update property view in Eclipse RCP?

I use property representation in RCP, i.e. org.eclipse.ui.views.properties.PropertySheet.

I want to be able to update the contents of these properties programmatically. RCP seems to be use-oriented, where it only changes when choices change.

Is it possible to somehow trigger a dummy event so that it is updated (without the presence of ugly artifacts of the user interface, for example, visible switching between parts)?

+3
source share
2 answers

The main problem is that the API hides all pages (PropertySheetPage) and therefore viewers (PropertySheetViewer) in the property view.

, , . , (PropertySheetPage), , , (), propertySheetPageRef.refresh() ( , ).

public Object getAdapter(Class adapter) {
        if (adapter == IPropertySource.class) {
            return resultProvider;
        } else if (adapter == IPropertySheetPage.class) {
            return propertySheetPage;
        }
        return null;
    }
+3

geejay: getAdapter ( , ).

( ):

//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 adapter manager for other classes
    return super.getAdapter(adapter);
}
+2

Source: https://habr.com/ru/post/1748508/


All Articles