Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to find if a diagram is already created for an element ?
How to find if a diagram is already created for an element ? [message #1716179] Wed, 02 December 2015 00:41 Go to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Hi,

I have a Feature F, I need to create an State Machine Diagram (Canvas) for F. I can do it now. I can also open the corresponding diagram by double clicking on the feature F. But here is the question:

When I want to create the diagram for feature F, I need to check that a diagram has already been created for the feature F or not! If, it has already been created, don't create it again! How to do this ?

Thanks,
Regards,
Parsa
Re: How to find if a diagram is already created for an element ? [message #1716534 is a reply to message #1716179] Fri, 04 December 2015 16:01 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hi Parsa,

You can use the API
DialectManager.INSTANCE.getRepresentations(semanticElement,
currentSiriusSession) to find every representation created on
"semanticElement" and then investigate if a State Machine Diagram exists
among them.

Regards,
Steve

Le 02/12/2015 01:41, Parsa Pourali a écrit :
> Hi,
>
> I have a Feature F, I need to create an State Machine Diagram (Canvas)
> for F. I can do it now. I can also open the corresponding diagram by
> double clicking on the feature F. But here is the question:
>
> When I want to create the diagram for feature F, I need to check that a
> diagram has already been created for the feature F or not! If, it has
> already been created, don't create it again! How to do this ?
>
> Thanks,
> Regards,
> Parsa


--
Steve Monnier - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to find if a diagram is already created for an element ? [message #1716538 is a reply to message #1716534] Fri, 04 December 2015 16:24 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

I replied a bit too fast and overlooked that you want it for a double
click tool. In your tool, you can add a precondition expression without
using a java service. The expression would look like this:
aql:not(self.eInverse()->filter(diagram::DDiagram).description.name->includes('yourDiagramID'))
where yourDiagramID is the name you sent in the VSM for your State
Machine Diagram.

Regards,
Steve

Le 04/12/2015 17:01, Steve Monnier a écrit :
> Hi Parsa,
>
> You can use the API
> DialectManager.INSTANCE.getRepresentations(semanticElement,
> currentSiriusSession) to find every representation created on
> "semanticElement" and then investigate if a State Machine Diagram exists
> among them.
>
> Regards,
> Steve
>
> Le 02/12/2015 01:41, Parsa Pourali a écrit :
>> Hi,
>>
>> I have a Feature F, I need to create an State Machine Diagram (Canvas)
>> for F. I can do it now. I can also open the corresponding diagram by
>> double clicking on the feature F. But here is the question:
>>
>> When I want to create the diagram for feature F, I need to check that a
>> diagram has already been created for the feature F or not! If, it has
>> already been created, don't create it again! How to do this ?
>>
>> Thanks,
>> Regards,
>> Parsa
>
>


--
Steve Monnier - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to find if a diagram is already created for an element ? [message #1716544 is a reply to message #1716538] Fri, 04 December 2015 16:56 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Hi Steve,

Thanks a lot for your help. I used the expr you posted and it worked great ! Thank you, it was exciting Very Happy

I have two Questions now:

1- If I'm gonna use DialectManager (someday), should I write a Java Service and use it in that service?

2- What should I refer to as a session ? With Java service I have access to the EObject that triggering the java service, should I just use SessionManager.INSTANCE.getSession(theSemanticElement to get the active session ?

Thanks,
Bests,
Parsa

[Updated on: Fri, 04 December 2015 17:05]

Report message to a moderator

Re: How to find if a diagram is already created for an element ? [message #1716679 is a reply to message #1716544] Mon, 07 December 2015 13:30 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 04/12/2015 17:56, Parsa Pourali a écrit :
> Hi Steve,
>
> Thanks a lot for your help. I have three Questions now:
>
> 1- If I'm gonna use DialectManager (someday), should I write a Java
> Service and use it in that service?

Not necessarily. DialectManager can be used to drive Sirius from code
which is not invoked from inside a VSM. For example from a normal
Eclipse action/handler, or a wizard, etc.

> 2- What should I refer to as a session ? With Java service I have access
> to the EObject that triggering the java service, should I just use
> SessionManager.INSTANCE.getSession(theSemanticElement to get the active
> session ?

Yes, if you have a semantic/busniess model element which comes from a
Sirius session that is the recommended API to obtain the corresponding
session.

> 3- I'm using the aql expr you kindly posted, I could manage to use
> eInverse() and it return several elements. However, when I use eInverse
> (diagram::DDiagram), it returns null. And I am sure that there is a
> representation for it. so it shuld not be empty. So, I used eInverse
> (diagram::DDiagramElement) and it returned two elements which I can see
> are diagram elements. The problem with using DDiagramElement is that
> there is no description attribute for it :( Do you have any idea why
> diagram::DDiagram returns empty ?

No, from the look of the expression Steve provided, I would say it
should work. Provided there is really a diagram "rooted" on that element
(not just where the element appears on the diagram) inside the same
Sirius session.

Regards,
Pierre-Charles

--
Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:How to create Border Node with a Domain Class not in the semantic model
Next Topic:Can't create a Node with Border Nodes
Goto Forum:
  


Current Time: Fri Apr 19 07:55:50 GMT 2024

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

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

Back to the top