Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Initializing a diagram with default node
Initializing a diagram with default node [message #1024027] Mon, 25 March 2013 17:08 Go to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Hello,

couldn't find an appropriate solution yet to fix my problem. What I want is a default node that is automatically added when a new diagram is created by the user.
I already checked the creation wizard, but I'm not sure what I've got to change there. Does anyone know the piece of code which is relevant to implement this?
Re: Initializing a diagram with default node [message #1024986 is a reply to message #1024027] Tue, 26 March 2013 09:50 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
Hi Phil!

I think this tutorial is exactly what you are looking for:
http://gmfsamples.tuxfamily.org/wiki/doku.php?id=gmf_tutorial7#diagram_initialization
Re: Initializing a diagram with default node [message #1028602 is a reply to message #1024027] Thu, 28 March 2013 13:36 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Hi,

thx that worked so far, but I noticed a strange behaviour. I've got the following Metamodel:

@gmf.diagram(onefile="true", diagram.extension="pld", model.extension="pld")
class PLD{

  	attr EString name;
  
  	val FM[*] fms; 
  	val EC ec;
  	val PL pl;
}


The createInitialModel() in the diagram.part package offers me method to set a name and EC/PL objects for my PLD class, but there is no method to add a FMobject. However there is still a getter which returns a list of FM objects. Any idea about this?

[Updated on: Thu, 28 March 2013 13:38]

Report message to a moderator

Re: Initializing a diagram with default node [message #1031765 is a reply to message #1028602] Tue, 02 April 2013 06:54 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
It should be something like:

private static Model createInitialModel() {
	PLD pld = XYZFactory.eINSTANCE.createPld();
	FM fm = XYZFactory.eINSTANCE.createFM();
	pld.getFM().add(fm); // getFM = your List; Add the fm-Object to this list

	return pld;
}


I didn't test it, but it should work.
Re: Initializing a diagram with default node [message #1031947 is a reply to message #1031765] Tue, 02 April 2013 11:51 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Thx, .getFM().add has done the trick Smile

One thing I still don't udnerstand is how the order of the positions in the diagram is determined. In the code it doesn't matter in which order I add elements - The FM element is always on the top left position in the diagram. Any Idea how to affect the position in the diagram?
Re: Initializing a diagram with default node [message #1032098 is a reply to message #1031947] Tue, 02 April 2013 15:06 Go to previous message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
It seems that the order within the .emf file determines the inital oder at the diagram. So changing this has done the trick:

class PLD{

  	attr EString name;
  
        val EC ec;
  	val FM[*] fms; 
  	val PL pl;
}
Previous Topic:Unresolvable transient references in notation model
Next Topic:GMF change class hierarhy
Goto Forum:
  


Current Time: Wed Apr 24 19:40:38 GMT 2024

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

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

Back to the top