Dreamer
Dreamer

Reputation: 17

show a view part from another using a button

I want to open a ViewPart from a button in the ViewPart of another button.. I am using eclipse RCP and rcp viewparts.

My code:

Button btnPush = new Button(container, SWT.NONE);
btnPush.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
        // i want to display the view from here

    }
});

Upvotes: 0

Views: 117

Answers (1)

greg-449
greg-449

Reputation: 111216

Get the workbench page. In a view part you can use

IWorkbenchPage page = getSite().getPage();

elsewhere use:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

Show and activate the view:

page.showView("view id");

Upvotes: 1

Related Questions