Load model created by GMF generated editor [message #531680] |
Wed, 05 May 2010 18:47 |
|
I am having an hard time trying to load a model created by a GMF generated editor.
In example following the GMF Tutorial I created a diagram editor that generates "*.mindmap" files.
How can I load them programmatically or through a MWE component?
I tried programmatically in this way:
String modelFileName = "C:\\Users\\FedericoTomassetti\\Documents\\My Dropbox\\Poli\\bMooble\\runtime-EclipseApplication\\EsempioMindmap\\default.mindmap";
XMLResourceFactoryImpl resourceFactory = new XMLResourceFactoryImpl();
String ecoreFilename = "C:\\Users\\FedericoTomassetti\\Documents\\My Dropbox\\Poli\\bMooble\\sandbox2-workspace\\Mindmap\\model\\mindmap.ecore";
URI modelURI = URI.createFileURI(modelFileName);
Resource modelResource = resourceFactory.createResource(modelURI);
URI ecoreURI = URI.createFileURI(ecoreFilename);
EcoreResourceFactoryImpl ecoreResourceFactory = new EcoreResourceFactoryImpl();
Resource ecoreResource = ecoreResourceFactory.createResource(ecoreURI);
Map xmlOptions = new HashMap();
try {
ecoreResource.load(xmlOptions);
EPackage packagez = (EPackage)ecoreResource.getContents().get(0);
EPackage.Registry.INSTANCE.put(packagez.getNsURI(),packagez);
modelResource.load(xmlOptions);
} catch (IOException e) {
e.printStackTrace();
}
Obtaining this error:
Caused by: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'map' is not found or is abstract. (file:/C:/Users/FedericoTomassetti/Documents/My%20Dropbox/Po li/bMooble/runtime-EclipseApplication/EsempioMindmap/default .mindmap, 2, 61)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2243)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2234)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1332)
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.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
... 4 more
I do not understand where I am wrong, could someone indicate my errors?
Thank you,
Federico
website: http://www.federico-tomassetti.it
|
|
|
|
|
Re: Load model created by GMF generated editor [message #531966 is a reply to message #531847] |
Thu, 06 May 2010 15:35 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Fredrico,
Probably it's best to ask MWE questions on the EMFT newsgroup because I
doubt they'll see your question here.
Federico Tomassetti wrote:
> You are right, the GenericXMLResourceFactoryImpl works.
>
> The XMLResourceFactoryImpl() works only if I set the option
> org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_ FEATURE
> to true.
>
> Does exist a MWE Component to load models through the
> GenericXMLResourceFactoryImpl or should I write it by myself?
>
> Thank you again,
> Federico
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04292 seconds