Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding an Edge to a GMF Diagram
Adding an Edge to a GMF Diagram [message #127297] Fri, 18 May 2007 04:16 Go to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Hello,

I am trying to add an Edge object to a GMF Diagram. I'm reading the edges
from another diagram and want to add them to the new one:

diagram.getEdges.add(edgeObj);

The problem is that I always get a java.lang.UnsupportedOperationException.
Does anyone have ideea why? And how can this be solved?

Thanks,




Floppy
Re: Adding an Edge to a GMF Diagram [message #127385 is a reply to message #127297] Fri, 18 May 2007 14:33 Go to previous messageGo to next message
Eclipse UserFriend
The edges list a derived read only list

use getPersistedEdges instead of get edges


Florin Banica wrote:

> Hello,
>
> I am trying to add an Edge object to a GMF Diagram. I'm reading the edges
> from another diagram and want to add them to the new one:
>
> diagram.getEdges.add(edgeObj);
>
> The problem is that I always get a java.lang.UnsupportedOperationException.
> Does anyone have ideea why? And how can this be solved?
>
> Thanks,
>
>
>
>
> Floppy
>
>
Re: Adding an Edge to a GMF Diagram [message #127644 is a reply to message #127385] Mon, 21 May 2007 04:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Thanks for the answer! That's good, it's working, but i had encountered
another problem... Even if I "put" the edges I want, the diagram still has
its edges, calculated when it paints the diagram/makes refresh. In the file
I can see both my edges and its edges.

So the question is now, how can I do to "interfere" when/where it calculates
its edges and makes refresh?


Than again, maybe it's better to explain the whole problem (what I want to
achieve) in order to make you understand better. Maybe there is a simpler
solution...

So, I have an editor which works fine and does its job (produces graphical
models). Then, I have another editor where I want to "import" both the model
and the graphics (diagram) from a graphical model produced by the first
editor.

So far, I have managed to import the model, but I have problems importing
the diagram (graphics). I'm trying to read the first diagram, get the edges
list and create new edges and add them into the edges list of the new
diagram. The problem is that I'm adding them but then, the diagram gets
painted and "calculates" its own edges. I think I need to insert my edges
into the diagram, after it gets painted. Any idea how to do that?

Thanks for your help,




Floppy


"Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
news:f2krp6$nn5$1@build.eclipse.org...
> The edges list a derived read only list
>
> use getPersistedEdges instead of get edges
>
>
> Florin Banica wrote:
>
>> Hello,
>>
>> I am trying to add an Edge object to a GMF Diagram. I'm reading the edges
>> from another diagram and want to add them to the new one:
>>
>> diagram.getEdges.add(edgeObj);
>>
>> The problem is that I always get a
>> java.lang.UnsupportedOperationException. Does anyone have ideea why? And
>> how can this be solved?
>>
>> Thanks,
>>
>>
>>
>>
>> Floppy
>>
Re: Adding an Edge to a GMF Diagram [message #127656 is a reply to message #127644] Mon, 21 May 2007 05:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

I would also say that I made a command (AbstractTransactionalCommand) and an
action (IObjectActionDelegate) in order to import the model and the diagram.
The action is in a pop-up menu and calls and executes the command.

So, it will help to know where to put my hands, just after the command gets
executed...



"Florin Banica" <fbanica@soluta.net> wrote in message
news:f2rmq7$9a6$1@build.eclipse.org...
> Thanks for the answer! That's good, it's working, but i had encountered
> another problem... Even if I "put" the edges I want, the diagram still has
> its edges, calculated when it paints the diagram/makes refresh. In the
> file I can see both my edges and its edges.
>
> So the question is now, how can I do to "interfere" when/where it
> calculates its edges and makes refresh?
>
>
> Than again, maybe it's better to explain the whole problem (what I want to
> achieve) in order to make you understand better. Maybe there is a simpler
> solution...
>
> So, I have an editor which works fine and does its job (produces graphical
> models). Then, I have another editor where I want to "import" both the
> model and the graphics (diagram) from a graphical model produced by the
> first editor.
>
> So far, I have managed to import the model, but I have problems importing
> the diagram (graphics). I'm trying to read the first diagram, get the
> edges list and create new edges and add them into the edges list of the
> new diagram. The problem is that I'm adding them but then, the diagram
> gets painted and "calculates" its own edges. I think I need to insert my
> edges into the diagram, after it gets painted. Any idea how to do that?
>
> Thanks for your help,
>
>
>
>
> Floppy
>
>
> "Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
> news:f2krp6$nn5$1@build.eclipse.org...
>> The edges list a derived read only list
>>
>> use getPersistedEdges instead of get edges
>>
>>
>> Florin Banica wrote:
>>
>>> Hello,
>>>
>>> I am trying to add an Edge object to a GMF Diagram. I'm reading the
>>> edges from another diagram and want to add them to the new one:
>>>
>>> diagram.getEdges.add(edgeObj);
>>>
>>> The problem is that I always get a
>>> java.lang.UnsupportedOperationException. Does anyone have ideea why? And
>>> how can this be solved?
>>>
>>> Thanks,
>>>
>>>
>>>
>>>
>>> Floppy
>>>
>
Re: Adding an Edge to a GMF Diagram [message #127668 is a reply to message #127644] Mon, 21 May 2007 05:36 Go to previous messageGo to next message
Eclipse UserFriend
Hello FLORIN,

> edges list of the new diagram. The problem is that I'm adding them but
> then, the diagram gets painted and "calculates" its own edges. I think
Looks like second diagram wass generated with property "synchronized == true"
for GenDiagram. If you want to add all the diagram elements to the second
diagram manually then it probably make sense to generate non-synchronized
diagram.

Concerning the place, all the edges should be added to the diagram from the
???CanonicalEditPolicy generated for diagram. So, you can put your logic
there.

-----------------
Alex Shatalin
Re: Adding an Edge to a GMF Diagram [message #127932 is a reply to message #127656] Mon, 21 May 2007 14:00 Go to previous message
Eclipse UserFriend
Hello Florin ;

We need to look closer at the problem to understand what is going on.

When you copy the edges, do you update them to point to elements in the
new imported model. If you do not then the canonical edit policy will be
confused and it will not be able to correctly recognize the edge and it
will try to create a new one.

i do not think you should change the Synchronized flag on your diagram
before understanding why the problem happens. Because the edges on your
diagram might be pointing to the wrong elements


The easiest way to debug that is to start in the
CnaonicalConnectionEditPolicy#refreshSemanticConnections, add a
breakpoint there and check the viewChildren and semanticChildren you get
The viewchildren should contain the edges you have created, then step
into cleanCanonicalSemanticChildren and see why it does not remove all
the semantic elements, this will give you a better understanding for
what is going on. I think if you just removed the Synchronized flag you
will be just hiding the problem not fixing it


One more thing, when you copy the edges you do not need to copy
transient edges since the canonical edit policy should take care of
creating them for you

in other words, te edges you copy should be the ones coming from
getPersistedEdges not getEdges



Florin Banica wrote:
> I would also say that I made a command (AbstractTransactionalCommand) and an
> action (IObjectActionDelegate) in order to import the model and the diagram.
> The action is in a pop-up menu and calls and executes the command.
>
> So, it will help to know where to put my hands, just after the command gets
> executed...
>
>
>
> "Florin Banica" <fbanica@soluta.net> wrote in message
> news:f2rmq7$9a6$1@build.eclipse.org...
>> Thanks for the answer! That's good, it's working, but i had encountered
>> another problem... Even if I "put" the edges I want, the diagram still has
>> its edges, calculated when it paints the diagram/makes refresh. In the
>> file I can see both my edges and its edges.
>>
>> So the question is now, how can I do to "interfere" when/where it
>> calculates its edges and makes refresh?
>>
>>
>> Than again, maybe it's better to explain the whole problem (what I want to
>> achieve) in order to make you understand better. Maybe there is a simpler
>> solution...
>>
>> So, I have an editor which works fine and does its job (produces graphical
>> models). Then, I have another editor where I want to "import" both the
>> model and the graphics (diagram) from a graphical model produced by the
>> first editor.
>>
>> So far, I have managed to import the model, but I have problems importing
>> the diagram (graphics). I'm trying to read the first diagram, get the
>> edges list and create new edges and add them into the edges list of the
>> new diagram. The problem is that I'm adding them but then, the diagram
>> gets painted and "calculates" its own edges. I think I need to insert my
>> edges into the diagram, after it gets painted. Any idea how to do that?
>>
>> Thanks for your help,
>>
>>
>>
>>
>> Floppy
>>
>>
>> "Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
>> news:f2krp6$nn5$1@build.eclipse.org...
>>> The edges list a derived read only list
>>>
>>> use getPersistedEdges instead of get edges
>>>
>>>
>>> Florin Banica wrote:
>>>
>>>> Hello,
>>>>
>>>> I am trying to add an Edge object to a GMF Diagram. I'm reading the
>>>> edges from another diagram and want to add them to the new one:
>>>>
>>>> diagram.getEdges.add(edgeObj);
>>>>
>>>> The problem is that I always get a
>>>> java.lang.UnsupportedOperationException. Does anyone have ideea why? And
>>>> how can this be solved?
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>>
>>>> Floppy
>>>>
>
>
Previous Topic:targetMetaFeature Error
Next Topic:M7
Goto Forum:
  


Current Time: Thu Jul 17 09:16:19 EDT 2025

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

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

Back to the top