Home » Modeling » GMF (Graphical Modeling Framework) » Re: Custom code after initialization (Short question)
Re: Custom code after initialization (Short question) [message #167362] |
Tue, 08 January 2008 10:23  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Tomas,
This sounds like purely a GMF question so I've added the GMF newsgroup
to the "to" list of the reply so it can be answered there.
Tomas Zijdemans wrote:
> Hi all :)
>
> I'm trying to execute some model specific code after a diagram has
> been initialized (add some elements that always should be present at
> startup). I've experimented with the constructor of the diagram
> element, but this constructor gets called many times at startup, and
> my code should only be run once per diagram. Where should I rather put
> my code?
>
>
> Best Regards,
>
> Tomas Zijdemans
|
|
| | | | | | |
Re: Custom code after initialization (Short question) [message #168128 is a reply to message #168120] |
Mon, 14 January 2008 21:29   |
Eclipse User |
|
|
|
hi ed,
normally you can add additional behavior, e.g. initializing an element
with an EditHelper(Advice). Since they are in reality called by the
parent element, this is not possible for the root element right now.
-stefan
P.S. I've fixed this genmodel bug (id=215282) ... 3 lines of code :(
Ed Merks wrote:
> Stefan,
>
> I'm not sure I understand the issue very well, but it seems a reasonable
> thing...
>
>
> SKuhn wrote:
>> hi ed,
>>
>> maybe it would be worth it executing the EditHelper for the
>> root/canvas element?
>>
>> should I file a feature request?
>>
>> -stefan
>>
>> Ed Merks wrote:
>>> Tomas,
>>>
>>> This sounds like purely a GMF question so I've added the GMF
>>> newsgroup to the "to" list of the reply so it can be answered there.
>>>
>>>
>>> Tomas Zijdemans wrote:
>>>> Hi all :)
>>>>
>>>> I'm trying to execute some model specific code after a diagram has
>>>> been initialized (add some elements that always should be present at
>>>> startup). I've experimented with the constructor of the diagram
>>>> element, but this constructor gets called many times at startup, and
>>>> my code should only be run once per diagram. Where should I rather
>>>> put my code?
>>>>
>>>>
>>>> Best Regards,
>>>>
>>>> Tomas Zijdemans
|
|
|
Re: Custom code after initialization (Short question) [message #168172 is a reply to message #168128] |
Tue, 15 January 2008 06:37   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Stefan,
I see. Allowing an EditHelper for the root would make really good sense
then.
I've commented on the bug that the option should to serialize with a
schema location, which is essential for supporting purely dynamic models
as the document suggests is supported, should be added at the time the
resource is created so anyone saving the resource will do so correctly.
It also seems to me that this decorator approach should allow a static
model to be used and that in that case, the generated item providers
could be used in the properties view (because item providers are
registered and could be discovered as needed).
SKuhn wrote:
> hi ed,
>
> normally you can add additional behavior, e.g. initializing an element
> with an EditHelper(Advice). Since they are in reality called by the
> parent element, this is not possible for the root element right now.
>
> -stefan
>
> P.S. I've fixed this genmodel bug (id=215282) ... 3 lines of code :(
>
> Ed Merks wrote:
>> Stefan,
>>
>> I'm not sure I understand the issue very well, but it seems a
>> reasonable thing...
>>
>>
>> SKuhn wrote:
>>> hi ed,
>>>
>>> maybe it would be worth it executing the EditHelper for the
>>> root/canvas element?
>>>
>>> should I file a feature request?
>>>
>>> -stefan
>>>
>>> Ed Merks wrote:
>>>> Tomas,
>>>>
>>>> This sounds like purely a GMF question so I've added the GMF
>>>> newsgroup to the "to" list of the reply so it can be answered there.
>>>>
>>>>
>>>> Tomas Zijdemans wrote:
>>>>> Hi all :)
>>>>>
>>>>> I'm trying to execute some model specific code after a diagram has
>>>>> been initialized (add some elements that always should be present
>>>>> at startup). I've experimented with the constructor of the diagram
>>>>> element, but this constructor gets called many times at startup,
>>>>> and my code should only be run once per diagram. Where should I
>>>>> rather put my code?
>>>>>
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Tomas Zijdemans
|
|
|
Re: Custom code after initialization (Short question) [message #168242 is a reply to message #168172] |
Tue, 15 January 2008 09:33   |
Eclipse User |
|
|
|
vote for:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=215344
-stefan
Ed Merks wrote:
> Stefan,
>
> I see. Allowing an EditHelper for the root would make really good sense
> then.
>
> I've commented on the bug that the option should to serialize with a
> schema location, which is essential for supporting purely dynamic models
> as the document suggests is supported, should be added at the time the
> resource is created so anyone saving the resource will do so correctly.
> It also seems to me that this decorator approach should allow a static
> model to be used and that in that case, the generated item providers
> could be used in the properties view (because item providers are
> registered and could be discovered as needed).
>
>
> SKuhn wrote:
>> hi ed,
>>
>> normally you can add additional behavior, e.g. initializing an element
>> with an EditHelper(Advice). Since they are in reality called by the
>> parent element, this is not possible for the root element right now.
>>
>> -stefan
>>
>> P.S. I've fixed this genmodel bug (id=215282) ... 3 lines of code :(
>>
>> Ed Merks wrote:
>>> Stefan,
>>>
>>> I'm not sure I understand the issue very well, but it seems a
>>> reasonable thing...
>>>
>>>
>>> SKuhn wrote:
>>>> hi ed,
>>>>
>>>> maybe it would be worth it executing the EditHelper for the
>>>> root/canvas element?
>>>>
>>>> should I file a feature request?
>>>>
>>>> -stefan
>>>>
>>>> Ed Merks wrote:
>>>>> Tomas,
>>>>>
>>>>> This sounds like purely a GMF question so I've added the GMF
>>>>> newsgroup to the "to" list of the reply so it can be answered there.
>>>>>
>>>>>
>>>>> Tomas Zijdemans wrote:
>>>>>> Hi all :)
>>>>>>
>>>>>> I'm trying to execute some model specific code after a diagram has
>>>>>> been initialized (add some elements that always should be present
>>>>>> at startup). I've experimented with the constructor of the diagram
>>>>>> element, but this constructor gets called many times at startup,
>>>>>> and my code should only be run once per diagram. Where should I
>>>>>> rather put my code?
>>>>>>
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>> Tomas Zijdemans
|
|
| | |
Re: Custom code after initialization (Short question) [to: Zac] [message #168874 is a reply to message #168812] |
Sun, 20 January 2008 12:39  |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
SKuhn wrote:
> I'm not sure if I got you right, but when creating elements on startup,
> you don't want to create diagram elements.
Yep :) What I meant was that the diagram element does not have a
XYZCreateCommand class. I want to add some classes when a diagram is
created - if I override the doDefaultElementCreation() of an object the
code will only execute at creation time of those objects.
You would rather want to
> create semantic elements of you domain model and let gmf choose the
> representation later on.
I succeeded in adding semantic elements in the createDiagram method of
the XYZUtil method, but now I'm wondering: I want to set a specific
location for my new elements. The only way I know of is through commands
(request.setLocation etc.).
Any ideas?
Best Regards,
Tomas Zijdemans
>
>
> Tomas Zijdemans wrote:
>> Zac Woof wrote:
>>> I had a similar requirement and I ended up overriding the
>>> doDefaultElementCreation() method in the CreateCommand class for my
>>> element and creating the child objects there on the actual EObject.
>>> Something like this:
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> @Override
>>> protected EObject doDefaultElementCreation() {
>>> MyObject obj = (MyObject) super.doDefaultElementCreation();
>>> obj.createChildObjects();
>>> return obj;
>>> }
>>>
>> Hi!
>>
>> This worked great for running customized code when an object is
>> created, but my problem now is that the diagram element do not have a
>> create command - so I can't create objects on diagram startup using
>> this method.
>>
>>
>> Regards,
>>
>> Tomas Zijdemans
|
|
|
Goto Forum:
Current Time: Mon May 12 00:28:23 EDT 2025
Powered by FUDForum. Page generated in 0.03397 seconds
|