Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How can I get the Diagram from Diagram file without opening it?
How can I get the Diagram from Diagram file without opening it? [message #42140] Thu, 07 September 2006 12:17 Go to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

I get the Diagram from digramfile, and then I use copyToImageUtil to create
a diagramEditPart based on the diagram. List codes below:

final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(600,800);
shell.setText("testcopytoutil");
IPath resourcePath = diagramFile.getFullPath();
ResourceSet resourceSet = myEditingDomain.getResourceSet();
try {
Resource modelResource = resourceSet.getResource(
URI.createPlatformResourceURI(resourcePath
.toString()), true);
if(modelResource instanceof XMIResourceImpl){
Object[] objs = getElements(modelResource);
CopyToImageUtil copyToImageUtil = new CopyToImageUtil();
diagramEditPart = copyToImageUtil.createDiagramEditPart((Diagram)
objs[0],new Shell(),ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT) ;
}
} catch (WrappedException e) {
ProcessDiagramEditorPlugin
.getInstance()
.logError(
"Unable to load resource: " + resourcePath.toString(), e);
//$NON-NLS-1$
}
shell.layout();
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch())
display.sleep();

The code works well without reporting error, but I can not see anything from
the shell shows up....So I suspect if I did right?
By the way, I use the diagramEditPart which is returned by
copyToImageUtil.createDiagramEditPart method to get the commands to create
view on it, then how to save the Diagram? I know if it is an editor, I can
use editor.doSave(), but it is Ddiagram, how to save it back to its
diagramfile.
Re: How can I get the Diagram from Diagram file without opening it? [message #42626 is a reply to message #42140] Fri, 08 September 2006 05:46 Go to previous messageGo to next message
Eclipse UserFriend
Hello dzh,

> use editor.doSave(), but it is Ddiagram, how to save it back to its
> diagramfile.
call resource.save(Collections.EMPTY_MAP); for the diagram file resource.

-----------------
Alex Shatalin
Re: How can I get the Diagram from Diagram file without opening it? [message #43354 is a reply to message #42626] Sat, 09 September 2006 02:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Thank you for your quick answer:)
The code works well without reporting error, but I can not see anything from
the shell shows up....So I suspect if I did right?
If there any example of using copyToImageUtil ? If rightly created, the
diagram should show up in the shell?

I use the diagramEditPart which is returned by
copyToImageUtil.createDiagramEditPart method to get the commands to create
view on it, and I use resource.save(Collections.EMPTY_MAP) to save, but
after reopen the diagram file, I found nothing changed.

Best reagrds,
dzh

"Alex Shatalin" <vano@borland.com> д
Re: How can I get the Diagram from Diagram file without opening it? [message #45338 is a reply to message #43354] Mon, 11 September 2006 15:08 Go to previous message
Eclipse UserFriend
Originally posted by: cmahoney.ca.ibm.com

Hello,

No, you shouldn't see the diagram in the shell. This method allows you
to create a DiagramEditPart without creating an editor. You could then
use the DiagramEditPart for whatever reason you needed it. For example,
GMF uses this mechanism to create an image from a diagram (see
CopyToImageUtil.copyToImage()).

Regards,
Cherie

dzh wrote:
> Thank you for your quick answer:)
> The code works well without reporting error, but I can not see anything from
> the shell shows up....So I suspect if I did right?
> If there any example of using copyToImageUtil ? If rightly created, the
> diagram should show up in the shell?
>
> I use the diagramEditPart which is returned by
> copyToImageUtil.createDiagramEditPart method to get the commands to create
> view on it, and I use resource.save(Collections.EMPTY_MAP) to save, but
> after reopen the diagram file, I found nothing changed.
>
> Best reagrds,
> dzh
>
> "Alex Shatalin" <vano@borland.com> дÈëÏûÏ¢ÐÂÎÅ:cd695fb3116688c8a1538267a876@news.eclipse.org...
>> Hello dzh,
>>
>>> use editor.doSave(), but it is Ddiagram, how to save it back to its
>>> diagramfile.
>> call resource.save(Collections.EMPTY_MAP); for the diagram file resource.
>>
>> -----------------
>> Alex Shatalin
>>
>>
>
>
Previous Topic:Right-justified layout
Next Topic:EditPolicyProvider question
Goto Forum:
  


Current Time: Wed May 14 10:14:44 EDT 2025

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

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

Back to the top