Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » MApplication.getDescriptors() returns an empty list
MApplication.getDescriptors() returns an empty list [message #1041138] Sun, 14 April 2013 17:38 Go to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
When I call MApplication.getDescriptors() (e.g. in a handler), I see the method returning an empty list. In my application model, I defined various parts and, thus, I'd rather expect a non empty list of MPartDescriptor instances, one for each xsi:type="basic:Part" element I defined in my application model.

Do I have to do something for that I get the expected result?

The background of my question is that the org.eclipse.e4.ui.internal.workbench.swt.handlers.ShowViewHandler displays an empty dialog window in my pure E4 application.
Re: MApplication.getDescriptors() returns an empty list [message #1043872 is a reply to message #1041138] Thu, 18 April 2013 08:06 Go to previous messageGo to next message
Eclipse UserFriend
In a pure e4 context, defining a MPart does not automatically mean defining a MPartDescriptor. MPDs are different things in terms of model elements. The MApplication#getDescriptors() will return the list of MPartDescriptors that were explicitly defined, be it programmatically or through the tooling editor.
Re: MApplication.getDescriptors() returns an empty list [message #1045156 is a reply to message #1041138] Fri, 19 April 2013 21:31 Go to previous messageGo to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
Thank you, Sopot, for your reply.
Thanks to this hint I added some descriptors nodes to my application model (having the tags 'View' and 'categoryTag:My Category'). Now, the ShowViewHandler works as expected.

How can I define a PartDescriptor in a model fragment?

I tried it straight forward by adding an element xsi:type="basic_1:PartDescriptor" to the fragments node (in the fragments model). Doing this, however, results in the following error at startup time:
===
java.lang.ClassCastException: org.eclipse.e4.ui.model.application.descriptor.basic.impl.PartDescriptorImpl cannot be cast to org.eclipse.e4.ui.model.application.ui.MUIElement
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl$1.validate(ElementContainerImpl.java:1)
at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:437)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:387)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:371)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:339)
at org.eclipse.e4.ui.model.internal.ModelUtils.mergeList(ModelUtils.java:201)
at org.eclipse.e4.ui.model.internal.ModelUtils.merge(ModelUtils.java:135)
at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.merge(StringModelFragmentImpl.java:288)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:167)
at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:220)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:366)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:220)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:132)
at org.elbe.relations.internal.RelationsApplication.start(RelationsApplication.java:60)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
===
Here is the element I added to the fragment e4xmi:
===
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_telpcKk1EeKhmYrZRO6sPg" label="My View" iconURI="platform:/plugin/org.elbe.relations.defaultBrowser/icons/relations.gif" tooltip="My View" contributionURI="bundleclass://org.elbe.relations.defaultBrowser/org.elbe.relations.defaultbrowser.internal.DefaultBrowserPart">
<tags>View</tags>
<tags>categoryTag:My Category</tags>
</elements>
===

Re: MApplication.getDescriptors() returns an empty list [message #1046705 is a reply to message #1045156] Mon, 22 April 2013 08:52 Go to previous messageGo to next message
Eclipse UserFriend
The casting to MUIElement is weird. What's the parent you are trying to stick the PartDescriptor to? If you're not sure paste the whole fragment.e4xmi.
Re: MApplication.getDescriptors() returns an empty list [message #1048250 is a reply to message #1046705] Wed, 24 April 2013 08:12 Go to previous messageGo to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
I've just added a PartDescriptor to the collection of Elements in the Model Fragment editor.
Therefore, the parent is a xsi:type="fragment:StringModelFragment" node.

Here's the fragment.e4xmi:

<?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:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:basic_1="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" 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" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_UUOPgDTFEeKJCcF8Dmjvqg">
<imports xsi:type="commands:Command" xmi:id="_-qVgAEI4EeK4WpHp4ZQ4aQ" elementId="org.elbe.relations.command.item.edit"/>

<fragments xsi:type="fragment:StringModelFragment" xmi:id="_gwxPwDTFEeKJCcF8Dmjvqg" featurename="children" parentElementId="relations.views" positionInList="first">

<elements xsi:type="basic:Part" xmi:id="_yf8x0DTGEeKJCcF8Dmjvqg" elementId="org.elbe.relations.browser.default" contributionURI="bundleclass://org.elbe.relations.defaultBrowser/org.elbe.relations.defaultbrowser.internal.DefaultBrowserPart" label="Relations" iconURI="platform:/plugin/org.elbe.relations.defaultBrowser/icons/relations.gif" tooltip="Relations" bindingContexts="_UsLV0EJVEeK4WpHp4ZQ4aQ" closeable="true">
<menus xsi:type="menu:PopupMenu" xmi:id="_KOgOIEI2EeK4WpHp4ZQ4aQ" elementId="org.elbe.relations.defaultbrowser.popup">
<children xsi:type="menu:HandledMenuItem" xmi:id="_XbYfIEI2EeK4WpHp4ZQ4aQ" elementId="defaultbrowser.popup:item.edit" label="ausgew&#xe4;hltes Item: editieren" iconURI="platform:/plugin/org.elbe.relations.defaultBrowser/icons/edit.gif" tooltip="" command="_-qVgAEI4EeK4WpHp4ZQ4aQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_Uvnh0EJJEeK4WpHp4ZQ4aQ" coreExpressionId="org.elbe.relations.definition.browser.popup.item"/>
</children>
</menus>
</elements>

<elements xsi:type="basic_1:PartDescriptor" xmi:id="_telpcKk1EeKhmYrZRO6sPg" label="My View" iconURI="platform:/plugin/org.elbe.relations.defaultBrowser/icons/relations.gif" tooltip="My View" contributionURI="bundleclass://org.elbe.relations.defaultBrowser/org.elbe.relations.defaultbrowser.internal.DefaultBrowserPart">
<tags>View</tags>
<tags>categoryTag:My Category</tags>
</elements>

</fragments>
</fragment:ModelFragments>
Re: MApplication.getDescriptors() returns an empty list [message #1048273 is a reply to message #1048250] Wed, 24 April 2013 08:42 Go to previous message
Eclipse UserFriend
No, no don't do it that way. When I say parent I don't mean the parent in the left-side tree in the editor. Every model element you add in the fragment has to have a parent in the main application model. Suppose you have two part stacks in the main model and you add a part through a fragment. In order to resolve ambiguity (which of the two part stacks you should add the part to?) you supply the ID of the parent model element (the correct part stack). Add the descriptor but in the model fragment metadata add it as a 'child' (feature) of your MApplication (supply the MApp's id and 'descriptors' featurename).

Ultimately it should look something like :

<fragments xsi:type="fragment:StringModelFragment" xmi:id="_hmhn4Ky6EeKLN_c01nrL9A" featurename="descriptors" parentElementId="org.eclipse.e4.ide.application">
    <elements xsi:type="basic:PartDescriptor" xmi:id="_hmhn4ay6EeKLN_c01nrL9A" elementId="popupmenutest.partdescriptor.0"/>
  </fragments>
Previous Topic:exporting cdo server feature product
Next Topic:Changing MenuItem Text when contributed via plugin.xml in 3.8.1 (4.2.1)
Goto Forum:
  


Current Time: Fri Apr 19 01:27:03 GMT 2024

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

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

Back to the top