Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Printing GMF diagram
Printing GMF diagram [message #197982] Sun, 20 July 2008 06:21 Go to next message
Eclipse UserFriend
Originally posted by: mike.gmail.com

Hello,

I am trying to create a custom print mechanism that prints a GMF diagram
with out showing the dialog box that usually comes up in GMF print.

Does anyone have tried this before? Is there a custom command that will
print a gmf diagram with out showing the dialog box?

Hope to hear from someone.

Thanks in advance

Mike
Re: Printing GMF diagram [message #198199 is a reply to message #197982] Tue, 22 July 2008 04:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Mike wrote:
> Hello,
>
> I am trying to create a custom print mechanism that prints a GMF diagram
> with out showing the dialog box that usually comes up in GMF print.
> Does anyone have tried this before? Is there a custom command that will
> print a gmf diagram with out showing the dialog box?
>
> Hope to hear from someone.
>
> Thanks in advance
>
> Mike
>
It's easy, prepare a PrintData for PrintOperation as same as the
PrintDialog produced.
Re: Printing GMF diagram [message #198245 is a reply to message #198199] Tue, 22 July 2008 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mike.gmail.com

Hello David BY Chan,


First of all thanks a lot for replying.

Basically what I am looking forward to is open up diagrams one by one and
print it so that I can print all diagrams in a project in a single stretch
as opening one by one in editor and print is time consuming.

Now I can open the diagram from my customEnhancedPrintActionHelper class
like this

URI diagramModelFilename = URI.createURI("test.mydomain_diagram"");
GMFResource myGMFDiagram = new GMFResource(diagramModelFilename);
try {
myGMFDiagram.load(Collections.EMPTY_MAP);
MydomainEditorUtil.openDiagram(myGMFDiagram);


} catch (IOException e1) {

e1.printStackTrace();
} catch (PartInitException e) {
System.out.println("Error opening diagram editor"+e.getStatus());

}

I need a method to print this opened diagram. I have made a custom method
for that

private static void printDiagrams(IEditorPart editorPart,DiagramPrinter
diagramPrinter) {

final Printer printer = new Printer();
diagramPrinter.setPrinter(printer);
diagramPrinter.setDisplayDPI(Display.getDefault().getDPI());

DiagramEditPart dgrmEP = ((IDiagramWorkbenchPart)
editorPart).getDiagramEditPart();


assert dgrmEP != null;

diagramPrinter.setDiagrams(Collections.singletonList(((IDiag ramWorkbenchPart)
editorPart).getDiagram()));
diagramPrinter.run();
printer.dispose();

}

This prints the diagram but it is the one already left open in the editor
not the one I open using java code(GMF enables the print menu only when
atleast a diagram is open). I want to know how to pass the object of this
opened diagram so that it prints only that one.If I could read this opened
diagram object, I can set it using diagramPrinter.setDiagrams(...);

I would be very grateful if some one could help me on this.

Thanks in advance.

Mike
Re: Printing All GMF diagrams [message #201014 is a reply to message #198245] Thu, 07 August 2008 10:15 Go to previous message
Eclipse UserFriend
Originally posted by: mike.gmail.com

Hey I found a resolution to this.Will be helpful for someone.

See this
http://cyberpen.wordpress.com/2008/07/27/print-all-gmf-diagr ams-with-a-single-click/


Thanks,

Mike
Previous Topic:Figure not drawn!
Next Topic:How to show a pop-up when a connection is made?
Goto Forum:
  


Current Time: Sat Nov 09 01:44:36 GMT 2024

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

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

Back to the top