Search in sources :

Example 1 with PrintGraphicalViewerOperation

use of org.eclipse.gef.print.PrintGraphicalViewerOperation in project archi by archimatetool.

the class PrintDiagramAction method run.

@Override
public void run() {
    PrintModeDialog modeDialog = new PrintModeDialog(getWorkbenchPart().getSite().getShell());
    modeDialog.open();
    int printMode = modeDialog.getPrintMode();
    if (printMode == -1) {
        return;
    }
    PrintDialog printDialog = new PrintDialog(getWorkbenchPart().getSite().getShell(), SWT.NULL);
    PrinterData data = printDialog.open();
    if (data != null) {
        IDiagramModel diagramModel = getWorkbenchPart().getAdapter(IDiagramModel.class);
        Shell tempShell = new Shell();
        GraphicalViewerImpl viewer = DiagramUtils.createViewer(diagramModel, tempShell);
        PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(new Printer(data), viewer);
        // this should stop font clipping
        op.setUseScaledGraphics(false);
        op.setPrintMode(printMode);
        op.run(getWorkbenchPart().getTitle());
        tempShell.dispose();
    }
}
Also used : PrintGraphicalViewerOperation(org.eclipse.gef.print.PrintGraphicalViewerOperation) Shell(org.eclipse.swt.widgets.Shell) PrintDialog(org.eclipse.swt.printing.PrintDialog) IDiagramModel(com.archimatetool.model.IDiagramModel) PrinterData(org.eclipse.swt.printing.PrinterData) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) Printer(org.eclipse.swt.printing.Printer)

Example 2 with PrintGraphicalViewerOperation

use of org.eclipse.gef.print.PrintGraphicalViewerOperation in project archi by archimatetool.

the class PrintAction method run.

/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    GraphicalViewer viewer;
    viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
    PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL);
    PrinterData data = dialog.open();
    if (data != null) {
        PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(new Printer(data), viewer);
        op.run(getWorkbenchPart().getTitle());
    }
}
Also used : PrintGraphicalViewerOperation(org.eclipse.gef.print.PrintGraphicalViewerOperation) GraphicalViewer(org.eclipse.gef.GraphicalViewer) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) Printer(org.eclipse.swt.printing.Printer)

Aggregations

PrintGraphicalViewerOperation (org.eclipse.gef.print.PrintGraphicalViewerOperation)2 PrintDialog (org.eclipse.swt.printing.PrintDialog)2 Printer (org.eclipse.swt.printing.Printer)2 PrinterData (org.eclipse.swt.printing.PrinterData)2 IDiagramModel (com.archimatetool.model.IDiagramModel)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)1 Shell (org.eclipse.swt.widgets.Shell)1