Eclipse GMF is very exciting technolgy. Unfotunately, it is not very easy to understand. The tutorials that can be found about GMF on the Internet are not always detailed enough.
This project aims to give a few samples to help people interested in GMF to get into that technology with step by step examples.
As GMF is deeply coupled to EMF, you will also find a few resources about EMF.
The code can be retreived via subversion (https://gmfsamples.svn.sourceforge.net/svnroot/gmfsamples). It is also made available through the File Manager
feature of sourceforge (https://sourceforge.net/projects/gmfsamples/files/).
I hope that this material will be helpful for you. If you want to support it, your help is welcome :
DiagramAppearancePreferencePage
class (in the xx.diagram.preferences
package)/** * @generated NOT */ public DiagramAppearancePreferencePage() { IPreferenceStore store = BowtieDiagramEditorPlugin.getInstance() .getPreferenceStore(); setPreferenceStore(store); FontData defaultFont = new FontData("Verdana", 7, SWT.NONE); PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_DEFAULT_FONT, defaultFont); }
Discussion
Hello, (sorry for my poor english) I'm working in an editor with GMF and i'm new on it. I have a problem that i should solve as soon as possible!!! SO, here is the situation: I have a diagram which contains an element “components” , when i double click on it, another diagram should be open in which is initialized some elements :” activities”, “roles”, …
The double click works, and when i was working on the sub-diagram only, elements are initialized without problem. But when i link between the two diagrams, elements “activites, roles”.. are not initialized when i double click !!
DO YOU HAVE ANY IDEA??
HELP, PLEASEEEE
Hello Hejer…
Can you send me your code to let me try to help you ?
I'm afraid it may be hard to help you with the informations that you provided…..
JFB
Hello, I'm using GMF and i'm trying to do the same thing. I would like, after double-clicking on an object on the diagram, to open a sub diagram? i'm searching for three weeks now, can you help me please????
You should take a look at this : http://www.jevon.org/wiki/GMF_Diagram_Partitioning
HI,
Please let me know how to disable all edit options,
1) Editing Tool, 2) Mouse over, 3) Palette
I don't know if I really understand. Do you want your diagram to be all the time in a read only mode ? Or do you want your editor to get readonly after a special event ?
Hello,
I'm new to GMF and I am trying to generate my first graphical Editor with it. I created an Ecore with several classes and relationships between them. Also I was able to create an editor out of it. But now I have a palette with several links on it. well i guess its a correct behaviour because my domain model has several relationships but I want an graphical editor just with one link, representing every relationship. Can you please tell me how I can get this feature in GMF? I searched in the book from Gronback and I also read several tutorials but I cant find a clue how to get this.
I am also working with the former DSL Tools in Visual Studio and I can get this feature, to have one link for every relationship, with a connection builder. But I cant find a similiar function in GMF.
I hope you can help me.
Kind regards
Jan Gewald
Hello Jan,
As far as I can see, GMF classically needs one tool in the palette per relation. It is understandable, if you have two relations between to EClasses for example, GMF should not know which relation you would like to create with a unique tool. Nevertheless, I think it is probably possible to get the result you want but you will have to customize the code by yourself.
Take a look at the
createXXXXTool
methods in yourXXXPaletteFactory
⇒ ALinkToolEntry
is instanciated with a unique relationship type. Maybe if you add other relations type, you will get the result you are expected.Regards,
JFB
Hi , thank you very much for this tutorial. I want to do an editor based GMF. I want to use the Jena Framework for validation in this editor.But I'm new GMF and I don't know where to start.Do you have resources you can recommend me to read. I'll be glad if you help.
Hello Mary,
I'm sorry, I have never used Jena Framework. Maybe could you find some interesting stuff here : http://www.jevon.org/wiki/OWL_Validation_with_Jena
Regards,
JFB
Dear Jean,
I'm doing a research, in which I have to create a GMF editor for a software process language named UMLPP. UMLPP uses UML2.0 heavyweight extension mechanism (It extends some UML classes ex: Classifier, Element, DirectedRelationship …). I've already create the umlpp.ecore and umlpp.genmodel. I use uml.ecore available in eclipse. When generating model code, edit code and editor code. I face with many errors. Most of them said that : I have to implement abstract operations from UML class (For example : AbstractProcessPatternImpl must implement the inherited abstract method ActivityNode.getIncoming(String, boolean, EClass) AbstractProcessPatternImpl)
I can't go on to create the gmftool, gmfgraph and gmfmap without overcome this problem. Could you please give me some suggestions to solve this? Thanks in advance and wish you sucess
Hum… How strange is your problem… It seems that you have interfaces with methods that are not implemented in your implementation class. By default, EMF generates the interfaces and implementation together. Have you added custom method in the model interfaces ? Could you send me your code (with your EMF file : ecore, …).
Hello, I'm creating Navigation design editor for android platform in GMF. In the generated editor, I'm able to create a model diagram, a model code in XMI is automatically created. I need to create java code and XML files from the diagram instead of the automatically created XMI code. Is it possible to do that? How? Please help.
If you are using the EMF tree editor, then the java code of your model has been generated (as the editor needs these classes). XMI is the persistent format used by the EMF tree editor to save the data. If you want to uses Java classes, you have to directly use the generated java classes of your model and/or load the file you've created with your editor. Maybe this page should be helpful : http://www.vogella.de/articles/EclipseEMFPersistence/article.html Hope it helps.
Hello,
I want to create a Class Diagram palette with GFM that allow to users drawing Class Diagrams, the problem is that i can't find an Ecore metamodel of the Class Diagram alone, all that i found is an Ecore of all UML diagrams.
So how can i do to generate a Class Diagram palette with GMF based on Ecore metamodel of the class diagram ?
THX
If you want to create UML diagrams, it may be more simple to use a tool like Topcased than to build your own Class diagram editor…. Don't you think ?
how can i create dropdown menu for the labels of links in GMF? Thanks
Sorry, I don't have the solution (I have not yet tried to do that). You will have to get into the generated code and modify it to get the special behavior you're expecting… If you find the solution, maybe you could give us a feedback : it should incorporated as a new tutorial.
How to create a link like below?
Thanks!
The link must be a whole one, and can connects three nodes.
I have done something like this in the past but I am not sure that my solution is exactly the one your expecting. I simply created a node with two entries and one output. For example to get something like this :
I put a node in the middle like this :
Hope it helps….
Hello, I want to create a node (n1) with an attached node (n2) in the border (half inside, half outside). Any help is well received.
By the way. Maybe creating a menu item in a node may help the purpose of @Idrees Ashraf, a reference on how to is Epsilon Wizard Language. There is also an example for showing labels in GMF links easy (endlabels example).
Thanks.
Hi,
I would personally try to create a node with nested nodes like in the fifth tutorial. In the parent node, you should try to draw a rectangle on which you would put the nested nodes (half inside of the rectangle, half outside).
Regards,
JF
Thanks for great tutorials, they are really helpful!
I created a GMF editor and model is being saved as XMI, how can save it to XML? Using EMF API for my model it's fairly easy, but what about GMF? I couldn't find anywhere where I can switch from XMI factory to XML one.
Thanks! Alex
Hello
I am not sure to understand…. In fact, XMI is based on XML… XMI is XML ! Doesn't it suit your need ? You want to personalize the XML format taht is used when EMF persists the data ?
JFB
Meant to reply to your comment…
Sorry, what I mean was that is there anyway to avoid xmi code in model? May be what you mentioned with personalization of XML? Perhaps people are creating another model that is only emf model (personalized) that is subset of generated gmf models? I am starting out with gmf, so sorry if I am asking wrong questions.
Sorry, what I mean was that is there anyway to avoid xmi code in model? May be what you mentioned with personalization of XML? Perhaps people are creating another model that is only emf model (personalized) that is subset of generated gmf models? I am starting out with gmf, so sorry if I am asking wrong questions.
When you say “the model”, are you talking about the generated java model code ? (I mean the EMF model, not the GMF models)
JF
Hey,
First of all, i want to say thanks for these helpful tutorial. well, i'm working on a diagram editor but I've a problem with the initial position of nodes which i must solve as soon as possible.
When i create a node programmatically, it'll be positioned, by default, in the top left corner of the canvas.
my question is, how can i change/set the initial position of a node when created?
Many thanks,
Lewis
Hello
To change the position of a created node in the diagram, you have to edit the
XXXXContainerCanonicalEditPolicy
and override thegetCreateViewRequest
method like this :Hope it helps.
Regards,
JFB
Hey Lewis
Im also trying to create new nodes programmatically, could i ask how you are doing it
what do you think to add your tutorials here: http://wiki.eclipse.org/GMF ? I think they will be very happy and you could even help more people.
Great idea ! Feel free to suggest it to eclipsepedia !!!!!! :)
Hi,
I wanted to know if it is possible to have labels out of edit parts area.
Thanks for your helpful tutorials.
Hello,
According to me, the only simple way to get a label outside of an edit part area is possible to attach it to a label… But it is maybe not what you want to do. Another solution is to handle a bigger area in which you put your label and a shape. That way, the label may “seem to be” outside of the shape.
Regards,
JFB
Bonsoir, je suis en cours de faire mon premier éditeur graphique, j'ai reconnu un problème que je doit le résoudre le plus tôt possible, ce problème est au niveau du fichier gmfmap, “containment EReference expected” j'ai pas arrivé à comprendre ce problème, ni le résoudre;
Merci de m'avoir aider Cordialement
Bonjour, Cette erreur vous indique simplement que vous avez omis de sélectionner une référence de type conteneur quelque part !!!!! Probablement au niveau d'un “compartment”… Quelque chose du genre. JF
I'm developing an editor to design user Interfaces based on eclipse GMF.Up to now I have developed an editor with a palette. The user can drag and drop UI elements from pallet and design the UI on canvas.
I need to implement the facility to group these UI elements. EX: User first design the UI by dragging and dropping elements to the canvas.Then he select a set of UI elements (say a label and text box) and press “group” button. It will automatically put the elements within a dashed line rectangle.
I'm planning to develop a plugin that can get info about selected ui elements, delete them, create a group element (dashed line rectangular) in canvas and insert deleted elements to it.
But i don't know where to start.So, I want to know how to create/delete nodes programmatically in GMF. Any help is highly appreciated as our project deadline is coming near.
regards, pavithra
Hello, I think that the answer to your question is presented in the 5th tutorial here : basic_diagram_generation. You have to modify the code in the commands that create your model objects. Regards, JFB
Hello,
I have been given a project to model a transactional language and allow the User to develop a process from the same in a Graphical Editor. I have done this, in GMF and the user can draw (make) the diagrams in the editor. The next task is to incorporate the semantic rules of the language (like structural congruence and reduction relations) and then based on these rules I am supposed to make a functionality that gives user an option to 'Transform' a particular diagram into a resulting diagram.
For example : if there are 2 processes in an editor diagram (made by the user), one of them Process Q is a SUCCESS and other is a normal process and both are in sequence i.e (Process P followed by another Process Q(which is a SUCCESS) ) then the result of this should be another editor diagram that shows only Process P. (as this is how the language rules defines such a sequence)
The doubts I have are :
1) How do I read the editor diagram in a file/code in order to generate the other editor diagram ? 2) Which files or codes (generated by GMF genmodel / EMF genmodel ) am I supposed to write all this code in ? 3) What structure should I follow ? 4) How do I add the functionality 'Transform' on the context Menu in the Eclipse instance (or the Editor window) ?
Also, I have a node T with 3 compartments, I want that when I click on the compartment, a new diagram editor should open up and allow me to add the same type of components. (i.e the meta-model, gmfgraph, gmfmap, gmftools will be the same ). In simpler terms, the compartments should contain a diagram. Also is it possible to add the diagram within that compartment rather than opening a new editor (Eclipse Instance)?
Thanks Kieara
Hi,
Sorry for the delay.
1. You should probably have to take a look at M2M transformation tools (http://eclipse.org/m2m/). Or you can code it manually by opening the source domain model, generating the target model, save it to a new file and open an diagram editor on top of the resulting model… (I don't know if you need all this to be automatized)
2, 3, 4. I think you must add a custom action to your editor or simply to eclipse itself that is enabled for the right resources in the navigator tree (use the
org.eclipse.ui.popupMenus
extension point). You write your code in the action delegate.Regards,
JFB
I am creating right click context menu for every Component. I want to get instances of every component.I mean if i drag rectangular three times then i get different xmi:id=“some numbers” for every instance of component.Can you please tell me that how can i fetch this id programmatic or Can you please explain that how to handle right click selection event so that i get unique id of my every component instances. Thanks in advance
Right click event is maybe not the good approach. I would try to use a custom editor action (see the
org.eclipse.ui.popupMenus
eclipse extension point).hi, I have made a editor. Suppose i create two nodes and make a connection between them. after that when i again create a node the previous connection just disappear. What should i do???
Hum…. Are you sure you've didn't customize a little bit the GMF generated code…. and that you didn't introduced… a bug ???!!! :) If I were you, I would restart from the generated code without modification to check the default behaviour.
Hi, I have made a editor and now I need that it when drag n drop a node (A) within another node (B), the node B get some properties about node A. But I don't have idea that how start this? You can help me?
Maybe should you try to listen to model change events. When A is dropped in B, the A semantic object is added to a containment reference of B. If you listen to this change, you may trigger your specific code.
My problem is:
I have a model that some nodes can have references to another nodes, for example, a ComponentA have one reference to InterfaceA.
My editor permit that I manually set the references selecting them in properties view, but I want to get this references when I drag n drop the referenced node on actual node, for example, when I drag n drop the InterfaceA to ComponentA my component get the interface reference but the interface dont change its position.
My question is how can get references on drag n drop?
GMF naturally handles references through edges (I think that this is in fact more a GMF tooling limitation than a GMF runtime limitation). If you drag'n'drop a component into another, it is more classically in a containment reference case. Why don't you use a simple edge for your need ?
hello… i am trying to develop an editor.. i tried to implement inheritance in my ecore diagram..but it gave some errors.. can you tell me how to implemet inheritance in ecore diagram? whats the procedure? thnaks for your help…
You simply have to connect your EClasses through an inheritance edge
Hello, i have several nodes that inherit from one abstract node, i want to have a full description of the nodes that are available in the diagram, i'm looking for a way to put this description, could it be to add an extra property (ex: description property) or maybe the javadoc description of the class. How can i achieve this?
Thanks for your help
Do you want to add a description on you meta-model or do you want to add a possibility to enter a description of the nodes that appears in you diagram ?
Hello, I haven't found a good tutorial on how to add mouse listeners on figures etc. Could you please explain briefly which method should i redefine and what are the steps to achieve something like this.
ThanksBold Text
Hi,
I have followed the tutorial in the following link to create GMF editor
http://www.devx.com/architect/Article/43366/1954
Iam facing following error. I have 3 objects in my Palette - Application,Entity,Relation.
1. Drag to entities onto the editor 2. Try to make relation from source entity to target entity. 3. Result is Target entity is removed from editor and no connection is shown
Thanks for your help
Sarath
Found the solution..Relation object in my palette is connection represented by Entity related to other Entity…..
So Entity should have reference to Entity….In the ecore file i have specified this reference as containment(true). This is the cause of problem…After resetting it everything worked fine.
Hi everybody, I'm working with GMF to create a graphic editor. My problem is that I have two classes, A and B linked by an association. When I launch the application, I want to see the properties of the linked class in the property view. Does anybody know how to do this ? PS : Thanks and excuse my bad english, actually I'm french
Hi everyone,
I have Few Nodes defined and placed in the Palette. Each Node has an attribute “Name”
which can be set in the property sheet.
I have a rule that in the diagram there shouldn't be multiple Nodes with same “Name”. I have to check this validation that “Name” is not same for any 2 Nodes.
I couldn't find a place in the GMF generated code to set the validator. Can someone help me on this. In the PropertySection code i have set descriptor as EMFCompositeSourcePropertyDescriptor and set validator on that but “isValid” method is not invoked when i change value in the property sheet
Thanks for your help
Thanks,
Sarath
Hi,
These tutorials are great even (if i haven't read all of them(lack of time)). Thank you! I am trying to do something simple I think, but i can't make it work. I want to change the style of the label in a node. For example bold, italic or font. I am trying to do this bu modifying the createContents method of the NodeFigure class. I use the semantic element from my model to ckeck some values and after that de[ending on the values i want to change the label. I 've used these lines fFigureNodeLabelFigure.setTextUnderline(true); fFigureNodeLabelFigure.setFont(new Font(Display.getCurrent(), “Tahoma”, 24 , SWT.ITALIC)); I thought it was simple but… Do you have any suggestions?
Thank you in advance.
I found the solution here. http://www.eclipse.org/forums/index.php/m/221818/?srch=style+label#msg_221818. :)
Hello,
I am trying to change the colour of the links. The code I am using LinkEditPart.createConnectionFigure() is:
polyLine.setForegroundColor(new Color(Display.getCurrent(), lineForgrColor.getRed(), lineForgrColor.getGreen(), lineForgrColor.getBlue()));
Do you have any suggestions?
Thank you in advance.
Thanks for do this page, was very usefull. Thank You very much! :)
Hi,
It's me again. Probably I will not take an answer, but i will try. I want to implement the multiple diagram concept. What I mean is that I want to have in my editor multi - sheets, the same metamodel is used. Do you have any suggestions? From where to start? Please help!!!
Thank you!
Hi, thx for the tutorial it was very helpful.
But I am stuck ! I have to create a wizard that contains a button. When I click on it, it should open the generated GMF editor . My problem is that I don't really understand the generated code that I can use it. Any help?
Hi!
I am working with GEF(Graphical Editing Framework). I have a create a tree and i want to transform it in XML? Can you help me please what kind of plug-in can I use? I need the XML format because i want to work with OWL-S later…
Please can anyone help. I have to work on Graphical Editing Framework. And i have to implement something to show the ontological matching of signatures.
Pleaseeeee…. Best Regards Fjona
Hi, could we find a approach to read the files defined in this system. What should we do?
hello, I am starting GMF.I want to use GMF to make a database editor tool .But I dont known who to do .can you help me ? thank you!
hello, I am starting GMF.I want to use GMF to make a database editor tool .But I dont known who to do .can you help me ? thank you!
hi anyone know how to change the stereotype of a node in the GMF editor Thanks??