Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Problems extending the application model with PartDescriptor's.
Problems extending the application model with PartDescriptor's. [message #567852] Tue, 19 January 2010 11:17 Go to next message
Jens Keller is currently offline Jens Keller
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
Hello,

i tried to extend my application model with PartDescriptor's and took the photo demo and org.eclipse.e4.ide.application as an example. So i created an components.e4xmi file with one descriptor and registered it through the org.eclipse.e4.workbench.model extension point. But when i start the application i get the following error:

java.lang.ClassCastException: org.eclipse.e4.ui.model.application.impl.ModelComponentsImpl cannot be cast to org.eclipse.e4.ui.model.application.MApplicationElement
at org.eclipse.e4.workbench.ui.internal.E4XMIResource.getID(E4X MIResource.java:82)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.attachedHelpe r(XMLResourceImpl.java:460)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.attached(Re sourceImpl.java:859)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:416)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:318)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processTopObject(X MLHandler.java:1484)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1336)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
......

I'm also getting a FeatureNotFoundException (for label, ModelComponents, containerData etc.) when i try to open the e4xmi-files with the emf-editor and i don't have these features as design-elements in the context-menu.

I'm using eclipse 3.6M4 and e4M3 as target.


Thanks in advance,

Jens Keller
Re: Problems extending the application model with PartDescriptor's. [message #568075 is a reply to message #567852] Wed, 27 January 2010 09:15 Go to previous messageGo to next message
Remy Suen is currently offline Remy Suen
Messages: 462
Registered: July 2009
Senior Member
Jens Keller wrote on Tue, 19 January 2010 11:17
> But when i start the application i get the following error:
>
> java.lang.ClassCastException: org.eclipse.e4.ui.model.application.impl.ModelComponentsImpl cannot be cast to org.eclipse.e4.ui.model.application.MApplicationElement
> at org.eclipse.e4.workbench.ui.internal.E4XMIResource.getID(E4X MIResource.java:82)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.attachedHelpe r(XMLResourceImpl.java:460)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.attached(Re sourceImpl.java:859)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:416)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:318)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processTopObject(X MLHandler.java:1484)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1336)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
Please open a bug about this in Bugzilla.
Re: Problems extending the application model with PartDescriptor's. [message #568162 is a reply to message #568075] Thu, 28 January 2010 09:51 Go to previous message
Jens Keller is currently offline Jens Keller
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
I found the solution. I forgot the xmi:id-attribut in the application element of the components.e4xmi-file.


Thats the steps i took to integrate a PartDescriptor (which i can now use at runtime but now i'm having problems showing this part):

I used two plugins de.sampleapp.client & de.sampleapp.data.ui

1. create a e4xmi-file to define the PartDescriptor in the de.sampleapp.data.ui plugin

<?xml version="1.0" encoding="ASCII"?>
<application:ModelComponents xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:application="http://www.eclipse.org/ui/2008/UIModel"
xsi:schemaLocation="http://www.eclipse.org/ui/2008/UIModel ../../org.eclipse.e4.ui.model.workbench/model/UIElements.eco re " xmi:id="which_i_forgot">
<components parentID="sampleApp">
<descriptors
URI=" platform:/plugin/de.sampleapp.data.ui/de.sampleapp.data.ui.T estView "
label="TestView"
category="viewStack"/>
</components>
</application:ModelComponents>


2. register this components.e4xmi definition via an extension in the de.sampleapp.data.ui plugin

<extension
id="SampleApp"
name="SampleApp"
point="org.eclipse.e4.workbench.model">
<snippet
uri="xmi/components.e4xmi">
</snippet>
</extension>


3. use the PartDescriptor in the de.sampleapp.client plugin in a self defined action

public void perform( MyActionEvent event ) {
IEclipseContext context = event.getContext();
MWindow window = (MWindow) context.get( EPartService.PART_SERVICE_ROOT );
MApplication app = (MApplication) (MUIElement) window.getParent();
EList<MPartDescriptor> desc = app.getDescriptors();

EPartService serviceP = (EPartService) context.get( EPartService.class.getName() );
if( !desc.isEmpty()){
serviceP.showPart( desc.get( 0 ).getId() );
Collection<MPart> partCollection = serviceP.getParts();
}
}

The PartDescriptor is now in the descriptor list of the MApplication and i can call EPartService.showPart() without an error
and after that the part is in the Collection of the EPartService.getParts() method. But the problem is, that the part
doesn't show up in the application.

And thats the part i try to show:

public class TestView {

@Inject
private Composite parent;

private Image image;

@PostConstruct
void init(){
parent.setLayout(new FillLayout());
image = new Image(Display.getDefault(),getClass().getResourceAsStream( "/images/karte.jpg" ));
Canvas canvas = new Canvas(parent,SWT.NO_REDRAW_RESIZE);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(image,0,0);
}
});
}

@PreDestroy
void dispose(){
if(!image.isDisposed())
image.dispose();
}
}
Previous Topic:Showing menu in e4 application
Next Topic:Problems extending the application model with PartDescriptor's.
Goto Forum:
  


Current Time: Wed Aug 20 02:53:18 EDT 2014

Powered by FUDForum. Page generated in 0.10382 seconds