Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Set Enumeration Type in Property of Stereotype
Set Enumeration Type in Property of Stereotype [message #1005433] Fri, 25 January 2013 12:32 Go to next message
edipo federle is currently offline edipo federle
Messages: 21
Registered: November 2012
Junior Member

Hello, I am trying via Java, set a property of a stereotype with an Enumeration. For Example:

First I create the enumeration and enumeration literals

private static void createBindingTimeEnumeration (Profile prof) {
try {
Enumeration bindingTime Helper.createEnumeration = (prof, "BidingTime");
Helper.createEnumerationLiteral (bindingTime, "DESIGN_TIME");
Helper.createEnumerationLiteral (bindingTime, "LINK_TIME");
Helper.createEnumerationLiteral (bindingTime, "COMPILE_TIME");
Helper.createEnumerationLiteral (bindingTime, "RUN_TIME");
} catch (Exception e) {
System.out.println (e.getMessage ());
}
}


Then I create the stereotype, and I would do something like this:

  Helper.createAttribute (myStereotype, "bindingTime" bidingTime, 1, 1);


Where is the 'bidingTime' enumeration.

Can anyone help?

thank you
Re: Set Enumeration Type in Property of Stereotype [message #1005460 is a reply to message #1005433] Fri, 25 January 2013 14:23 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 789
Registered: July 2009
Senior Member
What is "Helper" ? I assume that's some class you devised that wraps
the UMLFactory?

What is the problem? The bindingTime variable is a reference to the
Enumeration, which is a kind of Type. Just set it as the type of the
attribute. I assume that the Helper.createAttribute(...) method does
this already.

HTH,

Christian


On 2013-01-25 12:32:50 +0000, edipo federle said:

> Hello, I am trying via Java, set a property of a stereotype with an
> Enumeration. For Example:
>
> First I create the enumeration and enumeration literals
>
> private static void createBindingTimeEnumeration (Profile prof) {
> try {
> Enumeration bindingTime Helper.createEnumeration = (prof, "BidingTime");
> Helper.createEnumerationLiteral (bindingTime, "DESIGN_TIME");
> Helper.createEnumerationLiteral (bindingTime, "LINK_TIME");
> Helper.createEnumerationLiteral (bindingTime, "COMPILE_TIME");
> Helper.createEnumerationLiteral (bindingTime, "RUN_TIME");
> } catch (Exception e) {
> System.out.println (e.getMessage ());
> }
> }
>
> Then I create the stereotype, and I would do something like this:
>
>   Helper.createAttribute (myStereotype, "bindingTime" bidingTime, 1, 1);
>
> Where is the 'bidingTime' enumeration.
>
> Can anyone help?
>
> thank you
Re: Set Enumeration Type in Property of Stereotype [message #1005464 is a reply to message #1005460] Fri, 25 January 2013 14:38 Go to previous message
edipo federle is currently offline edipo federle
Messages: 21
Registered: November 2012
Junior Member
Actually I was with a problem with my method that return the enum by name. A cast problem;

Then, now everthing work: The code is:



Enumeration bindingTime = (Enumeration) getEnumerationByName(prof, "BidingTime");
 Helper.createAttribute(variantPoint, "bindingTime", bindingTime  , 1, 1);


	private static PackageableElement getEnumerationByName(Profile prof, String name) {
		EList<PackageableElement> a = prof.getPackagedElements();
		for (PackageableElement packageableElement : a) {
			if(packageableElement instanceof Enumeration && packageableElement.getName().equals(name))
				return packageableElement;
		}
		return null; // TODO retaforar Exp
	}


Thanks.

Sorry for the confusion
[]s

[Updated on: Fri, 25 January 2013 14:39]

Report message to a moderator

Previous Topic:linking lifeline to its corresponding class
Next Topic:How to get a metaclass for Stereotype.createExtension()
Goto Forum:
  


Current Time: Sun Sep 21 16:11:29 GMT 2014

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

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