Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » What is the language used for the field "Expression" in Edit Image dialog for a stereotype
What is the language used for the field "Expression" in Edit Image dialog for a stereotype [message #1849348] Thu, 13 January 2022 12:25 Go to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hello,

I would customize the icon of some elements according to their stereotype. For some of them, I use the Icon field to add some images. It works well when I want to use the same image for every element having the stereotype.

But in some cases, I have a stereotype that can be applied to several kinds of elements (operation, property, etc...). In this case, I would distinguish the elements according to their metatype too. For that, I suppose the field Expression in the Edit Image dialog of a stereotype would be a good location but the only example I found uses a test on an enumeration variable owned by the stereotype ("importance=High"). I would know what is the language to edit the expression. In particular, I would test the metatype of the element with something like : "base_Element.type = Property". Any help to understand how it works is welcome.

Thanks for reading.
Regards.
Yoann.
Re: What is the language used for the field "Expression" in Edit Image dialog for a stereo [message #1849349 is a reply to message #1849348] Thu, 13 January 2022 12:46 Go to previous messageGo to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
From what I read in ImageUtil class (used to retrieve this image), this field is only valuable to test an enumeration value. It can not be used to elaborate a more complex boolean expression.

I suppose a workaround would be to store the metatype as an enumeration attribute in the stereotype properties even if it is redundant.

Yoann.

Re: What is the language used for the field "Expression" in Edit Image dialog for a stereo [message #1849360 is a reply to message #1849349] Thu, 13 January 2022 16:39 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Yoann,

I've never used the expression attribute. In case of a static profile, there is a pragmatical way I've used a long time ago. Add multiple icons to a stereotype and select one in an added getIcon (to the Impl class of this stereotype), as shown below.

Another way is to use a CSS selecting different shapes depending on a calculated attribute. This has been used for instance in the UCM plugin, see plugin org.eclipse.papyrus.designer.ucm.css

public Image getIcon()
{
	// retieve stereotype ...
	EList<Image> icons = stereotype.getIcons();
	if (...) {
		return icons.get(1);
	}
 	else {
		return icons.get(0);
	}
}
Re: What is the language used for the field "Expression" in Edit Image dialog for a stereo [message #1849371 is a reply to message #1849360] Fri, 14 January 2022 12:47 Go to previous message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hi Ansgar,

Thanks for the tip. I use the getIcon way now. I first believed that I had to override a getIcon method but it doesn't exist in the generated class of the stereotype. Then I observe that the code which uses this way looks for a such method in the class and use if it exists. It was not obvious but it works well.
Thank you.
Yoann.
Previous Topic:[C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ?
Next Topic:Shorten global appearance operation class diagram
Goto Forum:
  


Current Time: Thu Apr 25 09:51:29 GMT 2024

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

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

Back to the top