How to refresh/reload a view [message #870166] |
Mon, 07 May 2012 02:29  |
Eclipse User |
|
|
|
Hi,
I'm trying to create a plugin which will have Custom View and a Custom Button. Every time a project is selected and the button is pressed the view should get updated.
To display a view I'm using the following code:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("MyView");
The problem is how to update the view when it is already open. As a work around for this I'm first hiding the view and then reloading it as I couldn't find any refresh method. So now my code is something like:
IViewReference ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findViewReference("MyView");
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(ref);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("MyView");
When I run this code in Linux, the constructor and createPartControl method of MyView is called most of the times (sometimes it doesn't, dont know why!), but the same code only gives focus to MyView in Windows.
My requirement is that whenever I click on my plugin button, createPartControl method of MyView should get called. If calling createPartControl is not a good idea then I need a method which is called everytime MyView gets focus, so that I can move all my functionality to that method.
Thank You in advance.
Regards,
-Alok
|
|
|
Re: How to refresh/reload a view [message #870489 is a reply to message #870166] |
Tue, 08 May 2012 08:15  |
Eclipse User |
|
|
|
createPartContrl() is for when your part is created--which should happen when your view is opened, not every time it gains focus. If you want a mechanism to refresh your view, just add one that your button can make use of.
|
|
|
Powered by
FUDForum. Page generated in 0.10536 seconds