Search code examples
eclipseeclipse-plugineclipse-rcpe4

How to get the Mpart from the part's handled tool item?


I want to to get the Mpart from which the handle tool item belongs when user clicks on handled toolitem of the toolbar (Here the command which will be executed on clicking is common across these toolitems).I tried using activepart but it seems if any other part is active in other partstack this will return wrong value .Any pointer on this will be helpful.Thanks in advance.


Solution

  • Use @Named(IServiceConstants.ACTIVE_PART) to get the correct active part in your handler @Execute or @CanExecute methods:

    @Execute
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart)