Programmatically showing a View from an Eclipse Plug-in

后端 未结 4 996

I have a plug-in to an Eclipse RCP application that has a view. After an event occurs in the RCP application, the plug-in is instantiated, its methods are called to populat

相关标签:
4条回答
  • 2020-11-29 03:57

    If called from handler of a command

    HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(viewId);
    

    would be better, as I know.

    0 讨论(0)
  • 2020-11-29 04:01

    In e4, the EPartService is responsible for opening Parts. This can also be used to open e3 ViewParts. Instantiate the following class through your IEclipseContext, call the openPart-Method, and you should see the Eclipse internal browser view.

    public class Opener {
        @Inject
        EPartService partService;
    
        public void openPart() {
            MPart part = partService.createPart("org.eclipse.ui.browser.view");
            part.setLabel("Browser");
    
            partService.showPart(part, PartState.ACTIVATE);
        }
    }
    

    Here you can find an example of how this works together with your Application.e4xmi.

    0 讨论(0)
  • 2020-11-29 04:04

    I found the need to bring the view to the front after it had been opened and pushed to the background. The activate method does the trick.

    PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow()
        .getActivePage()
        .activate(workbenchPartToActivate);
    

    NOTE: The workbenchPartToActivate is an instance of IWorkbenchPart.

    0 讨论(0)
  • 2020-11-29 04:15

    You are probably looking for this:

    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");
    
    0 讨论(0)
提交回复
热议问题