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;
	}
}

Filed under: Eclipse

Comments

  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.


Switch to our mobile site