Viewpoints – Output all Eclipse views your are using

I received the question how someone could see all available views.

This is easy, Eclipse 3.x allows access to the current available views via PlatformUI.getWorkbench().getViewRegistry().

For example this command handler prints out the ID’s of all available views.

public class SampleHandler extends AbstractHandler {
	public Object execute(ExecutionEvent event) throws ExecutionException {
		// Views
		System.out.println("All my View ID's");
		IViewRegistry viewRegistry = PlatformUI.getWorkbench().getViewRegistry();
		IViewDescriptor[] views = viewRegistry.getViews();
		for (IViewDescriptor iViewDescriptor : views) {
			System.out.println(iViewDescriptor.getId());
		}
		return null;
	}
}

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse. Bookmark the permalink.

2 Responses to Viewpoints – Output all Eclipse views your are using

  1. david says:

    How does one remove or hide a view that’s in the registry?

    I’ve got a RCP application that I’m developing and I want to prevent the Outline view from showing up in the “Show View” dialog.

    Thanks!

  2. Lars Vogel says:

    @david: don’t include it in your product configuration would be the simple answer.

Comments are closed.