gmf.label for EAttributes - use of pattern [message #1128456] |
Mon, 07 October 2013 18:11 |
Jessica Diaz Messages: 3 Registered: October 2013 |
Junior Member |
|
|
Hello,
Please, I need help for the following issue. I want to model the metaclass "CEOLidership" which has a list of attributes (pairs of key/value), such as:
- Tolerance Of Ambiguity : value{yes/no/no evidence}
- Self confidence : value{yes/no/no evidence}
- ....
I used gmf.label and label.pattern.
Althoug label.pattern works for gmf.node (see labels v1 and v2), it seems that label.pattern does not work for gmf.label
Any suggestion to make a fixed list of attributes in the form "key : value"
Please find below the code for any suggetion.
Thanks in advance.
---------------------------------------------------------
@namespace(uri="InnoModelingTool", prefix="InnoModelingTool")
package InnoModelingTool;
@gmf.diagram
class InnoModel {
val Employee[*] employees;
val Determinant[*] determinants;
}
@gmf.node(figure="rectangel",
label.icon="false", label="name", label.placement="external")
class Employee {
attr String name;
@gmf.link(width="2", color="0,0,255", target.decoration="arrow", style="dash")
ref CEOLidership exercises;
}
abstract class Determinant {
attr String name;
}
@gmf.node(label="v1,v2", figure="rectangle", label.pattern="aa:{0}:{1}",
tool.small.bundle="InnoModelingTool", tool.small.path="icons/CEO.gif")
class CEOLidership extends Determinant{
attr String v1;
attr String v2;
@gmf.label(label="toleranceofamiguityvalue", label.icon="false", label.pattern="Tolerance Of Ambiguity : {0}")
attr CEOFactorValue toleranceofamiguityvalue;
@gmf.label(label="selfconfidencevalue", label.icon="false", label.pattern="Self Confidence : {0}")
attr CEOFactorValue selfconfidencevalue;
}
//ENUM
enum CEOFactorValue{
no = 0;
yes = 1;
noEvidence = 2;
}
|
|
|
Re: gmf.label for EAttributes - use of pattern [message #1128554 is a reply to message #1128456] |
Mon, 07 October 2013 20:26 |
|
Hi Jessica,
The problem seems to be that the type of your attributes is an enum. If you change your attributes to be strings instead (and remove the label="..." details as they are not supported by @gmf.label) everything works as expected:
@gmf.label(label.icon="false" , label.pattern="Tolerance Of Ambiguity : {0}")
attr String toleranceofamiguityvalue;
@gmf.label(label.icon="false", label.pattern="Self Confidence : {0}")
attr String selfconfidencevalue;
A minor typo I also had to fix to get this to run was figure="rectangel" -> figure="rectangle".
This looks like a GMF bug to me as Eugenia generates the expected .gmfmap model even when the @gmf.label attributes are of an enumeration type.
Cheers,
Dimitris
|
|
|
Re: gmf.label for EAttributes - use of pattern [message #1128575 is a reply to message #1128554] |
Mon, 07 October 2013 21:00 |
|
Hi everyone,
I also found the same issues (label="..." and "rectangel"). I did get it to work with enums, though, but I had to manually modify the parser in the GMFGen model. The problem is that when GMF sees the enum, it uses the default enum parser instead of the MessageFormat-based parser.
I'll write up a quick polishing transformation which should help you, and if it works we could integrate it into Eugenia later on .
Cheers,
Antonio
Edit: We do tell GMF to use MESSAGE_FORMAT in the GMFGen model, but the "Edit/View Method" attributes are now deprecated in favor of the "Parser" attribute. I think this bug may have been introduced recently with a new version of GMF.
[Updated on: Mon, 07 October 2013 21:03] Report message to a moderator
|
|
|
Re: gmf.label for EAttributes - use of pattern [message #1128594 is a reply to message #1128575] |
Mon, 07 October 2013 21:22 |
|
Here's a fixed .emf file and the polishing transformation that you'll need.
You'll notice that I'm using label.parser="MessageFormatParser" in order to force GMF to honor our label patterns instead of using the default Enum parser.
GMF doesn't like unused parsers, though, so it'd produce a validation error and stop the code generation process. That's what the FixGMFGen.eol is for: it removes the unused parsers so GMF doesn't complain.
You only have to replace your .emf file with this one, place the FixGMFGen.eol file in the same folder and regenerate the code with Eugenia. Give it a try and tell us if it works for you .
-
Attachment: model.emf
(Size: 1.04KB, Downloaded 198 times) -
Attachment: FixGMFGen.eol
(Size: 0.16KB, Downloaded 177 times)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03153 seconds