Reputation: 514
I want to have a Boolean variable that is true if a view has already been activated in the RCP GUI, otherwise false.
I tried the following code:
IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("view.id");
if (view != null){
System.out.println("View Active");
}
But it returns a view even though it has not been activated in the GUI.
Upvotes: 1
Views: 294
Reputation: 3698
findView should return null if view has not been created at all. If by 'active' you mean brought up to front/visible currently, try using IWorkbenchPage.isPartVisible
Upvotes: 3
Reputation: 3304
Try finding a view reference, without trying to restore the view, like this:
IViewReference viewReference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findViewReference("view.id");
if (viewReference.getView(false) != null) {
System.out.println("View Active");
}
Upvotes: 1