Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » remove code that restricts contained nodes from been drawn
remove code that restricts contained nodes from been drawn [message #204278] Wed, 03 September 2008 11:25 Go to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi, does anyone know where I can find the section of generated code that
stops Nodes been drawn if they belong to a container?
(I need to disable this code so that contained nodes are drawn on my
diagram)

This is because I was unable to use shadow/phantom nodes because it caused
problems in my XML output, so I have disabled the code that removed nodes
when they were given a containment relationship (allowing me to see the
nodes on the diagram when drawing it, and correcting XML model output).
However this has now caused problems when loading a diagram from the
XML(note all xml code is correct), since the graphical representation of
the diagram no-longer uses shadow/phantom nodes the contained nodes are
not displayed on diagram generation!

I am fairly sure that somewhere in the generated code is a function that
checks to see if a node has a container and if it does It restricts the
node from been drawn, I just have no idea where to look for this!

Any help you can offer would be greatly appreciated,
Thank you in advance,
Gary
Re: remove code that restricts contained nodes from been drawn [message #204971 is a reply to message #204278] Wed, 10 September 2008 10:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

You can add back reference to the containment reference and specify OCL constraint
for the NodeMapping like: "myContainerReference.oclIsUndefined()"

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #205100 is a reply to message #204971] Wed, 10 September 2008 13:45 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex, I added... myContainerReference.oclIsUndefined() ...However I
believe I am suposed to replace myContainerReference with the reference of
the container of this class???

Please note a class can have different containers, and also some can be
contained by an element of the same type (depending on relationship link
used)
Re: remove code that restricts contained nodes from been drawn [message #205114 is a reply to message #205100] Wed, 10 September 2008 14:50 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> Hi Alex, I added... myContainerReference.oclIsUndefined() ...However I
> believe I am suposed to replace myContainerReference with the
> reference of the container of this class???
Well, it depends on your meta-model. myContainerReference should be a reference
pointing to the container of this very EObject (or null if there is no).
You can either make this reference eOpposite to the containment one and let
EMF do the rest for you or you can make this reference derived and implement
corresponding part of EMF-generated API manually.

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #205218 is a reply to message #205114] Thu, 11 September 2008 10:41 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex, I've tried what you said and I get the following ERROR

Severity and Description Path Resource Location Creation Time Id
Invalid expression body 'myContainerReference.oclIsUndefined()'. Cause:
Invalid expression body 'myContainerReference.oclIsUndefined()'. Cause:
ERROR in (variableExpCS): (Unrecognized variable:
(myContainerReference)) levelZero/model CIMLevelZero.gmfmap Unknown 1221119240752 235242



This suggests that myContainerReference is not a valid reference variable,
if this is the case, how else can I access the containerReference?

Note: I am adding the OCL Constraint into the *.gmfmap Node Mapping
Re: remove code that restricts contained nodes from been drawn [message #205280 is a reply to message #205218] Thu, 11 September 2008 11:34 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

You have to create myContainerReference in your meta-model...
There is no other ways to access contained from within OCL. Another option
is to create java constraint and use EObject API for accessing container.

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #205285 is a reply to message #205280] Thu, 11 September 2008 11:40 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
OK, thanks Alex
....Unfortunatly I have to stick to a strict model, so I will try the
other option you gave, thanks once again for your advice!
Re: remove code that restricts contained nodes from been drawn [message #206459 is a reply to message #205285] Tue, 23 September 2008 09:01 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex,
I tryed the other solution but this hasn't worked!
...do you have any ideas why this could be the case?
...if not, do you have any other ideas how I could solve this issue?

I'm quickly running out of solutions to this problem
(Note: these issues are caused because I need to model my containment
relationships as diagram links, do you not think this would be a good
feature for GMF to adopt? since many companys seem to want to display
their models this way).

Thanks in advance,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206491 is a reply to message #206459] Tue, 23 September 2008 09:34 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> ..if not, do you have any other ideas how I could solve this issue?
Well, no other ideas. do you have any particular question/problem to discuss?
Otherwise I think you can start with debugging your application to see the
reason of the problem.

> relationships as diagram links, do you not think this would be a good
> feature for GMF to adopt? since many companys seem to want to display
We do have several diagrams visualizing containment reference as a link on
the diagram, so it depends on the other consitions you have.

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206499 is a reply to message #206491] Tue, 23 September 2008 09:55 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Basicaly the changes made don't have the required affect!

-I have tried shadow nodes, however this causes the XML model output to be
incorrect (the nodes are not contained within the canvas)

-Because of this I looked for another solution, finding away to keep all
my nodes related to the canvas, I found a way to stop the node from
disapearing when a containment relationship was used! This ment that the
produced XML was correct and that diagrams could be drawn as required
(seeing the containment relationship as a diagram link) However When you
generate a diagram from the model XML (another requirement) the contained
nodes are no longer displayed.

The solution (remove code that restricts contained nodes from been drawn)
was hopefuly going to solve this issue however it doesn't work as
required, since contained nodes are still not drawn!
____________________________________________________________ ________________
my ecore file consists of over 150 classes all with a possible containment
relationship and some with more that one, the top level of my diagram is
kind of like this: (possible links are noted in brackets at side of
element)

A (container)
|
__B__ (container/not container/can contain elements of same type)!Abstract
| |
C D (can contain elements of same type)

hope this makes sence! any help you can give would be greatly appreciated

Thanks in advance,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206529 is a reply to message #206499] Tue, 23 September 2008 10:35 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> from disapearing when a containment relationship was used! This ment
> that the produced XML was correct and that diagrams could be drawn as
> required (seeing the containment relationship as a diagram link)
> However When you generate a diagram from the model XML (another
> requirement) the contained nodes are no longer displayed.
Looks like diagram itself works perfectly, but diagram initialization has
some problems.. Wich particular nodes do you miss on re-generating the diagram
from model file? See generated ???DiagramUpdater class - this class is responsible
for diagram updating process. Nevertheless it sounds strange that you are
able to draw some nodes on diagram and can not re-create these nodes from
the model.. Nearly the same updating code used for diagram initialization
and diagram updating.. To my unedrstansing you should loose these nodes on
reopenning diagram editor too. Can you try to reopen diagram to check it?

> The solution (remove code that restricts contained nodes from been
> drawn) was hopefuly going to solve this issue however it doesn't work as
> required, since contained nodes are still not drawn!
AFAIU corresponding nodes are visualized properly on a diagram if you create
it (there is no code hiding these nodes) the problem is - corresponding diagram
nodes will not be created on diagram initialization (Updater code should
be corrected probably).


> A (container)
> |
> __B__ (container/not container/can contain elements of same type)!Abstract
> | |
> C D (can contain elements of same type)
Few questions about this model structure. First of all, are these "lines"
wisualizing containment references in domain model? And am I right that:
1. A is a model element associated with diagram?
2. B can be created inside diagram element and should be visualized as a
top-level nodes?
3. C/D are children of B model element and should be visualized as top-level
diagram nodes with link from parent B element?
4. C/D can be parent elements for C/D accordingly?

5. Wich elements should not be moved to the resource root on corresponding
containment link deletion, but better should stay attached to A (diagram)
element? Do you have any appropriate containment reference in A for it?

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206561 is a reply to message #206529] Tue, 23 September 2008 11:32 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Thanks Alex,
I have answered your questions below...

Q)Looks like diagram itself works perfectly, but diagram initialization
has some problems.. Wich particular nodes do you miss on re-generating the
diagram from model file?
A)all the nodes with a containment relationship are not drawn

Q)See generated ???DiagramUpdater class - this class is responsible for
diagram updating process. Nevertheless it sounds strange that you are able
to draw some nodes on diagram and can not re-create these nodes from the
model.. Nearly the same updating code used for diagram initialization and
diagram updating.. To my unedrstansing you should loose these nodes on
reopenning diagram editor too. Can you try to reopen diagram to check it?
A)I have already checked this and the diagram is drawn with all the nodes,
its only when initalizing from the model file that they are not drawn!

AFAIU corresponding nodes are visualized properly on a diagram if you
create it (there is no code hiding these nodes) the problem is -
corresponding diagram nodes will not be created on diagram initialization
(Updater code should be corrected probably).
-I thought it was the case that it checked to see if nodes had a
containment relationship, and if this was the case it didn't draw them!
Due to this I haven't looked at the Updater code(maby this should be my
next move?)


A (container)
|
__B__ (container/not container/can contain elements of same type)!Abstract
| |
C D (can contain elements of same type)

Few questions about this model structure. First of all, are these "lines"
wisualizing containment references in domain model? And am I right that:
1. A is a model element associated with diagram?
-A is the canvas of my diagram and the root element of my model.

2. B can be created inside diagram element and should be visualized as a
top-level nodes?
-B is an abstract class and therefore is not displayed in the diagram
however it is a parent to the classes below (C,D) meaning C and D gain all
its attributes and also its relationships (including containment to self)
...this means all classes below this can have a containment to eachother!

3. C/D are children of B model element and should be visualized as
top-level diagram nodes with link from parent B element?
-C and D should be visualized as top-level nodes however they do not
display a link to B(as B is an abstract class)

4. C/D can be parent elements for C/D accordingly?
-Yes

5. Wich elements should not be moved to the resource root on corresponding
containment link deletion, but better should stay attached to A (diagram)
element? Do you have any appropriate containment reference in A for it?
-This is not a problem if i can get nodes with a containment link to be
drawn on diagram initalization(this was only a problem when using shadow
nodes)
-A is simply the root class (and canvas) with a containment relationship
to B

Thank you,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206585 is a reply to message #206561] Tue, 23 September 2008 12:30 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> on re-generating the diagram from model file? A)all the nodes with a
> containment relationship are not drawn
Do you mean nodes with incoming containment reference visualized as link?

> reopen diagram to check it? A)I have already checked this and the
> diagram is drawn with all the nodes, its only when initalizing from
> the model file that they are not drawn!
So, looks like diagram initialization code works incorrectly..

> (Updater code should be corrected probably).
> -I thought it was the case that it checked to see if nodes had a
> containment relationship, and if this was the case it didn't draw
> them!
Then to my understanding these nodes should not be drawn on "normal" diagram
as well. So, looks like the problem is: undater does not recognize these
nodes as existing diagram elements and do not try to create them.

> Due to this I haven't looked at the Updater code(maby this should be
> my next move?)
Looks like. I suggest you debugging updated on small diagram to see why corresponding
element was not recognized/created on diagram. I think you can first check
generated getA_1000SemanticChildren method. This method is responsible for
returning all the semantic elements of the main diagram element. In case
of containment reference represented as a links on diagram this method should
call getPhantomNodesIterator. I think you can try debugging this logic to
see why corresponding elements was not recognized as diagram nodes.
As an addition you can try debugging same method on existing diagram openning
to see the difference.

> A (container)
> |
> __B__ (container/not container/can contain elements of same
> type)!Abstract
> | |
> C D (can contain elements of same type)
So, you have two node mappings for C/D without containment reference specified
and link mapping visualizing containment reference from C/D to C/D, right?
All C/D nodes without incoming containment link (just created or after link
deletion) have to be stored inside A (using containment reference from A
to C/D), right?

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206602 is a reply to message #206585] Tue, 23 September 2008 12:51 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
on re-generating the diagram from model file? A)all the nodes with a
containment relationship are not drawn

Do you mean nodes with incoming containment reference visualized as link?
----Yes!

reopen diagram to check it? A)I have already checked this and the
diagram is drawn with all the nodes, its only when initalizing from
the model file that they are not drawn!

So, looks like diagram initialization code works incorrectly..
---This could very well be the case!

(Updater code should be corrected probably).
-I thought it was the case that it checked to see if nodes had a
containment relationship, and if this was the case it didn't draw
them!

Then to my understanding these nodes should not be drawn on "normal"
diagram as well. So, looks like the problem is: undater does not recognize
these nodes as existing diagram elements and do not try to create them.
---Yes, Maby yor right!

Due to this I haven't looked at the Updater code(maby this should be
my next move?)

Looks like. I suggest you debugging updated on small diagram to see why
corresponding element was not recognized/created on diagram. I think you
can first check generated getA_1000SemanticChildren method. This method is
responsible for returning all the semantic elements of the main diagram
element. In case of containment reference represented as a links on
diagram this method should call getPhantomNodesIterator. I think you can
try debugging this logic to see why corresponding elements was not
recognized as diagram nodes.
As an addition you can try debugging same method on existing diagram
openning to see the difference.
---OK, I will try your above suggestions and get back to you with the
results!


A (container)
|
__B__ (container/not container/can contain elements of same
type)!Abstract
| |
C D (can contain elements of same type)

So, you have two node mappings for C/D without containment reference
specified and link mapping visualizing containment reference from C/D to
C/D, right?
---Yes!

All C/D nodes without incoming containment link (just created or after
link deletion) have to be stored inside A (using containment reference
from A to C/D), right?
---Yes!

Thank you for your advice,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206610 is a reply to message #206585] Tue, 23 September 2008 12:59 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex, it seams I may have a problem with the following (in diagram
updater):

public static List getCIM_Model_79ContainedLinks(View view) {
CIM_Model modelElement = (CIM_Model) view.getElement();
List result = new LinkedList();
result
.addAll(getOutgoingFeatureModelFacetLinks_CIM_Model_Elements _3048(modelElement));
return result;
}

....Error = getOutgoingFeatureModelFacetLinks_CIM_Model_Elements_3048 is
undefined

Could this be the cause of my problems?
What is this methods purpose?
Re: remove code that restricts contained nodes from been drawn [message #206618 is a reply to message #206610] Tue, 23 September 2008 13:49 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex, I have created this method as demonstraited below, this still has
no affect on the issue I am facing!

private static Collection
getOutgoingFeatureModelFacetLinks_CIM_Model_Elements_3048(
CIM_Model modelElement) {
Collection result = new LinkedList();
for (Iterator destinations = modelElement.getElements().iterator();
destinations
.hasNext();) {
CIM_Model destination = (CIM_Model) destinations.next();
result.add(new CIMLevelZeroLinkDescriptor(modelElement, destination,
CIMLevelZeroElementTypes.CIM_ModelElements_3048,
CIM_ModelElementsEditPart.VISUAL_ID));
}
return result;
}
____________________________________________________________ ____________

Now as you know I have been trying 2 methods the one with shadow nodes and
the one without, and as mentioned:

-- the one with shadow nodes works except produces incorrect XML since
nothing is contained within the canvas! (note: contained nodes are
displayed but the link between is shown as a empty node rather than a link
when initalizing from the model file)

-- the one without shadow nodes works except doesn't display the contained
nodes at all when initalizing from the model file! (note: the diagram file
is displayed correctly)

....I think it best to decide which method I should use, based on which
will be the easyest to fix since working with 2 possible solutions is
taking more time than needed!

Your suggestion on which method to use and fix would be greatly
appreciated since you have a much greater knowlage of GMF and know which
would probably be the easyest issue to solve!!!
Re: remove code that restricts contained nodes from been drawn [message #206634 is a reply to message #206610] Tue, 23 September 2008 16:23 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> ...Error = getOutgoingFeatureModelFacetLinks_CIM_Model_Elements_3048
> is undefined
So, generated code was not compilable or do you mean something else?

>What is this methods purpose?
Search to the places in code calling this method. Some of the updater methods
can be not used by generated code..

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206648 is a reply to message #206618] Tue, 23 September 2008 16:50 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> Hi Alex, I have created this method as demonstraited below, this still
> has no affect on the issue I am facing!
Well, are you sure this method was the reason of the problem you are facing?
GMF-generated code should be compilable (at least, we do not have any reports
like this). Can you try to re-generate code from scratch (hope it will be
compilable then).

>the one with shadow nodes works except produces incorrect XML since
>nothing is contained within the canvas! (note: contained nodes are
I remember I already suggested a way to solve this problem - you have to
modify generated ???CreateCommand and ???ItemSemanticEditPolicy for containment
link.

>displayed but the link between is shown as a empty node rather than a link
>when initalizing from the model file)
Are you saying the "node" is visible instead of the link visualizing containment
reference on diagram?.. You have to double-check .gmfmap model in this case.

>-- the one without shadow nodes works except doesn't display the contained
>nodes at all when initalizing from the model file! (note: the diagram file
>is displayed correctly)
AFAIU you have to create ChildMappings for the contained nodes to place them
into the top-level nodes in this case.

> ...I think it best to decide which method I should use, based on which
> will be the easyest to fix since working with 2 possible solutions is
> taking more time than needed!
Sure, but for me two different proposed solutions produces really different
diagrams.. (Correct me if I'm wrong, but in first case you'll have only top-level
nodes connected with the links, in second one you'll have top-level nodes
visualizing their children inside their figures etc..) So, i think you should
decide which type of the diagram you are going to create and then choose
one of the solutions to follow (both can be implemented).

> Your suggestion on which method to use and fix would be greatly
> appreciated since you have a much greater knowlage of GMF and know
> which would probably be the easyest issue to solve!!!
For me both solutions looks rather different and taking into account the
fact we were discussing sol.1 in prev. messages in this thread I propose
you continue moving into that direction..

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206696 is a reply to message #206648] Wed, 24 September 2008 08:25 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi, Alex

Well, are you sure this method was the reason of the problem you are
facing?
GMF-generated code should be compilable (at least, we do not have any
reports like this). Can you try to re-generate code from scratch (hope it
will be compilable then).
----No, I have no idea if this is the reason for my problem, however I
have re-generated code from scratch and still this error is there.

I remember I already suggested a way to solve this problem - you have to
modify generated ???CreateCommand and ???ItemSemanticEditPolicy for
containment link.
----Yes, I tryed this though it would not alow me to create containment to
the canvas when the node is created!

Are you saying the "node" is visible instead of the link visualizing
containment reference on diagram?.. You have to double-check .gmfmap model
in this case.
---No, the parent node is displayed and the child node is displayed but
the link is replaced with an empty node, this also causes nodes to
disapear and move when you move one of the other nodes!

AFAIU you have to create ChildMappings for the contained nodes to place
them into the top-level nodes in this case.
---This cannot be done, since all nodes can be containde by all other nodes

Sure, but for me two different proposed solutions produces really
different diagrams.. (Correct me if I'm wrong, but in first case you'll
have only top-level nodes connected with the links, in second one you'll
have top-level nodes visualizing their children inside their figures
etc..) So, i think you should decide which type of the diagram you are
going to create and then choose one of the solutions to follow (both can
be implemented).
---I think both diagrams should produce the same result all top level
nodes visable and any containd children visible as nodes with a diagram
link.


For me both solutions looks rather different and taking into account the
fact we were discussing sol.1 in prev. messages in this thread I propose
you continue moving into that direction..
---OK, I agree, the solution with shadow nodes does also seam the best way
forward!

Thank you,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206720 is a reply to message #206634] Wed, 24 September 2008 09:25 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
So, generated code was not compilable or do you mean something else?
---Yes, was not compiled, however it was able to complie when i added my
method

Search to the places in code calling this method. Some of the updater
methods can be not used by generated code..
---This method is called in the following:
getContainedLinks (In DiagramUpdater)
collectAllLinks (In CanonicalEditPolicy)
Re: remove code that restricts contained nodes from been drawn [message #206728 is a reply to message #206696] Wed, 24 September 2008 09:29 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> ----No, I have no idea if this is the reason for my problem, however I
> have re-generated code from scratch and still this error is there.
I suggest you to strip down your model to have as few elements as it possible
to see if this error is still there. If it is you can submitt a bugzilla
entry for it.

> modify generated ???CreateCommand and ???ItemSemanticEditPolicy for
> containment link.
> ----Yes, I tryed this though it would not alow me to create
> containment to the canvas when the node is created!
Ok. general idea was: you can modify creation command to get proper container
(diagram element) from the command context is a similar way as it is done
with resource and modify appropriate reference to point to the newly created
element (reference from A to B should start pointing to created C/D).

> ---No, the parent node is displayed and the child node is displayed
> but the link is replaced with an empty node, this also causes nodes to
> disapear and move when you move one of the other nodes!
Looks like you have some other nodes defined in .gmfmap file.. Again, i suggest
you to completely clean .gmfmap file and make this diagram working for the
very simple situation then you have only diagram A with C/D elements.

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206736 is a reply to message #206720] Wed, 24 September 2008 09:33 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> So, generated code was not compilable or do you mean something else?
> ---Yes, was not compiled, however it was able to complie when i added
> my method
Did you execute non-compilable code of this diagram on prev. steps?..

> collectAllLinks (In CanonicalEditPolicy)
This execution can be a reason of incorrect diagram updating..
Once more i suggest you to make simple .gmfmap file describing diagram A
with C/D "phantom" nodes (NodeReferences without containmentFeature specified),
create .gmfgen file from it and generate code - generated code should be
compilable.

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206820 is a reply to message #206736] Wed, 24 September 2008 13:58 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex,
I have created a smaller more simple model based on mine and non of these
problems take place!
However This hasn't helped me descover whats wrong with my current tool!

...I'm not sure if it's the generated code thats the issue or not but even
after re-generating the code the problems still there, the only error
displayed in the generated code (which doesn't alow it to compile)is that
which I mentioned above, which I fixed by creating my own method(also
mentioned above) which I think is correct!
(so this suggests that the method I created is wrong OR the generated code
is simply not working as it should, the only reason I could think of for
this is that the model I am working with is too large and complex for
GMF(very unlikly!!!))
...Could you take a look at the method I created and see if you can spot
anything wrong with it?

____________________________________________________________ ________________
If the above problem is not the cause of the incorrect model file:

...What changes would you suggest I make to the 'ItemSemanticEditPolicy'
and the 'CreateCommand' of my containment class (canvas) Inorder to make a
link to the canvas on node creation?

...Also do you have any ideas why the other containment links on
Initalized diagrams are drawn as empty Nodes rather than links?

Thank you very much for your help in this, it is greatly appreciated,
Gary
Re: remove code that restricts contained nodes from been drawn [message #206852 is a reply to message #206820] Wed, 24 September 2008 14:22 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> However This hasn't helped me descover whats wrong with my current
> tool!
I'm suggesting you to try to lokate the reason of the problem. This reason
can be in error inside GMF or in .gmfmap definition you are using for this
diagram. In both situations you can end up with incorrectly working dagramm
editor. I think this is a key problem and I suggest you spending some time
on locating it.

> ..Could you take a look at the method I created and see if you can
> spot anything wrong with it?
Well, do not see anything wrong in it. Moreover, this method should not make
links converted to a node at least directly to my understanding...

> ..What changes would you suggest I make to the
> 'ItemSemanticEditPolicy' and the 'CreateCommand' of my containment
> class (canvas) Inorder to make a link to the canvas on node creation?
Default (generated) implementation of ???CreateCommand.doDefaultElementCreation()
method should be similar to:

Resource resource = getElementToEdit().eResource();
<???> newElement = <???>Factory.eINSTANCE.create<???>();
resource.getContents().add(newElement);

I suggest you to locate "A" instance associated with current diagram and
call A.getB().add(newElement); instead of "resource.getContents().add(newElement);"
there. I suppose "getElementToEdit()" will directly return you current instacne
of "A" element, but I suggest you to place a breakpoint into this method,
execute debugger and see what's happening on trying to create ??? element.

Same with SemanticEditPolicy - just debug generated code to see where to
put deleted link target instead of placing it into resource root.

> ..Also do you have any ideas why the other containment links on
> Initalized diagrams are drawn as empty Nodes rather than links?
no ideas. I think the reason is in incorrectly created mapping model. To
determine actual problem you have to debug generated Updater class while
initializing new diagram. I know, the generated code is big, but you can
simplify it by simplifying original model + this code is not so complex...

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #206908 is a reply to message #206852] Wed, 24 September 2008 15:37 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Well my mapping model is rather strange since all nodes are shadow nodes
due to the containment relationship link in the abstract class they
inherit from, which alows all nodes to contain all other nodes!
Re: remove code that restricts contained nodes from been drawn [message #207056 is a reply to message #206908] Thu, 25 September 2008 12:32 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
Hi Alex,
I have generated a diagram model based on the same meta model, only using
mapping for a few nodes!
This produced output correctly on one of the nodes bot in diagram file and
in the generated model file (however when i re-generated this it stoped
working correctly again!!!

This would suggest that my mapping model is correct atleast for that node
and link, but that GMF generated code is simply not working correctly!!!

Any ideas?

Thank you,
Gary
Re: remove code that restricts contained nodes from been drawn [message #207069 is a reply to message #207056] Thu, 25 September 2008 13:44 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> in the generated model file (however when i re-generated this it
> stoped working correctly again!!!
Did you change anything in .gmfmap/.gmfgen models or just re-generate the
code?
Can you compare first generation results with regenerated code?

-----------------
Alex Shatalin
Re: remove code that restricts contained nodes from been drawn [message #207076 is a reply to message #207069] Thu, 25 September 2008 14:12 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
I added a new node to the diagram in-order to further test this and it
stoped working, so I simply removed the extra node and re-generated but
this second time it failed to work!
Though everything was the same as before!

I have not managed to get it working again since!

....This seams rather strange to me!

Any Ideas?

Thank you,
Gary
Re: remove code that restricts contained nodes from been drawn [message #207090 is a reply to message #207076] Thu, 25 September 2008 14:24 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

> Any Ideas?
Well, there is an error in diagram definition, i suppose.. Can you try to
re-define this diagram from scratch, make it working and then step-by-step
adding more and more features on it?
BTW, I suggest you using version controll to track changes/store working
versions of model/code..

-----------------
Alex Shatalin
Previous Topic:Border Item Rectilinear router with nested EditParts
Next Topic:Re: DND from TreeViewer to GMF generated editor
Goto Forum:
  


Current Time: Fri Mar 29 14:45:16 GMT 2024

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

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

Back to the top