use of org.jboss.tools.hibernate.ui.diagram.print.PrintDiagramViewerOperation in project jbosstools-hibernate by jbosstools.
the class PrintDiagramViewerAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
GraphicalViewer viewer;
viewer = (GraphicalViewer) getWorkbenchPart().getAdapter(GraphicalViewer.class);
PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL);
PrinterData data = dialog.open();
if (data != null) {
PrintDiagramViewerOperation op = new PrintDiagramViewerOperation(new Printer(data), viewer);
DiagramViewer dv = (DiagramViewer) getWorkbenchPart();
op.setZoom(dv.getZoom());
if (Math.abs(dv.getZoom() - dv.getFitHeightZoomValue()) < 0.00000001) {
op.setPrintMode(PrintGraphicalViewerOperation.FIT_HEIGHT);
} else if (Math.abs(dv.getZoom() - dv.getFitWidthZoomValue()) < 0.00000001) {
op.setPrintMode(PrintGraphicalViewerOperation.FIT_WIDTH);
} else if (Math.abs(dv.getZoom() - dv.getFitPageZoomValue()) < 0.00000001) {
op.setPrintMode(PrintGraphicalViewerOperation.FIT_PAGE);
} else {
op.setPrintMode(PrintGraphicalViewerOperation.TILE);
}
op.run(getWorkbenchPart().getTitle());
}
}
Aggregations