com.oxygenxml.editor.contextMenuAdditions

<oXygen/> general issues.
SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

com.oxygenxml.editor.contextMenuAdditions

Post by SSC » Thu Oct 11, 2012 1:25 pm

Hello,

In your http://www.oxygenxml.com/InstData/Edito ... pseSDK.zip you have an example about the com.oxygenxml.editor.contextMenuAdditions Extension Point.

Code: Select all


    <extension point="com.oxygenxml.editor.contextMenuAdditions">
<group id="Example_group_1">
<action
id="Example_action_1"
label="Replace selection"
icon="images/ReplaceText16.gif"
text="NEW_TEXT"
class="com.oxygenxml.editor.sample.extension.action.ReplaceTextAction"/>
</group>
</extension>
When I adapt this sample and add my own Action to the ExtensionPoint I cannot see my custom action in the popup menu in the editor.

I am not sure what kind of id is required in the <group id="?"> and <action id="?">.
Are there any conditions for the ids or do I make some other mistakes?

Or is the contextMenuAdditions extension not intented to extend the popup menu of the XML editor?
If so, is it actually possible to extend the editor´s popup menu?

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Re: com.oxygenxml.editor.contextMenuAdditions

Post by Radu » Thu Oct 11, 2012 3:05 pm

Hi Simon,

The extension should be able to add actions to the pop-up menu in the Text page.
In Oxygen 14.1 you will an API for obtaining similar results:

Code: Select all

ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.addPopUpMenuCustomizer(TextPopupMenuCustomizer)
Anyway, the extension contextMenuAdditions should also work.

You are probably using the XML Author plugin so the extension point should be something like: com.oxygenxml.author.contextMenuAdditions.
You can see in the Eclipse SDK sample how the com.oxygenxml.editor.sample.extension.action.ReplaceTextAction action is connected to the extension point.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: com.oxygenxml.editor.contextMenuAdditions

Post by SSC » Thu Oct 11, 2012 4:58 pm

Hello Radu,

I cause I use the com.oxygenxml.author.contextMenuAdditions Extension.
The other one is not available, but it does not work.

Now I tried the following:

Code: Select all


  <extension point="com.oxygenxml.author.contextMenuAdditions">
<group id="Example_group_1">
<action
id="Example_action_1"
label="Replace selection"
text="NEW_TEXT"
class="eu.doccenter.kgu.client.tagging.oxygen.ReplaceTextAction"/>
</group>
</extension>
The eu.doccenter.kgu.client.tagging.oxygen.ReplaceTextAction is just a copy of your ReplaceTextAction but in a different package.
But unfortunately there is no additional item in the popup menu.
The extension should be able to add actions to the pop-up menu in the Text page.
Even though we want to add the additional item to the popup menu of the "Author Page" and not the "Text Page".

So I guess we´ll need to use the ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.addPopUpMenuCustomizer(AuthorPopupMenuCustomizer) method in order to extend the popup menu of the Author page.

Can I implement the AuthorPopupMenuCustomizer interface and gain access to the IMenuManager and then add my custom ContributionItems to that manager?
Like it is explained in the JavaDoc http://www.oxygenxml.com/InstData/Edito ... mizer.html.

Or does the Extension Point com.oxygenxml.editor.contextMenuAdditions also has a flag to extend the Author Page and not just the Text Page?
It would be nicer, if the action could be defined declaratively.

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: com.oxygenxml.editor.contextMenuAdditions

Post by SSC » Thu Oct 11, 2012 5:19 pm

Hello again Radu,

now the additional action works for the Text Page.
It wrote something wrong in the plugin.xml, because the Schemas for your Extension Points are missing.
Are those .exsd schemas for your Extension Points are available somewhere?

Nevertheless I expected that the com.oxygenxml.editor.contextMenuAdditions Extension Point to add an item to the popup menu of the Author Page and not the Text Page.

So there is just one question left.
Is there a declarative way to add items to the popup menu of the Author Page or do I have to implement the ro.sync.ecss.extensions.api.structure.AuthorPopupMenuCustomizer interface and add it with the ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.addPopUpMenuCustomizer(AuthorPopupMenuCustomizer) method?

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Re: com.oxygenxml.editor.contextMenuAdditions

Post by Radu » Thu Oct 11, 2012 5:23 pm

Hi Simon,
Are those .exsd schemas for your Extension Points are available somewhere?
No, sorry, but we'll look into this and try to build some.
Is there a declarative way to add items to the popup menu of the Author Page or do I have to implement the ro.sync.ecss.extensions.api.structure.AuthorPopupMenuCustomizer interface and add it with the ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.addPopUpMenuCustomizer(AuthorPopupMenuCustomizer) method?
No, only via using this Java API.
But the implementation on your side could read a custom made XML file which declares actions in a certain way.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: com.oxygenxml.editor.contextMenuAdditions

Post by SSC » Mon Oct 15, 2012 12:29 pm

Hello Radu,

so I build my own solution.

If you are interested I would share my solution with you:

The following OxygenAuhtorPagePopupMenuCustomizer is attached to the AuthorPages by an org.eclipse.ui.IPartListener like it is used in your sample SDK code.

Code: Select all


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>
*
* @author Simon Scholz
*
*/
public class OxygenAuhtorPagePopupMenuCustomizer 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);
}
}
}
Like I describe it in the JavaDoc of this class I can now add a custom menuContribution with the locationURI="menu:oxygen.authorpage":

Code: Select all


   <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>
Maybe you consider to add such an OxygenAuhtorPagePopupMenuCustomizer by default to the ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase, so that there is no need to attach it with an org.eclipse.ui.IPartListener.

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Re: com.oxygenxml.editor.contextMenuAdditions

Post by Radu » Mon Oct 15, 2012 4:53 pm

Hi Simon,

Actually, this is useful.
We are working at an API FAQ list which will be included in our user manual and I'll include your example as well, if you don't mind.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: com.oxygenxml.editor.contextMenuAdditions

Post by SSC » Tue Oct 16, 2012 12:06 pm

Hi Radu,

you are welcome to put this into your FAQ.
I appreciate to push the migration from org.eclipse.jface.action.IActions to the Eclipse Command Framework a bit further. :)
With my code I was able use the whole power of the Eclipse Commands, like declarative handler definition with activeWhen and enabledWhen definitions(http://wiki.eclipse.org/Command_Core_Expressions) and declarative definition of the menuContribution.
And the best thing is that this approach is very easy to extend.
So that any other plugin is able to contribute their own menuContributions to the Context Menu of the Editor by just using the locationURI:menu:oxygen.authorpage.

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Post Reply