Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » How to specify the Type of an attribute programmatically?
How to specify the Type of an attribute programmatically? [message #1734002] Thu, 02 June 2016 21:21 Go to next message
Syed Samsul Arefin is currently offline Syed Samsul ArefinFriend
Messages: 17
Registered: May 2016
Junior Member
I asked this question in EMF forum but I think MDT is the right place to ask this. Maybe it's a trivial question.

While creating the attribute programmatically how do I specify the Type of the attribute?

Package model = UMLFactory.eINSTANCE.createPackage();
		model.setName("MyPackage");
		Class cls = model.createOwnedClass("MyClass", false);
		Property p =cls.createOwnedAttribute("Attr1","???");


Any suggestion?
Re: How to specify the Type of an attribute programmatically? [message #1734008 is a reply to message #1734002] Fri, 03 June 2016 00:47 Go to previous message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1162
Registered: July 2009
Location: Canada
Senior Member

Hi,

This question would properly belong in the uml2 forum, but in any case
it's a pretty generic question of having references to model elements
in an EMF-based model.

If you want to create an attribute of a particular type, don't you know
that type a priori? You should already have a reference to some
instance of the org.eclipse.uml2.uml.Type interface. Otherwise, why
are you creating the attribute?

The API you're using is just like any other Java API. The arguments to
an operation like Package::createOwnedClass(...) are just references to
objects as usual in Java.

Perhaps I don't understand the question.

Christian


On 2016-06-02 21:21:11 +0000, Syed Samsul Arefin said:

> I asked this question in EMF forum but I think MDT is the right place
> to ask this. Maybe it's a trivial question.
> While creating the attribute programmatically how do I specify the Type
> of the attribute?
>
> Package model = UMLFactory.eINSTANCE.createPackage();
> model.setName("MyPackage");
> Class cls = model.createOwnedClass("MyClass", false);
> Property p =cls.createOwnedAttribute("Attr1","???");
>
> Any suggestion?
Previous Topic:convert BPMN20 OMG CMOF metamodel to ecore
Next Topic:news.eclipse.org is shutting down.
Goto Forum:
  


Current Time: Wed Jan 17 09:30:38 GMT 2018

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

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