开发者

Changing dynamically view content in Eclipse plugin view

开发者 https://www.devze.com 2023-04-11 04:20 出处:网络
I\'m developing Eclipse plugin that has a treeview with toolbar and buttons. I\'d want to make the plugin work so that it would show the treeview as default but in case of some error there would be so

I'm developing Eclipse plugin that has a treeview with toolbar and buttons. I'd want to make the plugin work so that it would show the treeview as default but in case of some error there would be some text and button to initialize or update the plugin. T开发者_JS百科he plugin view should change dynamically depending on the state of the plugin between the treeview and the "error view".

For now I'm creating the treeview instance and doing the other needed actions in createPartControl method to show the treeview right. How should I implement the dynamic view showing different kind of content in the plugin view? Is that possible at all?

Code of the createPartControlMethod:

public void createPartControl(Composite parent) {
        viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        drillDownAdapter = new DrillDownAdapter(viewer);
        viewContentProvider = new ViewContentProvider();
        viewer.setContentProvider(viewContentProvider);
        viewer.setLabelProvider(new ViewLabelProvider());
        viewer.setSorter(new NameSorter());
        viewer.setInput(getViewSite());
        viewer.expandToLevel(2);

        // Create the help context id for the viewer's control
        PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "my.plugin.viewer");
        makeActions();
        hookContextMenu();
        hookDoubleClickAction();
        contributeToActionBars();
        setToolBarButtonsEnabled();


Simplest way would be to create a Composite with a StackLayout and two children instead:

private Composite container;
private TreeViewer viewer;
private Composite errorComposite;
private StackLayout layout;

public void createPartControl(Composite parent) {
    container = new Composite(parent);
    layout = new StackLayout();
    viewer = new TreeViewer(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    ... // setup viewer
    errorComposite = new Composite(container, SWT.NONE);
    ... // setup error view
}
0

精彩评论

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