eclipse-emf

How to extend an EMF-based model with listeners for use in a GEF editor?

蓝咒 提交于 2019-12-11 04:12:40
问题 I am creating an Eclipse RCP with a GEF editor and an EMF -based model. One thing that is mentioned about the model in the GEF Book is The model should broadcast all state changes via listeners so that the view can be updated without the model having any direct knowledge of the controller or view. In the book's example, each model element class, e.g., Person , Marriage , etc. (the example is a genealogy editor), has methods to add and remove the respective listener, e.g., for Person the are:

Parse XML in string format using EMF

泪湿孤枕 提交于 2019-12-11 03:11:05
问题 I have used EMF to generate XSD-based access functions. I could see how to load input from a disk-file in the examples generated. However, the XML that I want to parse is stored in a string. Is there any way I can proceed without dumping the string into a file and then reading it back? 回答1: Here is an example method, takes in your modelString and the ECorePackage instance that parses the xml and returns the EObject. public static EObject loadEObjectFromString(String myModelXml, EPackage

How to generate 'java code with annotations' from emf model

橙三吉。 提交于 2019-12-10 14:37:53
问题 More precisely, I want to know, how one can model annotations into the ecore model definition. So that the generated java code would contain them. (For eg: hibernate persistence tags) 回答1: I don't think you can to this out of the box. However, you could look into the parameters of the " .genmodel " file to see if you can tweak how annotations ( EAnnotations ) are being output to the files. The problem with code generation templates is that they are fixed, but maybe through some option in the

Create GMF diagram programmatically

旧时模样 提交于 2019-12-10 00:03:32
问题 I trying to create one simple diagram using EMF & GMF in Eclipse plug-ins. I have created one Ecore with two node & connection. I am able to generate GMF out of that. When I run my application I am getting the palate and with the help of that I am able to draw the GMF diagram. But I want that programmatically. I have created one XML out of that Ecore and successfully able to load that XML into the EMF object. So my EObject is having that XML values. Now I want a GMF diagram out of that

QVT transformation applied to UML (XMI) models exported from Rhapsody

有些话、适合烂在心里 提交于 2019-12-08 12:45:44
问题 I guess this is quite a strange question about models transformation. I am starting from a UML 2.2 model defined with Rhapsody (IBM/Telelogic) and exported in XMI by means of the Rhapsody XMI toolkit. I have succesfully opened it with Topcased (The Eclipse based UML/Sysml modeling environment). I have therefore applied a QVT transformation to it, aimed at creating a new UML model with a specific subset of entities. Unfortunately i have not found the right way to retrieve entities description

How to merge EMF models programmatically in Java?

雨燕双飞 提交于 2019-12-07 03:52:13
问题 Is there a way to combine multiple Ecore models (2 or more) in a single Ecore model programmatically in Java? With all models conform to the same metamodel. In: Model1 conforming to metamodelX Model2 conforming to metamodelX model3 conforming to metamodelX model4 conforming to metamodelX model5 conforming to metamodelX Out: modelOut conforming to metamodelX and merge of Model1, Model2, model3, model4, model5 ... 回答1: There is Eclipse project for handling EMF comparing and Merging, called EMF

Create and modify ecore files and their instances from code

混江龙づ霸主 提交于 2019-12-06 15:25:01
问题 My question has two parts: 1) How can I create and/or modify and then store EMF ecore files (ecore metamodels with .ecore suffixes) from my scala/java code? 2) How can I create and/or modify an instance of an ecore file (i.e. a model conforming to an ecore metamodel) from my scala/java code? I am looking to see if there are some possible ways of doing these, other that manipulating directly their corresponding XML files using XML API's. Providing a code spinet or a reference to it is very

“Registered factory needed” exception when loading resource

人盡茶涼 提交于 2019-12-05 18:02:49
I get the following exception: java.lang.RuntimeException: Cannot create a resource for 'file:/home/my_conf.xml'; a registered resource factory is needed The "explosion" code is like this and stops at: resource = resourceSet..... ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = null; File f = new File(filename); URI uri = URI.createFileURI(f.getAbsolutePath()); if (!f.exists()) { throw new Exception(filename + " does not exist"); } else { resource = resourceSet.getResource(uri, true); mapPrepConfiguration = (MapPrepConfiguration) resource.getContents().get(0); } Is there

How to export Xcore to Ecore?

对着背影说爱祢 提交于 2019-12-05 13:27:41
Defining metamodels with Xcore is a lot easier than with EMF and Ecore. The problem is that I need the metamodels as Ecore files. Is it possible to export Xcore model to Ecore model? I don't see any export options in Eclipse. The official Wiki describes how to export an Xcore model to a GenModel. It looks like the same can be done with the Ecore Model. Especially because the author mentions: [...] Xcore resource does physically contain a GenModel and an Ecore model [...] 来源: https://stackoverflow.com/questions/15966601/how-to-export-xcore-to-ecore

How to merge EMF models programmatically in Java?

若如初见. 提交于 2019-12-05 07:01:08
Is there a way to combine multiple Ecore models (2 or more) in a single Ecore model programmatically in Java? With all models conform to the same metamodel. In: Model1 conforming to metamodelX Model2 conforming to metamodelX model3 conforming to metamodelX model4 conforming to metamodelX model5 conforming to metamodelX Out: modelOut conforming to metamodelX and merge of Model1, Model2, model3, model4, model5 ... There is Eclipse project for handling EMF comparing and Merging, called EMF Compare. Here is example provided by them: // Loading models EObject model1 = ModelUtils.load(model1,