Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Load model created by GMF generated editor
Load model created by GMF generated editor [message #531680] Wed, 05 May 2010 18:47 Go to next message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 190
Registered: July 2009
Location: Dublin
Senior Member

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



Re: Load model created by GMF generated editor [message #531835 is a reply to message #531680] Thu, 06 May 2010 10:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31491
Registered: July 2009
Senior Member
Fredrico,

Probably you need to use GenericXMLResourceFactoryImpl for creating the
resource to load the *.mindmap file.


Federico Tomassetti wrote:
> 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\\EsempioM indmap\\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
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Load model created by GMF generated editor [message #531847 is a reply to message #531835] Thu, 06 May 2010 11:29 Go to previous messageGo to next message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 190
Registered: July 2009
Location: Dublin
Senior Member

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


Re: Load model created by GMF generated editor [message #531966 is a reply to message #531847] Thu, 06 May 2010 15:35 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31491
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/
Previous Topic:integration OCL validation in EMF generated editor
Next Topic:PackageNotFoundException: Package with uri ... not found
Goto Forum:
  


Current Time: Wed Sep 30 06:27:11 GMT 2020

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

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

Back to the top