Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Initializing the diagram file
Initializing the diagram file [message #186236] Mon, 12 May 2008 06:21 Go to next message
Eclipse UserFriend
Originally posted by: zzhangh.cn.ibm.com

Hi,
When initialized a diagram file from model file, the generated
".xxx_diagram" only contains the root diagram itself like following:
<xml>
<diagram>
</diagram>

Is there a way to generate a complete diagram file having all diagram
elements in it, as following:
<xml>
<diagram>
<node1/>
<node2/>
</diagram>

Regards,
Hao
Re: Initializing the diagram file [message #186305 is a reply to message #186236] Mon, 12 May 2008 11:14 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Hao,

Modify ???DiagramEditorUtil.createDiagram() method.

-----------------
Alex Shatalin
Re: Initializing the diagram file [message #186313 is a reply to message #186305] Mon, 12 May 2008 11:17 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Alex,

Sorry.. If you are talking about diagram content initialization using existing
model file then you should call Diagram.persistChildren() before saving the
diagram from the editor to get all the elements saved.
BTW, it's not necessary beause those elements wich was not modified by user
will be automatically recreated on next DiagramEditor openning/

-----------------
Alex Shatalin
Re: Initializing the diagram file [message #186562 is a reply to message #186313] Tue, 13 May 2008 09:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zzhangh.cn.ibm.com

Hi Alex,
Thanks for letting me know this method. The reason why I asked this
question is that in my application which uses GMF diagram partitioning,
when I initialized a diagram and opened it, if it contains a sub-diagram
and I double-clicked to open the sub-diagram and save it, the
"HintedDiagramLinkStyle" style of the sub-diagram node (actually the
node it self) is not persisted, so the next time I open the same
sub-diagram, a new diagram is generated in the notation model and it is
an unexpected duplicated diagram.

I think it is a bug because my diagram is very simple and I can easily
reproduce this issue (I'm using GMF2.1.0M6a, also tried on previous GMF
versions). I tried the method you provided in XXXInitDiagramFileAction
and XXXNewDiagramFileWizard, unfortunately till now I can't get the
sub-diagram node persisted, I'm going to invest more time on that.

It would be great if you can point out where I should modify on
generated codes or some glues on that.

Regards,
Hao

Alex Shatalin 写道:
> Hello Alex,
>
> Sorry.. If you are talking about diagram content initialization using
> existing model file then you should call Diagram.persistChildren()
> before saving the diagram from the editor to get all the elements saved.
> BTW, it's not necessary beause those elements wich was not modified by
> user will be automatically recreated on next DiagramEditor openning/
>
> -----------------
> Alex Shatalin
>
>
Re: Initializing the diagram file [message #186593 is a reply to message #186562] Tue, 13 May 2008 10:50 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Hao,

> I think it is a bug because my diagram is very simple and I can easily
Looks like.. Let's continue trying to solve this problem by modifying the
generated code and then submit a request describing existing solution for it.

> XXXInitDiagramFileAction and XXXNewDiagramFileWizard, unfortunately
> till now I can't get the sub-diagram node persisted, I'm going to
> invest more time on that.
Actually, taking into account your use case you have to modify generated
OpenDiagramEditPolicy.OpenDiagramCommand.intializeNewDiagram () method. I
suggest you to put following code in the very beggining of this method:

EObject container = diagramFacet.eContainer();
while (container instanceof View) {
((View) container).persist();
container = container.eContainer();
}

Now node associated with the diagram you are going to open will be persisted
together with whole containers.

-----------------
Alex Shatalin
Re: Initializing the diagram file [message #187073 is a reply to message #186593] Thu, 15 May 2008 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zzhangh.cn.ibm.com

Hi Alex,
Your codes worked, till now I havn't found the issue any more. It is
great, thanks!
I submitted an bug entry for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232229

BTW, several months ago I had another bug entry about diagram
partitioning (which is also an issue in the project we're developing),
do you happen to have any thouhgts on it?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=214569

Regards,
Hao

Alex Shatalin 写道:
> Hello Hao,
>
>> I think it is a bug because my diagram is very simple and I can easily
> Looks like.. Let's continue trying to solve this problem by modifying
> the generated code and then submit a request describing existing
> solution for it.
>
>> XXXInitDiagramFileAction and XXXNewDiagramFileWizard, unfortunately
>> till now I can't get the sub-diagram node persisted, I'm going to
>> invest more time on that.
> Actually, taking into account your use case you have to modify generated
> OpenDiagramEditPolicy.OpenDiagramCommand.intializeNewDiagram () method. I
> suggest you to put following code in the very beggining of this method:
>
> EObject container = diagramFacet.eContainer();
> while (container instanceof View) {
> ((View) container).persist();
> container = container.eContainer();
> }
>
> Now node associated with the diagram you are going to open will be
> persisted together with whole containers.
>
> -----------------
> Alex Shatalin
>
>
Re: Initializing the diagram file [message #187187 is a reply to message #187073] Thu, 15 May 2008 10:01 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Hao,

> BTW, several months ago I had another bug entry about diagram
> partitioning (which is also an issue in the project we're developing),
> do you happen to have any thouhgts on it?
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=214569
Well, the solution for this problem is not so clear, but I have one in mind.
:-)
In your project you can try modifying ???ItemSemanticEditPolicy.getDestroyElementCommand()
for the "partitioned" element (EPackage in case of Ecore diagram). In addition
to all the current commands returned from this method now you can try add
one more command doing:

DiagramLinkStyle linkStyle = (DiagramLinkStyle) view.getStyle(NotationPackage.eINSTANCE.getDiagramLinkStyle( ));
if (linkStyle.getDiagramLink() != null) {
Diagram diagram = linkStyle.getDiagramLink();
if (diagram.eContainer() == null) {
diagram.eResource().getContents().remove(diagram);
}
}

I'll try to fix both problems in near future.
-----------------
Alex Shatalin
Previous Topic:RCP unexpected type
Next Topic:ViewService diagram creation issue
Goto Forum:
  


Current Time: Tue Apr 16 19:38:53 GMT 2024

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

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

Back to the top