cacert
cacert

Reputation: 2797

Hiding and showing Eclipse view programmatically

I am showing and hiding Eclipse view with code below. It works perfectly with Eclipse 3.3, but with Eclipse Juno (version 4.3) it's not showing the first time but showing when I fire the event for the second time.

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
    .getActivePage();
page.showView(UserView.ID);
page.hideView(page.findView(UserView.ID));

Is somebody come across with this situation before?

Upvotes: 3

Views: 3403

Answers (2)

moud
moud

Reputation: 749

I faced the same issue with the minimized state, so I tried chaging the view's state forcing it to appear after page.showView(UserView.ID);

this piece of code got my viewPart to show :

page.showView(UserView.ID); 
IWorkbenchPartReference ref = page.getReference(searchResultUI);    
page.setPartState(ref,IWorkbenchPage.STATE_RESTORED); //or STATE_MAXIMIZED

Upvotes: 2

Lai
Lai

Reputation: 482

I am not sure why you are not getting it the first time. Check to see if you dont have null pointer errors when you fire it the first time.

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()

can return a null if the workbench is not yet loaded.

Upvotes: 2

Related Questions