Search in sources :

Example 1 with StyledTextPrintOptions

use of org.eclipse.swt.custom.StyledTextPrintOptions in project eclipse.platform.text by eclipse.

the class TextViewer method print.

/**
 * Brings up a print dialog and calls <code>printContents(Printer)</code>
 * which performs the actual print.
 */
protected void print() {
    StyledTextPrintOptions options = new StyledTextPrintOptions();
    options.printTextFontStyle = true;
    options.printTextForeground = true;
    print(options);
}
Also used : StyledTextPrintOptions(org.eclipse.swt.custom.StyledTextPrintOptions)

Example 2 with StyledTextPrintOptions

use of org.eclipse.swt.custom.StyledTextPrintOptions in project eclipse.platform.text by eclipse.

the class AbstractDecoratedTextEditor method createPrintAction.

/**
 * Creates and registers the print action.
 *
 * @since 3.4
 */
private void createPrintAction() {
    final ISourceViewer viewer = getSourceViewer();
    ResourceAction action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.Print.") {

        @Override
        public void run() {
            StyledTextPrintOptions options = new StyledTextPrintOptions();
            options.printTextFontStyle = true;
            options.printTextForeground = true;
            options.printTextBackground = true;
            options.jobName = getTitle();
            options.header = StyledTextPrintOptions.SEPARATOR + getTitle();
            options.footer = StyledTextPrintOptions.SEPARATOR + NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_printPageNumber, StyledTextPrintOptions.PAGE_TAG);
            if (isLineNumberRulerVisible()) {
                options.printLineNumbers = true;
                // Compute line number labels
                options.lineLabels = new String[viewer.getTextWidget().getLineCount()];
                for (int i = 0; i < options.lineLabels.length; i++) options.lineLabels[i] = String.valueOf(JFaceTextUtil.widgetLine2ModelLine(viewer, i) + 1);
            }
            ((ITextViewerExtension8) viewer).print(options);
        }
    };
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PRINT);
    setAction(ITextEditorActionConstants.PRINT, action);
}
Also used : StyledTextPrintOptions(org.eclipse.swt.custom.StyledTextPrintOptions) ITextViewerExtension8(org.eclipse.jface.text.ITextViewerExtension8) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Point(org.eclipse.swt.graphics.Point)

Aggregations

StyledTextPrintOptions (org.eclipse.swt.custom.StyledTextPrintOptions)2 ITextViewerExtension8 (org.eclipse.jface.text.ITextViewerExtension8)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 Point (org.eclipse.swt.graphics.Point)1