How can I generate children for a node? [message #83040] |
Tue, 05 December 2006 09:59  |
Eclipse User |
|
|
|
Originally posted by: christian.daenekas.informatik.uni-oldenburg.de
Hi there!
I´ve got a specific node in my editor for which I´d like to create child
elements from another class. I´ve defined a compartment similar to the
Mindmap Example (part 2). I can create a node and create another element
(which is represented by its label like the ThreadItems from the
example) inside this node manually by using the palette. It semantically
represents a parameter for the parentnode. What I want to do is
something different. When I create the parentnode I specify an ID. After
I´ve done that I look up the ID from some datastorage (XML for example).
There is specified which parameters the node requires and how they are
named. They corresponding child elements (parameters) shall now be
created (using the names found in the datasource as the labels) both in
the graphical and semantical model. Any idea how I can manage this? Help
would be very appreciated.
Greeting,
Christian
|
|
|
|
|
|
|
|
Re: How to create elements in semantic/graphical layer by listening to events? [message #84078 is a reply to message #84059] |
Thu, 07 December 2006 12:07   |
Eclipse User |
|
|
|
Christian Dänekas wrote:
Hi Christian;
I'll try to explain how to implement this form the Runtime point of view
EditParts handle EMF events in the handleNotificationEvent, so in your
case i would expect that your edit part will listen to the EMF event
generated when you create/change the ID, then in response it will need
to create the 2 semantic elements for the parameters, also there should
be a canonical edit policy listening to the element owning the
parameters, This canonical edit policy should be installed on the
compartments that will contains these parameters. So as soon as you
create the semantic elements for the parameters the canonical edit
policy will kick in and create the views for these parameters, this will
trigger a refresh on the compartment which will result in creating the
edit parts for these parameters.
If you provide me with more specifics about your case, i might be able
to explain in more details
> Hello again,
>
> I´m really somewhat puzzled about this whole issue. I understand it this
> way:
>
> When an attribute of a node is changed, an event is generated by
>
> public void notifyChanged(Notification notification)
>
> in the ..ItemProvider class. As I understand it by now the events are
> handled by
>
> protected void handleNotificationEvent(Notification event)
>
> in the diagram.edit.parts.[...]EditPart classes.
> I think I need general advice on how events must be handled an new
> elements can be created (persistent in all model-layers).
>
> I´ve made some pics of what I want to do. I insert a new node which has
> an attribute id. By standard the id isn´t specified. This look like in
> "no_id.jpg". Now i specify the id to "testid" This id is stored
> somewhere (e.g. xml-file) and it´s specified that testid must have two
> parameters "testparameter1" and "testparameter2". So after the id was
> specified the node looks like "id_specified.jpg" and the parameters are
> also stored in the semantic layer. Maybe you or someone else can help me
> out a bit further. I´m using GMF 2.0M2.
>
> Thanks in advance
>
> Alex Shatalin schrieb:
>> Hello Christian,
>>
>> It depends on your configuration, but I thinkg graphical part of the
>> model should be corrected only in the place of parsing/combining the
>> labels - quite located part.
>>
>>
>> -----------------
>> Alex Shatalin
>>
>>
>
>
> ------------------------------------------------------------ ------------
>
>
> ------------------------------------------------------------ ------------
>
|
|
|
Re: How to create elements in semantic/graphical layer by listening to events? [message #84093 is a reply to message #84078] |
Thu, 07 December 2006 12:55   |
Eclipse User |
|
|
|
Originally posted by: christian.daenekas.informatik.uni-oldenburg.de
If I understand your explanation correctly the place to create the
elements that end up in the compartment is the handleNotificationEvent
method. There is a OperatorIdEditPart class that i think is the right
one (Operator is the class and Id its attribute). The
handleNotificationEvent method looks like this (generated code):
protected void handleNotificationEvent(Notification event) {
Object feature = event.getFeature();
if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(f eature)) {
Integer c = (Integer) event.getNewValue();
setFontColor(DiagramColorRegistry.getInstance().getColor(c)) ;
} else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(
feature)) {
refreshUnderline();
} else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough()
.equals(feature)) {
refreshStrikeThrough();
} else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(
feature)
|| NotationPackage.eINSTANCE.getFontStyle_FontName().equals(
feature)
|| NotationPackage.eINSTANCE.getFontStyle_Bold()
.equals(feature)
|| NotationPackage.eINSTANCE.getFontStyle_Italic().equals(
feature)) {
refreshFont();
} else {
if (getParser() != null
&& getParser().isAffectingEvent(event,
getParserOptions().intValue())) {
refreshLabel();
}
if (getParser() instanceof ISemanticParser) {
ISemanticParser modelParser = (ISemanticParser) getParser();
if (modelParser.areSemanticElementsAffected(null, event)) {
removeSemanticListeners();
if (resolveSemanticElement() != null) {
addSemanticListeners();
}
refreshLabel();
}
}
}
super.handleNotificationEvent(event);
}
So all I´ve got is the event. Now the information I need is which
operator element caused the event (so that I can create the parameters
for the correct element), what the Id attribute value of this element is
so that i can look up if there are parameters to specify and what names
they have (the names end up as label figures in the node). What I did
not understand yet I think is how the creation of semantic elements
works. The rest of the process should work automatically, if I got you
right. This is all information i can think of that may be relevant.
Thanks in advance
Mohammed Mostafa schrieb:
> Christian Dänekas wrote:
>
> Hi Christian;
>
> I'll try to explain how to implement this form the Runtime point of view
>
> EditParts handle EMF events in the handleNotificationEvent, so in your
> case i would expect that your edit part will listen to the EMF event
> generated when you create/change the ID, then in response it will need
> to create the 2 semantic elements for the parameters, also there should
> be a canonical edit policy listening to the element owning the
> parameters, This canonical edit policy should be installed on the
> compartments that will contains these parameters. So as soon as you
> create the semantic elements for the parameters the canonical edit
> policy will kick in and create the views for these parameters, this will
> trigger a refresh on the compartment which will result in creating the
> edit parts for these parameters.
>
> If you provide me with more specifics about your case, i might be able
> to explain in more details
|
|
|
|
Re: How to create elements in semantic/graphical layer by listening to events? [message #84515 is a reply to message #84078] |
Sun, 10 December 2006 06:28  |
Eclipse User |
|
|
|
Originally posted by: christian.daenekas.informatik.uni-oldenburg.de
Do you need any more information than I provided in my other post? Maybe
you have any helpful links about the handlng of events in GMF and how I
can get the desired information from it.
Greetings,
Christian
Mohammed Mostafa schrieb:
> Christian Dänekas wrote:
>
> Hi Christian;
>
> I'll try to explain how to implement this form the Runtime point of view
>
> EditParts handle EMF events in the handleNotificationEvent, so in your
> case i would expect that your edit part will listen to the EMF event
> generated when you create/change the ID, then in response it will need
> to create the 2 semantic elements for the parameters, also there should
> be a canonical edit policy listening to the element owning the
> parameters, This canonical edit policy should be installed on the
> compartments that will contains these parameters. So as soon as you
> create the semantic elements for the parameters the canonical edit
> policy will kick in and create the views for these parameters, this will
> trigger a refresh on the compartment which will result in creating the
> edit parts for these parameters.
>
> If you provide me with more specifics about your case, i might be able
> to explain in more details
>
>
>
>> Hello again,
>>
>> I´m really somewhat puzzled about this whole issue. I understand it this
>> way:
>>
>> When an attribute of a node is changed, an event is generated by
>>
>> public void notifyChanged(Notification notification)
>>
>> in the ..ItemProvider class. As I understand it by now the events are
>> handled by
>>
>> protected void handleNotificationEvent(Notification event)
>>
>> in the diagram.edit.parts.[...]EditPart classes.
>> I think I need general advice on how events must be handled an new
>> elements can be created (persistent in all model-layers).
>>
>> I´ve made some pics of what I want to do. I insert a new node which has
>> an attribute id. By standard the id isn´t specified. This look like in
>> "no_id.jpg". Now i specify the id to "testid" This id is stored
>> somewhere (e.g. xml-file) and it´s specified that testid must have two
>> parameters "testparameter1" and "testparameter2". So after the id was
>> specified the node looks like "id_specified.jpg" and the parameters are
>> also stored in the semantic layer. Maybe you or someone else can help me
>> out a bit further. I´m using GMF 2.0M2.
>>
>> Thanks in advance
>>
>> Alex Shatalin schrieb:
>>> Hello Christian,
>>>
>>> It depends on your configuration, but I thinkg graphical part of the
>>> model should be corrected only in the place of parsing/combining the
>>> labels - quite located part.
>>>
>>>
>>> -----------------
>>> Alex Shatalin
>>>
>>>
>>
>> ------------------------------------------------------------ ------------
>>
>>
>> ------------------------------------------------------------ ------------
>>
|
|
|
Powered by
FUDForum. Page generated in 0.27959 seconds