Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Rendering MUIElement at Runtime(App Model Manipulation & Renderer Behavior)
icon3.gif  Rendering MUIElement at Runtime [message #675060] Mon, 30 May 2011 08:27 Go to next message
Kunal Prasad is currently offline Kunal PrasadFriend
Messages: 18
Registered: September 2009
Junior Member
In e4 Workbench, The model is rendered at runtime. That means changes to the model using code can directly result in change visibility in SWT Widgets.

Following this concept, I added new Menu and Handled MenuItems to mainMenu at runtime
after the model is loaded and rendered first. The runtime modification in the app model is visible using ALT+SHIFT+F9, however same is not display in the main menu as new Menu with its Menuitems. Apart from changing app model, what is more is expected in E4 to handle the visibility dynamic model elements. I am more interested to do same in the Legacy Application Model in compatibility mode once the whole model is loaded after parsing UI extensions or contributions.

Please suggest.

Thanks & Regards,
Kunal
Re: Rendering MUIElement at Runtime [message #675081 is a reply to message #675060] Mon, 30 May 2011 08:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Did you set the rendered and visible properties to true?

Tom

Am 30.05.11 10:27, schrieb Kunal:
> In e4 Workbench, The model is rendered at runtime. That means changes to
> the model using code can directly result in change visibility in SWT
> Widgets.
>
> Following this concept, I added new Menu and Handled MenuItems to
> mainMenu at runtime
> after the model is loaded and rendered first. The runtime modification
> in the app model is visible using ALT+SHIFT+F9, however same is not
> display in the main menu as new Menu with its Menuitems. Apart from
> changing app model, what is more is expected in E4 to handle the
> visibility dynamic model elements. I am more interested to do same in
> the Legacy Application Model in compatibility mode once the whole model
> is loaded after parsing UI extensions or contributions.
>
> Please suggest.
>
> Thanks & Regards,
> Kunal
Re: Rendering MUIElement at Runtime [message #675161 is a reply to message #675060] Mon, 30 May 2011 13:05 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What version of Eclipse 4 are you using (i.e. 4.1 SDK I20110529-2200)?

It also matters where exactly you added your item. To Application/Windows/Trimmed Window/Main Menu/Menu (&File) ?

PW


Re: Rendering MUIElement at Runtime [message #675276 is a reply to message #675161] Tue, 31 May 2011 02:21 Go to previous messageGo to next message
Kunal Prasad is currently offline Kunal PrasadFriend
Messages: 18
Registered: September 2009
Junior Member
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: Tue, 31 May 2011 03:44]

Report message to a moderator

Re: Rendering MUIElement at Runtime [message #675396 is a reply to message #675276] Tue, 31 May 2011 11:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Try adding a menu item element to an existing menu. Does that show up?

Yes, the renderers add listeners to the model, and try to keep the view up to date with the model changes.

PW


Re: Rendering MUIElement at Runtime [message #675624 is a reply to message #675396] Wed, 01 June 2011 03:36 Go to previous messageGo to next message
Kunal Prasad is currently offline Kunal PrasadFriend
Messages: 18
Registered: September 2009
Junior Member
I tried adding a Menu to '&File' as well as Menu item element to '&File'. Both got added into the legacy application model, but none of them were visible when checked in GUI. Crying or Very Sad Please suggest if there is any change required in class WorkbenchWindow to support this. I used below APIs before and after adding MUIElements to the application model.
workbench.largeUpdateStart();

//Add Menu item element to '&File' menu by finding it using id=file.

workbench.largeUpdateEnd();

Anything else needed more here, I tried below logic too, but not worked.

AbstractPartRenderer rendr = rendererFactory.getRenderer((MUIElement) targetParent, ((MUIElement) targetParent).getParent());
Object newWidget = engine.createGui((MUIElement) child, targetParent.getWidget(), model.getContext());
((MUIElement) child).setRenderer(rendr);

Kunal

[Updated on: Wed, 01 June 2011 03:50]

Report message to a moderator

Re: Rendering MUIElement at Runtime [message #675650 is a reply to message #675624] Wed, 01 June 2011 05:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Can you show us the code you use to make the addition to the model or
was it done using the model tooling?

Tom
Am 01.06.11 05:36, schrieb Kunal:
> I tried adding a Menu to '&File' as well as Menu item element to
> '&File'. Both got added into the application model in legacy application
> model, but none of them were visible when checked in GUI. Please suggest
> if there is any change required in class WorkbenchWindow to support this.
>
> Kunal
Re: Rendering MUIElement at Runtime [message #675712 is a reply to message #675650] Wed, 01 June 2011 09:24 Go to previous message
Kunal Prasad is currently offline Kunal PrasadFriend
Messages: 18
Registered: September 2009
Junior Member
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="&amp;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-- --------------------
Previous Topic:[ Databinding ] Error due to two ways of normalization
Next Topic:Problems with 4.1 RC on mac os x
Goto Forum:
  


Current Time: Thu Apr 25 06:15:24 GMT 2024

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

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

Back to the top