Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Changing and saving the value of a label?
Changing and saving the value of a label? [message #217827] Mon, 09 February 2009 09:28 Go to next message
Anna is currently offline AnnaFriend
Messages: 34
Registered: July 2009
Member
In my diagram, I want to be able to assign event- and guard-values to my
transitions. These values should be chosen from two predefined lists of
values, taken from an XML-file. Right now, the values are fixed when you
draw the diagram (to prevent the user from entering a value by hand), as
shown in this picture.
http://farm4.static.flickr.com/3440/3265528805_5ab616a2a3.jp g

I have created a wizard that can be reached by clicking on a transition.
Through that wizard, a user can load such an XML-file and populate the
lists. After that, the user are presented with two drop-down menus
containing these value-lists.
Now to my problem...when a user chooses for example an event-value I want
that value to replace the default-value on the diagram, and I also want to
be able to save some other info about the chosen event (for example a type
and an id-number). But I don't know how to "reach" the appropriate
java-file (or which one it might be) from my wizard-code? Is there anyone
who can tell me how to do this?

(I also want to do the same thing with the state-names, but I'm guessing
that it can be done in the same way...)

Sincerely,
Anna
Re: Changing and saving the value of a label? [message #217845 is a reply to message #217827] Mon, 09 February 2009 10:34 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Anna,

If you just want to change initial names (or other properties) of the object
to something else then you can:
- create FeatureSequenceInitializer + FeatureValueSpecification + ValueExpression
below corresponding NodeMapping
- set FeatureValueSpecification.feature to point to the feature you are going
to initialize
- set ValueExpression.language property to “java”
- generate code

In the generated code additional method will be generated (you can compare
generated sources with old version to see the diff most probably this method
will be injected into XXXVisualIdRegistry class). This method will be responsible
for initialization of corresponding feature of the newly created object.
You can modify this method to get preloaded value end use it.
-----------------
Alex Shatalin
Re: Changing and saving the value of a label? [message #217910 is a reply to message #217845] Mon, 09 February 2009 12:30 Go to previous messageGo to next message
Anna is currently offline AnnaFriend
Messages: 34
Registered: July 2009
Member
Not sure if this is what I want...just checking to see that I haven't
misunderstood.
I still want the diagram to have a default name for its states and
transitions (sort of like in the picture I linked to before). When I draw
a state it should be called "state" by default. Then, by clicking on the
state, I should reach a menu where I can start my wizard, and in the
wizard I can choose a state name from my list. When I click OK, the
default name should change to the one that I have chosen. Is this (the
answer below) the way to achieve this? I want to know how I can reach the
appropriate java-file (where the state/transition labels are set) from my
wizard-code.

/Anna

> If you just want to change initial names (or other properties) of the object
> to something else then you can:
> - create FeatureSequenceInitializer + FeatureValueSpecification +
ValueExpression
> below corresponding NodeMapping
> - set FeatureValueSpecification.feature to point to the feature you are
going
> to initialize
> - set ValueExpression.language property to “java”
> - generate code

> In the generated code additional method will be generated (you can compare
> generated sources with old version to see the diff most probably this method
> will be injected into XXXVisualIdRegistry class). This method will be
responsible
> for initialization of corresponding feature of the newly created object.
> You can modify this method to get preloaded value end use it.
> -----------------
> Alex Shatalin
Re: Changing and saving the value of a label? [message #217927 is a reply to message #217910] Mon, 09 February 2009 12:39 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Anna,

> default name should change to the one that I have chosen. Is this (the
> answer below) the way to achieve this? I want to know how I can reach
> the appropriate java-file (where the state/transition labels are set) from
> my wizard-code.
In this case the solution is simple - use selection in a wizard to get corresponding
EditPart. From an EditPart you can get underlying domain model element by
calling:

((org.eclipse.gmf.runtime.notation.View) EditPart.getModel()).getElement()

-----------------
Alex Shatalin
Previous Topic:How can I get the instance of the Diagram?
Next Topic:Regarding DND
Goto Forum:
  


Current Time: Fri Apr 26 21:31:35 GMT 2024

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

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

Back to the top