Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to create standalone model from .edit project in EMF?
How to create standalone model from .edit project in EMF? [message #1815588] Sun, 06 October 2019 14:44 Go to next message
Gurvir Bawa is currently offline Gurvir BawaFriend
Messages: 2
Registered: October 2019
Junior Member
I want to run my model (.genmodel) outside Eclipse (i.e. as a standalone model). I have done an extensive search on this. I know Edit projects can run standalone. For now I am trying to achieve this through a new plugin project. Below is the code. I am just not sure what is the correct method to achieve this. Any suggestions will be much appreciated. I am new to EMF, so don't know where to put in the main class i have written. Should it go under the Edit project or as a separate plugin?

import java.util.Collections;

import java.io.IOException;
import org.eclipse.emf.common.util.URI;
//import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
//import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;

import asdl.asdlPackage;



public class UsingEMFModel {
/** Create Resource Manager**/
public static void startResourceManager() {

/** Register factory**/
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());

/** Register package**/
asdlPackage.eINSTANCE.eClass();
}

/**Create ResourceSet**/
public static ResourceSet createResourceSet() {
ResourceSet rs= new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new EcoreResourceFactoryImpl());
rs.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap(false));
return rs;

}

public static void main(String[] args) {
// TODO Auto-generated method stub
/**Initiate Resource Manager**/
UsingEMFModel.startResourceManager();
ResourceSet rs=UsingEMFModel.createResourceSet();

/**Get URI for model**/
URI fileURI= URI.createPlatformPluginURI("platform:/resource/TestFullIntegration/DepartureIntegration/model/landingIntegration.ecore", false);

/**Load resource for the file**/
Resource resource=rs.getResource(fileURI,true);

try {
resource.save(System.out, Collections.EMPTY_MAP);

}
catch(IOException e) {}
}
}
Re: How to create standalone model from .edit project in EMF? [message #1815592 is a reply to message #1815588] Sun, 06 October 2019 15:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
It's best to ask about EMF on the EMF forum:

https://www.eclipse.org/forums/index.php?t=thread&frm_id=108

EMF will generate a simple example of how to use your generated model stand alone. Just invoke Generate Test Code and look for the XyzExample.java.; it's probably called asdlExample.java. This example shows how to load and save instances of your model and runs as a normal Java Application.
Previous Topic:Eclipse error [wont open]
Next Topic:'Updating Software' has encountered a problem.
Goto Forum:
  


Current Time: Sun Oct 20 06:06:21 GMT 2019

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

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

Back to the top