Printing GMF diagram [message #197982] |
Sun, 20 July 2008 06:21 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03490 seconds