The API methods WSAuthorEditorPageBase.addPopUpMenuCustomizer and WSTextEditorPage.addPopUpMenuCustomizer allow you to customize the contextual menu shown either in the Author or in the Text modes. The API is available both in the standalone application and in the Eclipse plugin.
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 { @Override public void customizePopUpMenu(Object menuManagerObj, AuthorAccess authoraccess) { if (menuManagerObj instanceof ContributionManager) { ContributionManager contributionManager = (ContributionManager) menuManagerObj; IMenuService menuService = (IMenuService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IMenuService.class); menuService.populateContributionManager(contributionManager, "menu:oxygen.authorpage"); contributionManager.update(true); } } }
Workbench.getInstance().getActiveWorkbenchWindow().getPartService().addPartListener(
new IPartListener() {
@Override
public void partOpened(IWorkbenchPart part) {
if(part instanceof ro.sync.exml.workspace.api.editor.WSEditor) {
WSEditorPage currentPage = ((WSEditor)part).getCurrentPage();
if(currentPage instanceof WSAuthorEditorPage) {
((WSAuthorEditorPage)currentPage).addPopUpMenuCustomizer(new OxygenAuthorPagePopupMenuCustomizer());
}
}
}
........
});
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:oxygen.authorpage">
<command
commandId="eu.doccenter.kgu.client.tagging.removeTaggingFromOxygen"
style="push">
</command>
</menuContribution>
</extension>