The system is done by two plugins:
• org.eclipse.papyrus.infra.newchild
It has in charge to provide and construct swt.Menu from the ecore model. To do that the developer has to:
o instantiate a CreationMenuFactory,
o ask to get all Root model and populate it
CreationMenuFactory creationMenuFactory= new CreationMenuFactory(editingDomain);
ArrayList<Folder> folders= creationMenuRegistry.getRootFolder();
Iterator<Folder> iterFolder= folders.iterator();
while (iterFolder.hasNext()) {
Folder currentFolder= iterFolder.next();
creationMenuFactory.populateMenu(menu, currentFolder,eObject);
}
• org.eclipse.papyrus.views.modelexplorer.newchild
It has in charge to add menu in the model explorer of papyrus.
This the structure of EMF model for model
• CreationMenu
o It correspond to a menu
o The ElemenTypeIDRef correspond a reference to the element Type.
o The role can be filled in order to specify the role play by the element.
o If displayAllRole is set to true, it displays all roles played by the element if the number of roles is greater than 1. By default this property is true;
• Folder
o It is possible to add owns label an icon.
example of model menu.
<?xml version="1.0" encoding="ASCII"?>
<ElementCreationMenuModel:Folder
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ElementCreationMenuModel="http://ElementCreationMenuModel"
xsi:schemaLocation="http://ElementCreationMenuModel ../../../org.eclipse.papyrus.infra.newchild/resource/elementCreationMenuModel.ecore"
label="SimpleUMLTest">
<menu xsi:type="ElementCreationMenuModel:CreationMenu"
label="Package"
icon="platform:/plugin/org.eclipse.papyrus.infra.newchild.test/icon/O.gif"
elementTypeIdRef="org.eclipse.papyrus.uml.Package"/>
<menu xsi:type="ElementCreationMenuModel:CreationMenu"
label="Class"
elementTypeIdRef="org.eclipse.papyrus.uml.Class"/>
<menu xsi:type="ElementCreationMenuModel:Folder"
label="ElementWithFeature">
<menu xsi:type="ElementCreationMenuModel:CreationMenu"
label="NestedClass"
icon="platform:/plugin/org.eclipse.papyrus.infra.newchild.test/icon/M.gif"
elementTypeIdRef="org.eclipse.papyrus.uml.Class"
role="nestedClassifier"/>
<menu xsi:type="ElementCreationMenuModel:CreationMenu"
label="Integer"
elementTypeIdRef="org.eclipse.papyrus.uml.LiteralInteger"/>
<menu xsi:type="ElementCreationMenuModel:CreationMenu"
label="MyActivity"<!--display role-->
icon="platform:/plugin/org.eclipse.papyrus.infra.newchild.test/icon/O.gif"
elementTypeIdRef="org.eclipse.papyrus.uml.Activity"/>
</menu>
</ElementCreationMenuModel:Folder>