|
|
|
Re: Rendering MUIElement at Runtime [message #675276 is a reply to message #675161] |
Mon, 30 May 2011 22:21   |
Eclipse User |
|
|
|
I am currently using E4 Version: 4.1.0, Build id: I20110422-0200.
I was wondering if the renderer has any listener towards the application model. I mean whenever the model is modified or its set to dirty, the renderer will update itself to accommodate new/modified UI Elements, since explicitly calling renderer to update UI seems complex. Also I expected that if any user modifies the application model using ALT+SHIFT+F9, changes will reflect immediately, which is not the case now.
Right now, my intention is to add a new Menu to Main Menu e.g. Add "SVN" Menu and its children (Handled Menu-Items) just after "File" in the main menu. I am able to do this in the application model by code, but same is not reflected in UI. Suggest the steps to do so with kind of renderer needed to invoke. I guess visible flag set in the model for UI element should be sufficient to see if UI element needs to be rendered or not, explicitly setting it doesn't make sense setting same in the model. As of now, The visible and rendered flags are set for the UI Element in the application model, so I am looking for additional steps needed to display same in the GUI.
Regards,
Kunal
[Updated on: Mon, 30 May 2011 23:44] by Moderator
|
|
|
|
|
|
Re: Rendering MUIElement at Runtime [message #675712 is a reply to message #675650] |
Wed, 01 June 2011 05:24  |
Eclipse User |
|
|
|
I used a fragment to insert Menu and MenuItem in the legacy application model. the XMI for same is added below:
<?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="_Ne0RoIj8EeCYpOC1ICPLrQ">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_TK_KQIj8EeCYpOC1ICPLrQ" featurename="children" parentElementId="file" positionInList="after:new">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_6fpccIj8EeCYpOC1ICPLrQ" elementId="com.huawei.oneide.open" label="&Open" iconURI="platform:/plugin/E4MixPrj/icons/sample.gif" command="_b0B2sIv8EeCUFK2HEctMvg"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_Seg40Iv8EeCUFK2HEctMvg" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command" xmi:id="_b0B2sIv8EeCUFK2HEctMvg" elementId="myExit" commandName="MyExit"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_ja1QAIv8EeCUFK2HEctMvg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_owftIIv8EeCUFK2HEctMvg" elementId="MyExitCmd" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.ExitHandler" command="_b0B2sIv8EeCUFK2HEctMvg"/>
</fragments>
</fragment:ModelFragments>
The code I used above to combine/merge in Legacy Application Model is as below:
//---------------------------------- Existing Code in WorkbenchWindow.setup() ----------------------------------
MenuManagerRenderer renderer = (MenuManagerRenderer) rendererFactory.getRenderer(
mainMenu, null);
renderer.linkModelToManager(mainMenu, menuManager);
fill(renderer, mainMenu, menuManager);
model.setMainMenu(mainMenu);
Menu menu = (Menu) engine.createGui(mainMenu, model.getWidget(), model.getContext());
shell.setMenuBar(menu);
//------------------Added logic/code to merge E4 Fragment into Legacy Application Model--------------------
//Scan registry for "org.eclipse.core.runtime.products" extensions and filter them for "fragment"
//Load the XMI resource into object "resource"
//Check content.get(0) is instanceof MModelFragments
//For each fragment in fragments //See the logic already existing in class : ModelAssembler, same is used here.
//Perform fragment.merge(application) after setting the IDs & ContributionURIs
//-----------------End of code changes or additions for merge into legacy application-- --------------------
|
|
|
Powered by
FUDForum. Page generated in 0.05192 seconds