How to contribute a new menu item in an existing menu via a fragment? [message #1001806] |
Thu, 17 January 2013 12:00 |
Eclipse User |
|
|
|
Hello,
I'm looking for a simple tutorial on how to contribute a new menu item t
an existing menu. I found some urls:
http://www.vogella.com/articles/Eclipse4Modularity/article.html#contributefragments_model
http://www.vogella.com/articles/EclipseRCP/article.html#commands_popup
But the described model alwayws refers to the application.e4xmi and not
just to a fragment.e4xmi. So I'm confused how to contribute because
sometimes "menu:" must be a prefix of the menu id to contribute to and
sometimes not. The attached file shows my fragment.e4xmi and my intends
to contribute a menu item but nothing happens. Would be nice if you
could give me some pointers to tutorials or any hints how to realise
this. Or maybe a good book would be nice, too.
best regards,
Gilbert
-------------------------------------------------------
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands"
xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment"
xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu"
xmi:id="_IU2pYGCJEeK-fpTrs2yrzw">
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_LgthYGCJEeK-fpTrs2yrzw" featurename="commands"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command"
xmi:id="_S2HosGCJEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.commands.modifyFillColor"
commandName="Modify Fill Color of EClasses" description="Modifies the
fill color of each EClass in an open Ecore Tools Diagram Editor"
category="_mWvIoGCJEeK-fpTrs2yrzw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_inHcQGCJEeK-fpTrs2yrzw" featurename="categories"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Category"
xmi:id="_mWvIoGCJEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.categories.ecoretoolsadditions"
name="Ecore Tools Additions" description="Some additional features for
the Ecore Tools"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_unv8kGCJEeK-fpTrs2yrzw" featurename="handlers"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler"
xmi:id="_xYe-0GCJEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.handlers.fillColorChangeHandler"
contributionURI="bundleclass://org.test.ecoretools.additions/org.test.ecoretools.additions.ModifyFillColorHandler"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_0b4XAGCMEeK-fpTrs2yrzw" featurename="toolBarContributions"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:ToolBarContribution"
xmi:id="_1F4O4GCPEeK-fpTrs2yrzw" elementId="org.test.ecoretools.toolbar">
<children xsi:type="menu:HandledToolItem"
xmi:id="_PV008GCNEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.item" label="Modify Fill
Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_Q4ShsGCXEeK-fpTrs2yrzw" featurename="menuContributions"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution"
xmi:id="_g19fUGCXEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menuitem"
parentId="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
<children xsi:type="menu:HandledMenuItem"
xmi:id="_aj-cgGCaEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
<elements xsi:type="menu:MenuContribution"
xmi:id="_e1RSkGCaEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menuitem"
parentId="menu:org.eclipse.ui.main.menu">
<children xsi:type="menu:HandledMenuItem"
xmi:id="_e1RSkWCaEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_QtvCEGCYEeK-fpTrs2yrzw" featurename="children"
parentElementId="org.eclipse.ui.main.menu">
<elements xsi:type="menu:Menu" xmi:id="_fsYLoGCYEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.menu" label="Ecore Tools Additions">
<children xsi:type="menu:HandledMenuItem"
xmi:id="_m81W8GCXEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_eLubwGCZEeK-fpTrs2yrzw" featurename="children"
parentElementId="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
<elements xsi:type="menu:HandledMenuItem"
xmi:id="_i8654GCZEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_wQ-UcGCaEeK-fpTrs2yrzw" featurename="children"
parentElementId="menu:org.eclipse.ui.main.menu">
<elements xsi:type="menu:HandledMenuItem"
xmi:id="_wQ-UcmCaEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</fragments>
</fragment:ModelFragments>
|
|
|
|
Re: How to contribute a new menu item in an existing menu via a fragment? [message #1001978 is a reply to message #1001936] |
Thu, 17 January 2013 16:32 |
Eclipse User |
|
|
|
Hi Joseph
one of my tries realises exactly what you wrote:
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_Q4ShsGCXEeK-fpTrs2yrzw" featurename="menuContributions"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution"
xmi:id="_g19fUGCXEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menuitem"
parentId="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
<children xsi:type="menu:HandledMenuItem"
xmi:id="_aj-cgGCaEeK-fpTrs2yrzw"
elementId="org.test.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses"
iconURI="platform:/plugin/org.test.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
</fragments>
I want to add the command to popup menu of the Ecore Tools Diagram
editor. Did I specify the property "parentId" right (I mean, is the
prefix "popup" needed)?
best regards,
Gilbert
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04888 seconds