Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to add manually some model "elements" to a diagram (where "elements" are giv
How to add manually some model "elements" to a diagram (where "elements" are giv [message #119984] Tue, 17 April 2007 13:46 Go to next message
Eclipse UserFriend
Originally posted by: renwart.lippmann.lu

Hi all,

My problem seems to be simple but I don't know how to solve it because
I'm new on GMF.

For example, I use the GMF BPMN editor. When I create a new Diagram (a
new File) or when I open an already existing one, my goal is to load "on
launch" a file saved on my local harddisk... This file contains pieces
of information which I want to use to "complete" my model while loading
it. For example, Imagine that I want to add a "Task" to my diagram
because this task is defined in the loaded file...

No problem to load my file, but... The problem is that I don't know how
(and where?) to add the code to manually add some elements to the model
when I start my GMF editor ?

Can you help me by giving an example of such a job ?
Re: How to add manually some model "elements" to a diagram (where "elements" are [message #119997 is a reply to message #119984] Tue, 17 April 2007 16:34 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
I think this can be accomplished in many ways, one of them is using edit
policies

For example, in GMF every time you open a diagram we have code that
synchronize the Diagram with semantic model.

The nice thing about edit policies is that they will not just be invoked
when you open your diagram but they are alive, by alive i mean that they
will refresh when your edit part will refresh and they can listen to
semantic or diagram elements of interest so for example if some one
delete the task and while the diagram is open your edit policy might
respond to that by doing some semantic changes

you can take a look at the CanonicalEditPolicy as an example

I hope this helps

Ben Renwart wrote:
> Hi all,
>
> My problem seems to be simple but I don't know how to solve it because
> I'm new on GMF.
>
> For example, I use the GMF BPMN editor. When I create a new Diagram (a
> new File) or when I open an already existing one, my goal is to load "on
> launch" a file saved on my local harddisk... This file contains pieces
> of information which I want to use to "complete" my model while loading
> it. For example, Imagine that I want to add a "Task" to my diagram
> because this task is defined in the loaded file...
>
> No problem to load my file, but... The problem is that I don't know how
> (and where?) to add the code to manually add some elements to the model
> when I start my GMF editor ?
>
> Can you help me by giving an example of such a job ?
>
>
Re: How to add manually some model "elements" to a diagram (where "elements" are [message #120194 is a reply to message #119997] Wed, 18 April 2007 12:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renwart.lippmann.lu

Hi Mohammed,

Thanks for your fast reply...

If I've understood correctly :
- The fact of adding a semantic element to my model will be
automatically "shown" on the diagram because of XXXCanonicalEditPolicy ?
- If it's true, I'd like to know how I have to do to add elements to my
semantic model ? I don't know where classes to use and methods to
execute to do that...
- If I don't understand, could you give me an alternative solution ?


Please note that in fact, the goal of my searches on that problem is to
load a file when I open a diagram and add some elements to my diagram
(without adding any of elements found in the common diagram file). In
other words, I just want to display elements founds in the loaded file
on launch and not the ones saved in the GMF diagram file. Finally, note
that I'm using GMF 1.0 (But I can update to 2.0 if necessary).

Thanks for your help,

Ben.




Mohammed Mostafa a écrit :
> I think this can be accomplished in many ways, one of them is using edit
> policies
>
> For example, in GMF every time you open a diagram we have code that
> synchronize the Diagram with semantic model.
>
> The nice thing about edit policies is that they will not just be invoked
> when you open your diagram but they are alive, by alive i mean that they
> will refresh when your edit part will refresh and they can listen to
> semantic or diagram elements of interest so for example if some one
> delete the task and while the diagram is open your edit policy might
> respond to that by doing some semantic changes
>
> you can take a look at the CanonicalEditPolicy as an example
>
> I hope this helps
>
> Ben Renwart wrote:
>
>> Hi all,
>>
>> My problem seems to be simple but I don't know how to solve it because
>> I'm new on GMF.
>>
>> For example, I use the GMF BPMN editor. When I create a new Diagram (a
>> new File) or when I open an already existing one, my goal is to load
>> "on launch" a file saved on my local harddisk... This file contains
>> pieces of information which I want to use to "complete" my model while
>> loading it. For example, Imagine that I want to add a "Task" to my
>> diagram because this task is defined in the loaded file...
>>
>> No problem to load my file, but... The problem is that I don't know
>> how (and where?) to add the code to manually add some elements to the
>> model when I start my GMF editor ?
>>
>> Can you help me by giving an example of such a job ?
>>
>>
Re: How to add manually some model "elements" to a diagram (where "elements" are [message #120245 is a reply to message #120194] Wed, 18 April 2007 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: newsgroups.elmarweber.org

Hello Ben,

> If I've understood correctly :
> - The fact of adding a semantic element to my model will be
> automatically "shown" on the diagram because of XXXCanonicalEditPolicy ?

Yes, as long as you defined the proper views for the semantic element.


> - If it's true, I'd like to know how I have to do to add elements to
> my semantic model ? I don't know where classes to use and methods to
> execute to do that...

Depending under which conditions you want to add elements: via actions
(see
< http://wiki.eclipse.org/index.php/GMF_Tutorial_Part_3#Custom _Actions>),
by simply adding objects to your domain model (e.g. in the
handleNotification() method of the *CanonialEditPolicy (this would
ensure that a write transaction is already in progress) or virtually at
any point with a RecordingCommand.


> Please note that in fact, the goal of my searches on that problem is to
> load a file when I open a diagram and add some elements to my diagram
> (without adding any of elements found in the common diagram file). In
> other words, I just want to display elements founds in the loaded file
> on launch and not the ones saved in the GMF diagram file. Finally, note
> that I'm using GMF 1.0 (But I can update to 2.0 if necessary).

If I understand you right you want to ignore the domain model belonging
to the diagram and display a predefined other model?
Are the elements of the loaded file also representable in your EMF model?
This sounds to me as if you want to replace the original model with the
loaded one?

ciao,
elm
Re: How to add manually some model "elements" to a diagram (where "elements" are [message #120317 is a reply to message #120194] Wed, 18 April 2007 16:36 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Ben Renwart wrote:
> Hi Mohammed,
>
> Thanks for your fast reply...
>
> If I've understood correctly :
> - The fact of adding a semantic element to my model will be
> automatically "shown" on the diagram because of XXXCanonicalEditPolicy ?

This is correct if you have a canonical edit policy taking care of that
element synchronization

> - If it's true, I'd like to know how I have to do to add elements to
> my semantic model ? I don't know where classes to use and methods to
> execute to do that...

if you want to create a semantic element take a look at
CreateElementCommand if you are trying to create views take a look at
CanonicalEditPolicy#createViews

> - If I don't understand, could you give me an alternative solution ?
>

>
> Please note that in fact, the goal of my searches on that problem is to
> load a file when I open a diagram and add some elements to my diagram
> (without adding any of elements found in the common diagram file). In
> other words, I just want to display elements founds in the loaded file
> on launch and not the ones saved in the GMF diagram file. Finally, note
> that I'm using GMF 1.0 (But I can update to 2.0 if necessary).

I'm not sure i got what do you mean here, The thing I'm trying to say if
you want to edit the diagram or the semantic model you can do that using
an EditPolicy, it does not need to be a conical edit policy since
canonical edit policy had a very specific job which is Synchronizing the
model and the view


>
> Thanks for your help,
>
> Ben.
>
>
>
>
> Mohammed Mostafa a écrit :
>> I think this can be accomplished in many ways, one of them is using
>> edit policies
>>
>> For example, in GMF every time you open a diagram we have code that
>> synchronize the Diagram with semantic model.
>>
>> The nice thing about edit policies is that they will not just be
>> invoked when you open your diagram but they are alive, by alive i mean
>> that they will refresh when your edit part will refresh and they can
>> listen to semantic or diagram elements of interest so for example if
>> some one delete the task and while the diagram is open your edit
>> policy might respond to that by doing some semantic changes
>>
>> you can take a look at the CanonicalEditPolicy as an example
>>
>> I hope this helps
>>
>> Ben Renwart wrote:
>>
>>> Hi all,
>>>
>>> My problem seems to be simple but I don't know how to solve it
>>> because I'm new on GMF.
>>>
>>> For example, I use the GMF BPMN editor. When I create a new Diagram
>>> (a new File) or when I open an already existing one, my goal is to
>>> load "on launch" a file saved on my local harddisk... This file
>>> contains pieces of information which I want to use to "complete" my
>>> model while loading it. For example, Imagine that I want to add a
>>> "Task" to my diagram because this task is defined in the loaded file...
>>>
>>> No problem to load my file, but... The problem is that I don't know
>>> how (and where?) to add the code to manually add some elements to the
>>> model when I start my GMF editor ?
>>>
>>> Can you help me by giving an example of such a job ?
>>>
>>>
Previous Topic:how to customize focus feedback
Next Topic:Does EMF/GMF support this?
Goto Forum:
  


Current Time: Fri Aug 16 20:36:59 GMT 2024

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

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

Back to the top