Unable to run org.eclipse.gef.examples.ediagram [message #643771] |
Wed, 08 December 2010 03:51  |
Eclipse User |
|
|
|
Hello,
For some references I tried to download the "org.eclipse.gef.examples.ediagram" example from CVS and run it. I try to create a new ecore file and I get a blank error message.
On further investigation it appears to me that the application is failing to create a new resource out of the resourceset. I guess it has something to do with the URI.
Would be great if anyone could help me out here.
Thanks,
Murthy
|
|
|
Re: Unable to run org.eclipse.gef.examples.ediagram [message #643776 is a reply to message #643771] |
Wed, 08 December 2010 04:15  |
Eclipse User |
|
|
|
Hi,
I have resolved the issue now.
I need to register my resource factory before creating the resource. So I create a method as below and call it as one of the first lines in the doFinish() method of 'NewEDiagramWizard'
private void registerFactory() {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
"ecore", new XMIResourceFactoryImpl() {
public Resource createResource(URI uri) {
XMIResource xmiResource = new XMIResourceImpl(uri);
return xmiResource;
}
});
}
After this, there was one last hurdle between me and the GEF editor, the package inclusion error.
So I modified the part in the doFinish() method as below.
doFinish(). . . .
if (ecoreResource == null) {
// The URI didn't match any existing file,so create a new one in the workspace
ecoreResource = rsrcSet.createResource(uri);
}
EPackage pckg = EcoreFactory.eINSTANCE.createEPackage();
pckg.setName("changeMe");
ecoreResource.getContents().add(pckg);
try {
ecoreResource.save(Collections.EMPTY_MAP);
} catch (IOException ioe) {
EDiagramPlugin.INSTANCE.log(ioe);
}
List contents = ecoreResource.getContents();
for (int j = 0; j < contents.size(); j++) {
diagram.getImports().add(contents.get(j));
}
Hope this helps someone is in similar situation.
Regards,
Murthy
|
|
|
Powered by
FUDForum. Page generated in 0.03989 seconds