Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 573
cacert Avatar asked Sep 17 '26 02:09

cacert


2 Answers

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.

like image 51
Lai Avatar answered Sep 19 '26 00:09

Lai


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
like image 42
Mood Avatar answered Sep 19 '26 00:09

Mood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!