Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to define a predefined sequence attributes?
How to define a predefined sequence attributes? [message #1198722] Wed, 20 November 2013 13:27 Go to next message
Tarcísio Couto is currently offline Tarcísio CoutoFriend
Messages: 29
Registered: May 2013
Junior Member
Hello,

my doubt is:

I have a node called Variant. Variant has a set of attributes like name and id for example.

What I want is every time that I insert a Variant the attributes can be inserted automatically, for example.

I inserted the first Variant, so the attributes will be..

Name: Variant 1
Id: 1

The Second Variant

Name: Variant 2
Id: 2

and So on..

Can someone help me?
Re: How to define a predefined sequence attributes? [message #1199135 is a reply to message #1198722] Wed, 20 November 2013 17:53 Go to previous messageGo to next message
Tarcísio Couto is currently offline Tarcísio CoutoFriend
Messages: 29
Registered: May 2013
Junior Member
I tried the following:

NFRSoftgoalImpl nfrsoftgoal = (NFRSoftgoalImpl ) ((NodeImpl) NFRSoftgoalEditPart.this.getModel()).getElement();
int id = sequence_soft.getAndIncrement();
nfrsoftgoal.setId(String.valueOf(id));
nfrsoftgoal.setNFRSoftgoalPriority(BigInteger.valueOf(id));
nfrsoftgoal.setName("NFRSoftgoal" + id);

but, the following error happened: java.lang.IllegalStateException: Cannot modify resource set without a write transaction

I don't know how to solve this problem....
Re: How to define a predefined sequence attributes? [message #1200455 is a reply to message #1199135] Thu, 21 November 2013 08:49 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

you can do what you want to do by using the gmfmap model. There is something called FeatureSeqInitializer which you can use. Your bug happens because you are not using a command. For you task you could use an EMF SetCommand.create(...) and execute it on a command stack which you can get from your edit parts for example getEditingDomain().getCommandStack().execute(command).

Ralph
Re: How to define a predefined sequence attributes? [message #1200786 is a reply to message #1198722] Thu, 21 November 2013 12:11 Go to previous messageGo to next message
Tarcísio Couto is currently offline Tarcísio CoutoFriend
Messages: 29
Registered: May 2013
Junior Member
I need something more concrete.

What you said is very "empty" for me.
Re: How to define a predefined sequence attributes? [message #1202798 is a reply to message #1200786] Fri, 22 November 2013 10:17 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

take a look here (http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial/Part_2#Feature_Initializers). They use it.

Ralph
Re: How to define a predefined sequence attributes? [message #1203263 is a reply to message #1198722] Fri, 22 November 2013 15:11 Go to previous messageGo to next message
Tarcísio Couto is currently offline Tarcísio CoutoFriend
Messages: 29
Registered: May 2013
Junior Member
I used the Feature Seq Initializers, but this tip doesn't do what I want.

It just initialize an attribute. What I want is every time that I insert an node, the attribute can be inserted automatically, for example.

Name: Variant 1
Id: 1

The Second Variant

Name: Variant 2
Id: 2

The Feature Seq Initializers only put a value for an attribute, the attribute doesn't change like a iteration above... 1 and after 2 and so on...
Re: How to define a predefined sequence attributes? [message #1209925 is a reply to message #1198722] Mon, 25 November 2013 19:32 Go to previous messageGo to next message
Tarcísio Couto is currently offline Tarcísio CoutoFriend
Messages: 29
Registered: May 2013
Junior Member
Help me please.
Re: How to define a predefined sequence attributes? [message #1213637 is a reply to message #1209925] Wed, 27 November 2013 10:21 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I do not get your point. What you want to do is counting the instances as far as I understand. In OCL it would be something like [MetaType].allInstances()->size() + 1. This would generate a counter for each attribute.

Ralph
Previous Topic:Preferential Updates of shortcuts
Next Topic:How can i make Compartment with Grid layout ?
Goto Forum:
  


Current Time: Sat Feb 27 11:10:16 GMT 2021

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

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

Back to the top