Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318059

Summary: e4 photo demo: fragment merge issue in case of duplicate application element ids
Product: [Eclipse Project] e4 Reporter: Eduard Bartsch <eduard.bartsch>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Lars.Vogel
Version: 1.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Eduard Bartsch CLA 2010-06-25 18:49:17 EDT
e4 photo demo (org.eclipse.e4.demo.e4photo) defines two menus (a main menu and a view menu) with same id (org.eclipse.e4.ide.app.menu.file) in Application.e4xmi: 
...
<mainMenu xmi:id="_9rNPkUjTEd-v7fhjaiz65w" elementId="_9rNPkUjTEd-v7fhjaiz65w">
  <children xsi:type="menu:Menu" xmi:id="_E5HnwEjUEd-v7fhjaiz65w" 
       elementId="org.eclipse.e4.ide.app.menu.file" label="File">
...
<children xsi:type="basic:Part" xmi:id="_LYVTMEleEd-TVO58rzJVgA"
   elementId="_LYVTMEleEd-TVO58rzJVgA" contributionURI="..." label="Library">
     <menus xmi:id="_E5HnwEjUEd-v7fhjaiz65w"
        elementId="org.eclipse.e4.ide.app.menu.file" label="File">
...

SFS photo demo application(/cvsroot/eclipse/e4/org.eclipse.e4.resources/examples/org.eclipse.e4.demo.e4photo.withSFS) extends the e4 photo demo with an additional menu item using fragment.e4xmi:

...
<fragments xsi:type="fragment:StringModelFragment" 
    xmi:id="_OPAnEIBhEd-g6O-Z5GM-fw" featurename="children" 
    parentElementId="org.eclipse.e4.ide.app.menu.file">
      <elements xsi:type="menu:HandledMenuItem" 
                xmi:id="_VraP8HlKEd-scPKZUqTcjQ" 
                label="Create Album on Semantic File System"  
                command="_c0nHQHlKEd-scPKZUqTcjQ"/>
</fragments>
...

The above menu item with label "Create Album on Semantic File System" is attached only to the view menu of the part "Library" and doesn't appear on main menu (which is my actual intention).

I have checked the implementation. It looks like the method public List<MApplicationElement> merge(MApplication application) from StringModelFragmentImpl only looks for the first occurence of an application element with a particular id.

I see two options. Either the same id may appear multiple times and the merge method must attach fragment's children to all application elements with the same id. Or an id must be unique so that we need a fix for Application.e4xmi of e4 photo demo.
Comment 1 Paul Webster CLA 2010-06-27 07:48:39 EDT
I've changed the view menu to be org.eclipse.e4.demo.e4photo.Library.viewMenu as a temporary workaround.

PW
Comment 2 Lars Vogel CLA 2012-11-14 14:57:00 EST
ID in the application model must be unique. Closing as fixed with Pauls change.