Home » Modeling » EMF » Custom code after initialization (Short question)
Custom code after initialization (Short question) [message #415823] |
Tue, 08 January 2008 09:26  |
Eclipse User |
|
|
|
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 #415984 is a reply to message #415983] |
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 #415987 is a reply to message #415984] |
Tue, 15 January 2008 06:37   |
Eclipse User |
|
|
|
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 #415992 is a reply to message #415987] |
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 #416143 is a reply to message #416113] |
Fri, 18 January 2008 11:49  |
Eclipse User |
|
|
|
hi tomas,
I'm not sure if I got you right, but when creating elements on startup,
you don't want to create diagram elements. You would rather want to
create semantic elements of you domain model and let gmf choose the
representation later on.
-stefan
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: Tue Jul 15 04:09:20 EDT 2025
Powered by FUDForum. Page generated in 0.28211 seconds
|