Edit online


How do I add my own custom actions to the contextual menu using an API?


The WSAuthorEditorPageBase.addPopUpMenuCustomizer and WSTextEditorPage.addPopUpMenuCustomizer API methods allow you to customize the contextual menu shown either in the Author or Text modes. The API is available both in the standalone application and in the Eclipse plugin.

Here is an elegant way to add actions to the Author page from your Eclipse plugin extension:
  1. Create a pop-up menu customizer implementation:
    import org.eclipse.jface.action.ContributionManager;
    import org.eclipse.ui.PlatformUI;
    import org.eclipse.ui.menus.IMenuService;
    import ro.sync.ecss.extensions.api.AuthorAccess;
    import ro.sync.ecss.extensions.api.structure.AuthorPopupMenuCustomizer;
    * This class is used to create the possibility to attach certain
    * menuContributions to the {@link ContributionManager}, which is used for the
    * popup menu in the Author Page of the Oxygen Editor.<br />
    * You just need to use the org.eclipse.ui.menus extension and add a
    * menuContribution with the locationURI: <b>menu:oxygen.authorpage</b>
    public class OxygenAuthorPagePopupMenuCustomizer implements
            AuthorPopupMenuCustomizer {
        public void customizePopUpMenu(Object menuManagerObj,
                AuthorAccess authoraccess) {
            if (menuManagerObj instanceof ContributionManager) {
     ContributionManager contributionManager = (ContributionManager) menuManagerObj;
                IMenuService menuService = (IMenuService) PlatformUI.getWorkbench()
  2. Add a workbench listener and add the pop-up customizer when an editor is open in the Author page:
        new IPartListener() {
          public void partOpened(IWorkbenchPart part) {
            if(part instanceof ro.sync.exml.workspace.api.editor.WSEditor) {
              WSEditorPage currentPage = ((WSEditor)part).getCurrentPage();
              if(currentPage instanceof WSAuthorEditorPage) {
    (new OxygenAuthorPagePopupMenuCustomizer());
  3. Implement the extension point in your plugin.xml file: