简体   繁体   中英

Open eclipse 3.x view in eclipse 4.x using Handlers

I am migrating my 3.x eclipse RCP application to eclipse 4.x, I have imported 3.x Views in application model and now i want to invoke the view from command, So i have created handler in 4.x and in execute method written below code:

@Execute
    public void execute(EPartService partService)
    {
      MPart mpart = partService.showPart("com.sample.application.part.other", PartState.ACTIVATE);
    }

But this code is not working for 3.x views so please let me know how can i invoke 3.x views in eclipse 4 using handlers?

If your 3.x views are imported as in the Application.e4xmi , I don't think you'll have a problem with the solution you've posted. ,我认为您发布的解决方案不会有问题。 The legacy views should be considered as parts.

You may also want to try converting some of the old views to e4, because the process is quite fast.

Ultimately, have you tried the old way of opening views?

 
 
 
  
  @Execute public void execute(final EPartService partService) throws PartInitException { final IWorkbenchWindow activeww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = activeww.getActivePage(); activePage.showView("com.sample.application.part.other"); }
 
  

or even a combination of 3.x/e4

 
 
 
  
  @Execute public void execute(final ExecutionEvent event) throws PartInitException { final IWorkbenchWindow activeww = HandlerUtil.getActiveWorkbenchWindow(event); final IWorkbenchPage activePage = activeww.getActivePage(); activePage.showView("com.sample.application.part.other"); }
 
  

I have to use compat layer to use 3.x views and will not support in pure 4.x application, after introducing the compat layer above code is working fine now. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM