Home » Modeling » GMF (Graphical Modeling Framework) » Programmatically generating diagram from model
Programmatically generating diagram from model [message #144522] |
Fri, 27 July 2007 08:08  |
Eclipse User |
|
|
|
Originally posted by: exquisitus.web.de
Hey Guys,
I'm searching for a way to generate the diagram code from an existing =
model-xml.
This is possible, with the user interaction "Initialize ??? diagram file=
" =
in eclipse. But I want to do this programmatically.
Help would be appreciate. Thnx.
Enjoy your weekend :).
|
|
| | | | | | |
Re: Programmatically generating diagram from model [message #147335 is a reply to message #147298] |
Tue, 21 August 2007 13:13   |
Eclipse User |
|
|
|
Hi André,
First, you should create a diagram itself using
ViewService.createDiagram(...). For synchronized diagrams, you don't
need anything else (the diagram structure will be created for you once
you open the diagram). For non-synchronized diagrams, you should
additionally invoke XYZDiagramContentInitializer.initDiagramContent(...)
to actually create the structure underneath the diagram.
You can find the details in template NewDiagramFileWizard.xpt.
Hope that helps.
Best regards,
Boris
André Sousa wrote:
> Hi,
>
> I want to do exactly the same thing, generating a diagram from a model
> without using "Initialize ??? diagram file".
> I've read the answers, and I took a look at the run() method and tried to
> adapt it, but I was unsuccessful in my attempt.
> Can someone send me some guidelines (or maybe your source code) as how to do
> this without a GUI.
>
> thanks.
>
> "Miriam Grundig" <exquisitus@web.de> wrote in message
> news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com...
> Hey Guys,
> I'm searching for a way to generate the diagram code from an existing
> model-xml.
> This is possible, with the user interaction "Initialize ??? diagram file"
> in eclipse. But I want to do this programmatically.
> Help would be appreciate. Thnx.
>
> Enjoy your weekend :).
>
>
|
|
|
Programmatically generating diagram from model (the source code) [message #156818 is a reply to message #144522] |
Tue, 23 October 2007 11:38  |
Eclipse User |
|
|
|
Originally posted by: sousandre.gmail.com
This is a multi-part message in MIME format.
------=_NextPart_000_001A_01C81593.28F6FC30
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable
Hi guys,
After a great strugle against GMF, I finally found out how to create my =
diagrams automatically.
Thanks to everyone for all your help.
Your tips helped me a lot.
Anyways, I have created a function to do the generation of diagrams from =
any domain model file, and I want to share it with everyone.
There might be someone out there with looking for the same solution I =
was, and this might be helpfull.
So here goes:
public void generateDiagram(String domainModelFileName) {
String diagramModelFileName =3D domainModelFileName + "_diagram";
EObject domainRoot =3D null;
try {
//load the domain model resource
ResourceSet domainResourceSet =3D new ResourceSetImpl();
=
domainResourceSet.getResourceFactoryRegistry().getExtensionT oFactoryMap()=
..put(Resource.Factory.Registry.DEFAULT_EXTENSION, new =
XMIResourceFactoryImpl());
URI domainFileURI =3D URI.createFileURI(new =
File(domainModelFileName).getAbsolutePath());
Resource domainResource =3D =
domainResourceSet.getResource(domainFileURI, true);
//create the diagram model resource
ResourceSet diagramResourceSet =3D new ResourceSetImpl();
=
diagramResourceSet.getResourceFactoryRegistry().getExtension ToFactoryMap(=
).put(Resource.Factory.Registry.DEFAULT_EXTENSION, new =
XMIResourceFactoryImpl());
URI diagramFileURI =3D URI.createFileURI(new =
File(diagramModelFileName).getAbsolutePath());
Resource diagramResource =3D =
diagramResourceSet.createResource(diagramFileURI);
//create the diagram and save it to the file
domainRoot =3D (EObject) domainResource.getContents().get(0);
Diagram diagram =3D =
ViewService.createDiagram(domainRoot,fct.ample.annotatedUC.a nnotateduc.di=
agram.edit.parts.AnnotatedUCModelEditPart.MODEL_ID,fct.ample .annotatedUC.=
annotateduc.diagram.part.AnnotatedUCDiagramEditorPlugin.DIAG RAM_PREFERENC=
ES_HINT);
diagramResource.getContents().add(diagram);
=
diagramResource.save(fct.ample.annotatedUC.annotateduc.diagr am.part.Annot=
atedUCDiagramEditorUtil.getSaveOptions());
}
catch (Exception e) {
e.printStackTrace();
}
if (domainRoot =3D=3D null) {
=
MessageDialog.openError(getShell(),fct.ample.annotatedUC.ann otateduc.diag=
ram.part.Messages.AnnotatedUCInitDiagramFileAction_InitDiagr amFileResourc=
eErrorDialogTitle,fct.ample.annotatedUC.annotateduc.diagram. part.Messages=
..AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceEr rorDialogMessa=
ge);
return;
}
}
Regards
Andr=E9 Sousa
"Miriam Grundig" <exquisitus@web.de> wrote in message =
news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com...
Hey Guys,
I'm searching for a way to generate the diagram code from an existing =20
model-xml.
This is possible, with the user interaction "Initialize ??? diagram =
file" =20
in eclipse. But I want to do this programmatically.
Help would be appreciate. Thnx.
Enjoy your weekend :).
------=_NextPart_000_001A_01C81593.28F6FC30
Content-Type: text/html;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi guys,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>After a great strugle against GMF, I =
finally found=20
out how to create my diagrams automatically.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks to everyone for all your =
help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Your tips helped me a lot.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Anyways, I have created a function to =
do the=20
generation of diagrams from any domain model file, and I want to share =
it with=20
everyone.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>There might be someone out there with =
looking for=20
the same solution I was, and this might be helpfull.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>So here goes:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2><STRONG><FONT=20
color=3D#800080>public void</FONT></STRONG> generateDiagram(String=20
domainModelFileName) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
String=20
diagramModelFileName =3D domainModelFileName + <FONT=20
color=3D#0000ff>"_diagram"</FONT>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
EObject=20
domainRoot =3D <STRONG><FONT =
color=3D#800080>null</FONT></STRONG>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>try</FONT></STRONG> {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//load the domain model=20
resource</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
ResourceSet domainResourceSet =3D <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> ResourceSetImpl();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
domainResourceSet.getResourceFactoryRegistry().getExtensionT oFactoryMap()=
..put(Resource.Factory.Registry.<EM><FONT=20
color=3D#0000ff>DEFAULT_EXTENSION</FONT></EM>, <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> =
XMIResourceFactoryImpl());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
URI domainFileURI =3D URI.createFileURI(<STRONG><FONT =
color=3D#800080>new</FONT></STRONG>=20
File(domainModelFileName).getAbsolutePath());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Resource domainResource =3D=20
domainResourceSet.getResource(domainFileURI, <STRONG><FONT=20
color=3D#800080>true</FONT></STRONG>);</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT face=3D"Courier New"=20
size=3D2></FONT></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//create the diagram model=20
resource</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
ResourceSet diagramResourceSet =3D <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> ResourceSetImpl();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
diagramResourceSet.getResourceFactoryRegistry().getExtension ToFactoryMap(=
).put(Resource.Factory.Registry.<FONT=20
color=3D#0000ff><EM>DEFAULT_EXTENSION</EM></FONT>, <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> =
XMIResourceFactoryImpl());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
URI diagramFileURI =3D =
URI.createFileURI(<STRONG><FONT=20
color=3D#800080>new</FONT></STRONG>=20
File(diagramModelFileName).getAbsolutePath());</FONT></DIV >
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Resource diagramResource =3D=20
diagramResourceSet.createResource(diagramFileURI);</FONT></DIV >
<DIV align=3Dleft><FONT size=3D2><FONT face=3D"Courier New"=20
size=3D2></FONT></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//create the diagram and save =
it to the=20
file</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
domainRoot =3D (EObject)=20
domainResource.getContents().get(0);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Diagram diagram =3D=20
ViewService.createDiagram(domainRoot,fct.ample.annotatedUC.a nnotateduc.di=
agram.edit.parts.AnnotatedUCModelEditPart.<EM><FONT=20
color=3D#0000ff>MODEL_ID</FONT></EM>,fct.ample.annotatedUC.annotateduc.di=
agram.part.AnnotatedUCDiagramEditorPlugin.<EM><FONT=20
color=3D#0000ff>DIAGRAM_PREFERENCES_HINT</FONT></EM>);</FONT ></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=
diagramResource.getContents().add(diagram);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
diagramResource.save(fct.ample.annotatedUC.annotateduc.diagr am.part.Annot=
atedUCDiagramEditorUtil.getSaveOptions());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" =
size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>catch</FONT></STRONG> (Exception e) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
e.printStackTrace();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" =
size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>if</FONT></STRONG> (domainRoot =3D=3D <STRONG><FONT=20
color=3D#800080>null</FONT></STRONG>) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
MessageDialog.openError(getShell(),fct.ample.annotatedUC.ann otateduc.diag=
ram.part.Messages.<EM><FONT=20
color=3D#0000ff>AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceE=
rrorDialogTitle</FONT></EM>,fct.ample.annotatedUC.annotateduc.diagram.par=
t.Messages.<EM><FONT=20
color=3D#0000ff>AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceE=
rrorDialogMessage</FONT></EM>);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>return</FONT></STRONG>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Andr=E9 Sousa</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Miriam Grundig" <</FONT><A=20
href=3D"mailto:exquisitus@web.de"><FONT face=3DArial=20
size=3D2>exquisitus@web.de</FONT></A><FONT face=3DArial size=3D2>> =
wrote in message=20
</FONT><A =
href=3D"news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com"><FONT=20
face=3DArial=20
size=3D2>news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com</FONT></A><F=
ONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>Hey =
Guys,<BR>I'm=20
searching for a way to generate the diagram code from an existing =20
<BR>model-xml.<BR>This is possible, with the user interaction =
"Initialize ???=20
diagram file" <BR>in eclipse. But I want to do this=20
programmatically.<BR>Help would be appreciate. Thnx.<BR><BR>Enjoy your =
weekend=20
:).</FONT></BODY></HTML>
------=_NextPart_000_001A_01C81593.28F6FC30--
|
|
|
Programmatically generating diagram from model (the source code) [message #156829 is a reply to message #144522] |
Tue, 23 October 2007 11:38  |
Eclipse User |
|
|
|
Originally posted by: sousandre.gmail.com
This is a multi-part message in MIME format.
------=_NextPart_000_001A_01C81593.28F6FC30
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable
Hi guys,
After a great strugle against GMF, I finally found out how to create my =
diagrams automatically.
Thanks to everyone for all your help.
Your tips helped me a lot.
Anyways, I have created a function to do the generation of diagrams from =
any domain model file, and I want to share it with everyone.
There might be someone out there with looking for the same solution I =
was, and this might be helpfull.
So here goes:
public void generateDiagram(String domainModelFileName) {
String diagramModelFileName =3D domainModelFileName + "_diagram";
EObject domainRoot =3D null;
try {
//load the domain model resource
ResourceSet domainResourceSet =3D new ResourceSetImpl();
=
domainResourceSet.getResourceFactoryRegistry().getExtensionT oFactoryMap()=
..put(Resource.Factory.Registry.DEFAULT_EXTENSION, new =
XMIResourceFactoryImpl());
URI domainFileURI =3D URI.createFileURI(new =
File(domainModelFileName).getAbsolutePath());
Resource domainResource =3D =
domainResourceSet.getResource(domainFileURI, true);
//create the diagram model resource
ResourceSet diagramResourceSet =3D new ResourceSetImpl();
=
diagramResourceSet.getResourceFactoryRegistry().getExtension ToFactoryMap(=
).put(Resource.Factory.Registry.DEFAULT_EXTENSION, new =
XMIResourceFactoryImpl());
URI diagramFileURI =3D URI.createFileURI(new =
File(diagramModelFileName).getAbsolutePath());
Resource diagramResource =3D =
diagramResourceSet.createResource(diagramFileURI);
//create the diagram and save it to the file
domainRoot =3D (EObject) domainResource.getContents().get(0);
Diagram diagram =3D =
ViewService.createDiagram(domainRoot,fct.ample.annotatedUC.a nnotateduc.di=
agram.edit.parts.AnnotatedUCModelEditPart.MODEL_ID,fct.ample .annotatedUC.=
annotateduc.diagram.part.AnnotatedUCDiagramEditorPlugin.DIAG RAM_PREFERENC=
ES_HINT);
diagramResource.getContents().add(diagram);
=
diagramResource.save(fct.ample.annotatedUC.annotateduc.diagr am.part.Annot=
atedUCDiagramEditorUtil.getSaveOptions());
}
catch (Exception e) {
e.printStackTrace();
}
if (domainRoot =3D=3D null) {
=
MessageDialog.openError(getShell(),fct.ample.annotatedUC.ann otateduc.diag=
ram.part.Messages.AnnotatedUCInitDiagramFileAction_InitDiagr amFileResourc=
eErrorDialogTitle,fct.ample.annotatedUC.annotateduc.diagram. part.Messages=
..AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceEr rorDialogMessa=
ge);
return;
}
}
Regards
Andr=E9 Sousa
"Miriam Grundig" <exquisitus@web.de> wrote in message =
news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com...
Hey Guys,
I'm searching for a way to generate the diagram code from an existing =20
model-xml.
This is possible, with the user interaction "Initialize ??? diagram =
file" =20
in eclipse. But I want to do this programmatically.
Help would be appreciate. Thnx.
Enjoy your weekend :).
------=_NextPart_000_001A_01C81593.28F6FC30
Content-Type: text/html;
charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi guys,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>After a great strugle against GMF, I =
finally found=20
out how to create my diagrams automatically.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks to everyone for all your =
help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Your tips helped me a lot.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Anyways, I have created a function to =
do the=20
generation of diagrams from any domain model file, and I want to share =
it with=20
everyone.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>There might be someone out there with =
looking for=20
the same solution I was, and this might be helpfull.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>So here goes:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2><STRONG><FONT=20
color=3D#800080>public void</FONT></STRONG> generateDiagram(String=20
domainModelFileName) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
String=20
diagramModelFileName =3D domainModelFileName + <FONT=20
color=3D#0000ff>"_diagram"</FONT>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
EObject=20
domainRoot =3D <STRONG><FONT =
color=3D#800080>null</FONT></STRONG>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>try</FONT></STRONG> {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//load the domain model=20
resource</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
ResourceSet domainResourceSet =3D <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> ResourceSetImpl();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
domainResourceSet.getResourceFactoryRegistry().getExtensionT oFactoryMap()=
..put(Resource.Factory.Registry.<EM><FONT=20
color=3D#0000ff>DEFAULT_EXTENSION</FONT></EM>, <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> =
XMIResourceFactoryImpl());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
URI domainFileURI =3D URI.createFileURI(<STRONG><FONT =
color=3D#800080>new</FONT></STRONG>=20
File(domainModelFileName).getAbsolutePath());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Resource domainResource =3D=20
domainResourceSet.getResource(domainFileURI, <STRONG><FONT=20
color=3D#800080>true</FONT></STRONG>);</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT face=3D"Courier New"=20
size=3D2></FONT></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//create the diagram model=20
resource</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
ResourceSet diagramResourceSet =3D <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> ResourceSetImpl();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
diagramResourceSet.getResourceFactoryRegistry().getExtension ToFactoryMap(=
).put(Resource.Factory.Registry.<FONT=20
color=3D#0000ff><EM>DEFAULT_EXTENSION</EM></FONT>, <STRONG><FONT=20
color=3D#800080>new</FONT></STRONG> =
XMIResourceFactoryImpl());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
URI diagramFileURI =3D =
URI.createFileURI(<STRONG><FONT=20
color=3D#800080>new</FONT></STRONG>=20
File(diagramModelFileName).getAbsolutePath());</FONT></DIV >
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Resource diagramResource =3D=20
diagramResourceSet.createResource(diagramFileURI);</FONT></DIV >
<DIV align=3Dleft><FONT size=3D2><FONT face=3D"Courier New"=20
size=3D2></FONT></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<FONT color=3D#008080>//create the diagram and save =
it to the=20
file</FONT></FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
domainRoot =3D (EObject)=20
domainResource.getContents().get(0);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
Diagram diagram =3D=20
ViewService.createDiagram(domainRoot,fct.ample.annotatedUC.a nnotateduc.di=
agram.edit.parts.AnnotatedUCModelEditPart.<EM><FONT=20
color=3D#0000ff>MODEL_ID</FONT></EM>,fct.ample.annotatedUC.annotateduc.di=
agram.part.AnnotatedUCDiagramEditorPlugin.<EM><FONT=20
color=3D#0000ff>DIAGRAM_PREFERENCES_HINT</FONT></EM>);</FONT ></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=
diagramResource.getContents().add(diagram);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
diagramResource.save(fct.ample.annotatedUC.annotateduc.diagr am.part.Annot=
atedUCDiagramEditorUtil.getSaveOptions());</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" =
size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>catch</FONT></STRONG> (Exception e) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
e.printStackTrace();</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" =
size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>if</FONT></STRONG> (domainRoot =3D=3D <STRONG><FONT=20
color=3D#800080>null</FONT></STRONG>) {</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
=20
MessageDialog.openError(getShell(),fct.ample.annotatedUC.ann otateduc.diag=
ram.part.Messages.<EM><FONT=20
color=3D#0000ff>AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceE=
rrorDialogTitle</FONT></EM>,fct.ample.annotatedUC.annotateduc.diagram.par=
t.Messages.<EM><FONT=20
color=3D#0000ff>AnnotatedUCInitDiagramFileAction_InitDiagramFileResourceE=
rrorDialogMessage</FONT></EM>);</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
<STRONG><FONT=20
color=3D#800080>return</FONT></STRONG>;</FONT></DIV>
<DIV align=3Dleft><FONT face=3D"Courier New" size=3D2> =
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Andr=E9 Sousa</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Miriam Grundig" <</FONT><A=20
href=3D"mailto:exquisitus@web.de"><FONT face=3DArial=20
size=3D2>exquisitus@web.de</FONT></A><FONT face=3DArial size=3D2>> =
wrote in message=20
</FONT><A =
href=3D"news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com"><FONT=20
face=3DArial=20
size=3D2>news:op.tv4hb2biw6zt2o@elster.boeblingen.de.ibm.com</FONT></A><F=
ONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>Hey =
Guys,<BR>I'm=20
searching for a way to generate the diagram code from an existing =20
<BR>model-xml.<BR>This is possible, with the user interaction =
"Initialize ???=20
diagram file" <BR>in eclipse. But I want to do this=20
programmatically.<BR>Help would be appreciate. Thnx.<BR><BR>Enjoy your =
weekend=20
:).</FONT></BODY></HTML>
------=_NextPart_000_001A_01C81593.28F6FC30--
|
|
|
Goto Forum:
Current Time: Sat Aug 30 01:56:03 EDT 2025
Powered by FUDForum. Page generated in 0.05501 seconds
|