Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Use of ChoiceFormat in View/Edit Pattern on Labels
Use of ChoiceFormat in View/Edit Pattern on Labels [message #217523] Fri, 06 February 2009 15:44 Go to next message
Mark Wood is currently offline Mark WoodFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

I'm having a problem trying to conditionally format the content of labels
on GMF diagrams.

Basically, I have a Cardinality attribute on a Reference concept in my
Meta Model, this is modelled as an Integer. I model one-to-many references
as -1, many-to-one as -2 and many-to-many as -3. Non-negative
cardinalities are left as is. When labelling a Reference in my GMF diagram
I wish it to convert the string I give it to the correct underlying format
as such:

"1..*" -> -1
"*..1" -> -2
"*..*" -> -3
"3" -> 3

In order to accomplish this I'm trying to use View and Edit Patterns
however there isn't a huge amount of documentation on these. For my
View/Edit/Editor Pattern I currently use the expression:

{0,choice,-3#*..*|-2#*..1|-1#1..*|-1<{0}}

This is a ChoiceFormat expression in the form as described here:
http://java.sun.com/javase/6/docs/api/java/text/MessageForma t.html

However, I cannot seem to get the format correct. Using the above
expression, although correct for the View, I don't think it's quite right
for the Edit/Editor patterns. Consequently, the current behaviour allows
me to enter the first 3 rules from earlier but fails to change the label
value when I enter regular values such as "10" or "5".

It's quite difficult to explain the behaviour as it varies only slightly
for each adjustment, but I hope you can understand what I'm trying to do.
Essentially I just want to pretty print certain values (-1, -2, -3) such
that if I type 1..*, *..1, *..* (respectively) into a label, it converts
the underlying value into the correct Integer so I can then process it
later on.

Any advice would be very much appreciated. If View/Edit/Editor Patterns
are not the best way to solve the problem then I am keen to hear
suggestions on other possible solutions.

Thanks in advance,

Mark
Re: Use of ChoiceFormat in View/Edit Pattern on Labels [message #217778 is a reply to message #217523] Mon, 09 February 2009 07:11 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mark,

MessageFormat is good for the View patterns here. As an edit pattern you
have to use {0} and plug in your custom parser/modify generated one.

-----------------
Alex Shatalin
Re: Use of ChoiceFormat in View/Edit Pattern on Labels [message #217983 is a reply to message #217778] Mon, 09 February 2009 15:54 Go to previous message
Mark Wood is currently offline Mark WoodFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks Alex, I'll look into it.
Previous Topic:Re: problem customizing edit plugin, PropertyDescriptor
Next Topic:[Announce] GMF 2.2.0M5 is available
Goto Forum:
  


Current Time: Fri Feb 26 06:24:47 GMT 2021

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

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

Back to the top