Search code examples
javaeclipse-pluginswtrcp

How to close a view in in RCP Application?


I have a RCP Application with number of views. There is a 'Welcome' view and other views. Whenever I select 'Welcome' view, other views are closed using the code,

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(viewID); 

(Note : Dependency of other plug-in is added to the plug-in where 'Welcome' view is present.)

The same way, I want to close 'Welcome' view when I select any other views from coolbar or Show view dialog. The problem is, if I use the same code as above by adding the dependency, it is causing cyclic dependency in my application and throwing errors. How do I do it without causing cyclic dependency?


Solution

  • This is the correct code to close a view.

    You don't need to make the plug-in which contains the view a dependency of the plug-in which is doing the close. All you need is the view id.

    Cyclic dependency means you have two plug-ins A and B with A depending on B and B depending on A. This is not allowed because there is no way to build the plug-ins cleanly. You need to change the dependencies to remove the cycle.