Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » e4 compatability layer: add menu item in default file menu
e4 compatability layer: add menu item in default file menu [message #725316] Wed, 14 September 2011 13:54 Go to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 57
Registered: September 2009
Member
Hello,
I'm using e4 with the compatibility layer in order to include an EMF generated editor in a RCP application.

My product definition is based on "org.eclipse.ui.ide.workbench" application.
So when I launch my product, an current eclipse is launched containing my generated editor. It's OK.

Now, I would like to add a menu in the default "File" menu.

I added a fragment.e4xmi in my generated editor. This fragment contains:

<?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="_xg7kcN6wEeCXR5SkB_wTuQ">
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_34imwN6wEeCXR5SkB_wTuQ" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:Command" xmi:id="_737YAN6xEeCXR5SkB_wTuQ" elementId="saveAsXML" commandName="Save as XML"/>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_RtL0EN6yEeCXR5SkB_wTuQ" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:Handler" xmi:id="_DOWzAN6yEeCXR5SkB_wTuQ" elementId="SaveAsXMLHandler" contributionURI="platform:/plugin/Camping.editor/camping.presentation.SaveXMLHandler" command="_737YAN6xEeCXR5SkB_wTuQ"/>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_YvLQIN6yEeCXR5SkB_wTuQ" featurename="children" parentElementId="file" positionInList="">
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_KP48EN6yEeCXR5SkB_wTuQ" elementId="saveAsXMLItem" label="Save as XML" command="_737YAN6xEeCXR5SkB_wTuQ"/>
  </fragments>
</fragment:ModelFragments>



My menu doesn't appear in the File menu. D you know why ?

Thanks in advance.
Re: e4 compatability layer: add menu item in default file menu [message #725325 is a reply to message #725316] Wed, 14 September 2011 14:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5419
Registered: July 2009
Senior Member
Hi,

I suppose the file menu is created by the compat layer (through the
ApplicationActionBarAdvisor).

I haven't looked at the code yet but my guess is that the problem is the
order in which the model assembling happens

a) Load the base XMI (=legacy.e4xmi)
b) Merge in the fragment.e4xmi and execute processors
c) Merge in compat layer created stuff
* The stuff defined through the advisor
* The stuff defined by the extension points

The only solution I can think of in 4.1 is to move the file-menu
definition directly into the the base xmi and remove it from the adivsor
or plugin.xml.

I think it would make sense that we'd add support to the extension point
where you contribute the plugin so that we execute the merge after the
compat layer has finished his job.

Tom

Am 14.09.11 15:54, schrieb val.dupin:
> Hello,
> I'm using e4 with the compatibility layer in order to include an EMF
> generated editor in a RCP application.
>
> My product definition is based on "org.eclipse.ui.ide.workbench"
> application.
> So when I launch my product, an current eclipse is launched containing
> my generated editor. It's OK.
>
> Now, I would like to add a menu in the default "File" menu.
>
> I added a fragment.e4xmi in my generated editor. This fragment contains:
>
> <?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="_xg7kcN6wEeCXR5SkB_wTuQ">
> <fragments xsi:type="fragment:StringModelFragment"
> xmi:id="_34imwN6wEeCXR5SkB_wTuQ" featurename="commands"
> parentElementId="org.eclipse.e4.legacy.ide.application">
> <elements xsi:type="commands:Command"
> xmi:id="_737YAN6xEeCXR5SkB_wTuQ" elementId="saveAsXML" commandName="Save
> as XML"/>
> </fragments>
> <fragments xsi:type="fragment:StringModelFragment"
> xmi:id="_RtL0EN6yEeCXR5SkB_wTuQ" featurename="handlers"
> parentElementId="org.eclipse.e4.legacy.ide.application">
> <elements xsi:type="commands:Handler"
> xmi:id="_DOWzAN6yEeCXR5SkB_wTuQ" elementId="SaveAsXMLHandler"
> contributionURI="platform:/plugin/Camping.editor/camping.presentation.SaveXMLHandler"
> command="_737YAN6xEeCXR5SkB_wTuQ"/>
> </fragments>
> <fragments xsi:type="fragment:StringModelFragment"
> xmi:id="_YvLQIN6yEeCXR5SkB_wTuQ" featurename="children"
> parentElementId="file" positionInList="">
> <elements xsi:type="menu:HandledMenuItem"
> xmi:id="_KP48EN6yEeCXR5SkB_wTuQ" elementId="saveAsXMLItem" label="Save
> as XML" command="_737YAN6xEeCXR5SkB_wTuQ"/>
> </fragments>
> </fragment:ModelFragments>
>
>
> My menu doesn't appear in the File menu. D you know why ?
>
> Thanks in advance.
Re: e4 compatability layer: add menu item in default file menu [message #725337 is a reply to message #725325] Wed, 14 September 2011 14:42 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 57
Registered: September 2009
Member
Hi Tom,

Thanks for your reply.

When you said:
"The only solution I can think of in 4.1 is to move the file-menu
definition directly into the the base xmi and remove it from the adivsor
or plugin.xml."


You mean:

1- Create a new file-menu definition in my e4xmi definition, in other words my file-menu ?

2- And remove the existing file-menu from the plugin.xml placed in my application project ? programmatically I think ?

Re: e4 compatability layer: add menu item in default file menu [message #725386 is a reply to message #725337] Wed, 14 September 2011 15:29 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5419
Registered: July 2009
Senior Member
Am 14.09.11 16:42, schrieb val.dupin:
> Hi Tom,
>
> Thanks for your reply.
>
> When you said:
> "The only solution I can think of in 4.1 is to move the file-menu
> definition directly into the the base xmi and remove it from the adivsor
> or plugin.xml."
>
> You mean:
>
> 1- Create a new file-menu definition in my e4xmi definition, in other
> words my file-menu ?

yes i guess you copied the default legacy.e4xmi to your project.

>
> 2- And remove the existing file-menu from the plugin.xml placed in my
> application project ? programmatically I think ?
>
>

Yes dependending on where the file-menu entry is created. In many
RCP-Applications it is created through the ActionbarAdvisor.

Tom
Re: e4 compatability layer: add menu item in default file menu [message #725387 is a reply to message #725337] Wed, 14 September 2011 15:29 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5419
Registered: July 2009
Senior Member
Am 14.09.11 16:42, schrieb val.dupin:
> Hi Tom,
>
> Thanks for your reply.
>
> When you said:
> "The only solution I can think of in 4.1 is to move the file-menu
> definition directly into the the base xmi and remove it from the adivsor
> or plugin.xml."
>
> You mean:
>
> 1- Create a new file-menu definition in my e4xmi definition, in other
> words my file-menu ?

yes i guess you copied the default legacy.e4xmi to your project.

>
> 2- And remove the existing file-menu from the plugin.xml placed in my
> application project ? programmatically I think ?
>
>

Yes dependending on where the file-menu entry is created. In many
RCP-Applications it is created through the ActionbarAdvisor.

Tom
Previous Topic:Disable drag and drop to detached window?
Next Topic:How to update menu after uninstall fragment contribution bundle ?
Goto Forum:
  


Current Time: Thu Oct 23 16:36:14 GMT 2014

Powered by FUDForum. Page generated in 0.01718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software