Search in sources :

Example 1 with PrintDiagramViewerOperation

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());
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer) DiagramViewer(org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer) PrintDiagramViewerOperation(org.jboss.tools.hibernate.ui.diagram.print.PrintDiagramViewerOperation)

Aggregations

GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 PrintDialog (org.eclipse.swt.printing.PrintDialog)1 Printer (org.eclipse.swt.printing.Printer)1 PrinterData (org.eclipse.swt.printing.PrinterData)1 DiagramViewer (org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer)1 PrintDiagramViewerOperation (org.jboss.tools.hibernate.ui.diagram.print.PrintDiagramViewerOperation)1