views:

192

answers:

1

Hi,

i have one perspective and one viewpart. The viewpart is shown as soon as the program opens. The viewpart should be the only one and should be closeable.

I have two problems with that behaviour:

  1. I want the perspective to be shown empty, just a background image should being shown. (How do I do that?)
  2. I want to open the viewpart from the menu, using the command style menu.

So far I can close my viewpart and the perspective is empty.

but

I can not call it from the menu with my selfdefined command. The code is like

public class CallMyViewPart extends AbstractHandler implements IHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

        MyViewPart myViewPart = new MyViewPart();

    return null;
    }
}

What am I doing wrong? Thanks!

A: 

Well, it was easier than I thought.

public class CallMyViewPart extends AbstractHandler implements IHandler {      

    @Override      
    public Object execute(ExecutionEvent event) throws ExecutionException {      
        Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();      
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
        try {
        page.showView("somedomain.mainViewpart");
    } catch (PartInitException e) {
        e.printStackTrace();
    }

    return null;      
    }      
} 
Raven