|
Re: How to load Applied Stereotypes [message #1720479 is a reply to message #1720416] |
Mon, 18 January 2016 20:45 |
|
Hi,
The last statement of your code snippet is:
> EList<Stereotype> list = package_.getModel().getAppliedStereotypes(); :(
which is asking for the stereotypes applied to the nearest element of
type Model that contains the Package retrieved from the contents of the
resource. That model is probably the 'package_', itself, since it is a
root element in the resource.
So, does this particular element actually have stereotypes applied to
it? Or is it elements contained within it (such as elements of the
Interaction) that have stereotypes applied to them? Every element
answers only the stereotypes applied to itself.
HTH,
Christian
On 2016-01-18 20:28:49 +0000, Jean-Marc LARRE said:
> Hello,
>
> I try, from a standalone Eclipse application to extract the stereotypes
> applied to a interaction diagram directly with Papyrus. I found a lot
> of exemple in this forum and on Eclipse Wiki, I tested all examples but
> nothing works for me.
>
> See my code :
>
>
> URI diURI = URI.createFileURI("scenario/checkAllPackage_2_1_002_ErrorYes.uml");
> org.eclipse.uml2.uml.Package package_ = null;
>
> try {
> ResourceSet RESOURCE_SET = new ResourceSetImpl();
> UMLResourcesUtil.init(RESOURCE_SET);
> Resource resource = RESOURCE_SET.getResource(uri, true);
> package_ = (org.eclipse.uml2.uml.Package)
> EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PACKAGE);
> } catch (WrappedException we) {
> we.printStackTrace();
> System.exit(1);
> }
>
> EList<Stereotype> list = package_.getModel().getAppliedStereotypes(); :(
>
> And the "list" is already empty ...
>
> Thank you
> Jean-Marc
|
|
|
|
Re: How to load Applied Stereotypes [message #1720579 is a reply to message #1720539] |
Tue, 19 January 2016 13:25 |
|
Hi, Jean-Marc,
If you have the interaction, you just need to ask it for its applied
stereotypes:
Interaction interaction = // ... however you find it in the model tree
doSomethingWith(interaction.getAppliedStereotypes());
The only reasons why this would fail to retrieve all of the stereotypes are:
* the profile application could not resolve the applied profile
* the profile application is out-of-date and the current UML definition
of the profile
does not have the stereotype(s) any longer
The first case is the more likely in the case of code running
stand-alone (outside of the Eclipse run-time environment). Perhaps the
URI scheme of the applied-profile reference is one that requires the
Eclipse context to resolve properly (e.g., if it's a pathmap:// URI,
platform:/plugin/, etc.). This can be addressed by registering URI
mappings with the URIConverter. There are numerous postings on that
subject in this newsgroup.
In any case, debugging the getAppliedStereotypes() call will help you
to understand why no stereotypes are found.
HTH,
Christian
On 2016-01-19 08:52:19 +0000, Jean-Marc LARRE said:
> Thank you very much for your answer.
>
> In fact, the stereotype is applied to the interaction diagram (see the
> screenshot of papyrus).
>
> When I search the stereotype applied to the interaction I don't get any result.
>
> I don't understand how to get the aplied stereotypes ?
>
> Sincerely
> Jean-Marc
>
>
> <image>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02884 seconds