Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mdt-papyrus.dev] extract information from an activity diagram

Hi,

 

A Comment is not a NamedElement.

You can probably modify your code by getting an adapter for Element.class (which is common ancestor for NamedElement and Comment), and test if the Element you get is a NamedElement or a Comment.

 

Arnaud.

 

De : mdt-papyrus.dev-bounces@xxxxxxxxxxx [mailto:mdt-papyrus.dev-bounces@xxxxxxxxxxx] De la part de Alexandre HERISSE
Envoyé : vendredi 5 avril 2013 12:25
À : mdt-papyrus.dev@xxxxxxxxxxx
Objet : Re: [mdt-papyrus.dev] extract information from an activity diagram

 

Hi,

Thanks a lot for your previous help. It works great.

I have an other question concerning comment block in an activity diagram.
Using the code from the papyrus faq to get a NamedElement from a selection gave me a null NamedElement object when an Activity comment is selected.

Here is the code from your website :

"...

Object obj = ... // The Graphical Object
 if( obj instanceof IAdaptable ) {
   NamedElement ele = (NamedElement)((IAdaptable)obj).getAdapter(NamedElement.class);
   // Adapt object to NamedElement
   NamedElement ele = null;
   if( obj instanceof IAdaptable ) {
     ele = (NamedElement)((IAdaptable)obj).getAdapter(NamedElement.class);
   }
   if( ele == null) {
     ele = (NamedElement)Platform.getAdapterManager().getAdapter(obj, NamedElement.class);
   }
 }
..."
 
How could I do in order to have a non null NamedElement from a Activity Comment selection ?
If this is not possible, how to get an object reflecting the comment ?
 
Thanks.
 
 
Herisse Alexandre.
 


Le 21/02/2013 11:19, LETAVERNIER Camille a écrit :

Hello Alexandre,

 

Ø  I can get the NamedElement

 

The « NamedElement » is your CallBehaviorAction, right ? If so, you can call:

 

NamedElement selectedNamedElement = …;

if (selectedNamedElement instanceof CallBehaviorAction){

       Behavior calledBehavior = ((CallBehaviorAction)selectedNamedElement).getBehavior();

       if (calledBehavior instanceof Activity){

             Activity calledActivity = (Activity)calledBehavior;

             //...

       }

}

 

If you also need to manipulate SysML stereotypes, have a look at Element#getAppliedStereotype() and Element#getStereotypeApplication(Stereotype)


Regards,
Camille

__________________________

Camille Letavernier

+33 (0)1 69 08 00 59 - camille.letavernier@xxxxxx

CEA LIST - Laboratoire d'Ingénierie dirigée par les modèles pour les Systèmes Embarqués (LISE)

Papyrus : http://www.eclipse.org/papyrus

 

De : mdt-papyrus.dev-bounces@xxxxxxxxxxx [mailto:mdt-papyrus.dev-bounces@xxxxxxxxxxx] De la part de Alexandre HERISSE
Envoyé : jeudi 21 février 2013 11:01
À : mdt-papyrus.dev@xxxxxxxxxxx
Objet : [mdt-papyrus.dev] extract information from an activity diagram

 

Hi,

I need to extract information from an activity diagram with the help of an eclipse plugin.
This activity diagram is mainly composed of call-behaviour actions. Each call-behaviour action points to an activity which have some inputs and some outputs.
By clicking on that item, I can get the NamedElement under the eclipse plugin. What I need is to get the activity which is pointed by the call behaviour action and on that activity, get the arguments name and the result name to process something.

I can see them under debug (in "behaviour" attribute) but I do not know how to get them by calling public functions. Is it related to EMF? If yes, how can we question the emf to get the sysml model of the selected element ?

Thanks for your help.



-- 
Alexandre HERISSE
Xcos developer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.70
http://www.scilab-enterprises.com 




_______________________________________________
mdt-papyrus.dev mailing list
mdt-papyrus.dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mdt-papyrus.dev




-- 
Alexandre HERISSE
Xcos developer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.70
http://www.scilab-enterprises.com 

Back to the top