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);
}
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);
}
Aggregations