Search code examples
eclipse-plugineclipse-rcprcpeclipse-emfemf

getActivePage().showView() pass model


using the EMF to start another view I would do this:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewid")

thing is, what if I want to pass some object through as well, is there a way to do this?

EDIT

I can just create the view like this: SomeView sv = new SomeView(objecttopass); but then how would I start the view?


Solution

  • Do not try and call your view constructor yourself that will not work.

    showView returns you the view part that was shown:

    IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewid");
    

    If the view is your code you can then cast that to your view class and call a method to set the data:

    SomeView myPart = (SomeView)part;
    
    myPart.setData(objecttopass);