Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 34575 Details for
Bug 19602
[Printing] Line numbers aren't printed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
JFace portion of the patch
jfacePrintMarginsPatch.txt (text/plain), 14.50 KB, created by
Steven Wasleski
on 2006-02-13 11:08:29 EST
(
hide
)
Description:
JFace portion of the patch
Filename:
MIME Type:
Creator:
Steven Wasleski
Created:
2006-02-13 11:08:29 EST
Size:
14.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.text >Index: src/org/eclipse/jface/text/source/SourceViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java,v >retrieving revision 1.58 >diff -u -r1.58 SourceViewer.java >--- src/org/eclipse/jface/text/source/SourceViewer.java 10 Feb 2006 15:57:44 -0000 1.58 >+++ src/org/eclipse/jface/text/source/SourceViewer.java 13 Feb 2006 15:48:50 -0000 >@@ -13,6 +13,7 @@ > import java.util.Stack; > > import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyledTextPrintMarginDecorator; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Canvas; >@@ -1011,4 +1012,12 @@ > } > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.TextViewer#getPreferredLineNumberDecorator(int) >+ */ >+ public StyledTextPrintMarginDecorator getPreferredLineNumberDecorator() { >+ return new SourceLineNumberMarginDecorator(this); >+ } >+ > } >Index: src/org/eclipse/jface/text/TextViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java,v >retrieving revision 1.145 >diff -u -r1.145 TextViewer.java >--- src/org/eclipse/jface/text/TextViewer.java 9 Feb 2006 14:18:45 -0000 1.145 >+++ src/org/eclipse/jface/text/TextViewer.java 13 Feb 2006 15:48:50 -0000 >@@ -28,6 +28,8 @@ > import org.eclipse.swt.custom.ST; > import org.eclipse.swt.custom.StyleRange; > import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.custom.StyledTextPrintMarginDecorator; >+import org.eclipse.swt.custom.StyledTextPrintOptions; > import org.eclipse.swt.custom.VerifyKeyListener; > import org.eclipse.swt.dnd.DND; > import org.eclipse.swt.events.ControlEvent; >@@ -95,7 +97,7 @@ > public class TextViewer extends Viewer implements > ITextViewer, ITextViewerExtension, ITextViewerExtension2, ITextViewerExtension4, ITextViewerExtension6, IEditingSupportRegistry, > ITextOperationTarget, ITextOperationTargetExtension, >- IWidgetTokenOwner, IWidgetTokenOwnerExtension, IPostSelectionProvider { >+ IWidgetTokenOwner, IWidgetTokenOwnerExtension, IPostSelectionProvider, IPrintOptionsConsumer { > > /** Internal flag to indicate the debug state. */ > public static final boolean TRACE_ERRORS= false; >@@ -1394,6 +1396,11 @@ > * @since 3.1 > */ > private IPositionUpdater fSelectionUpdater; >+ /** >+ * Options provider for the <code>print()</code> method >+ * @since 3.2 >+ */ >+ private IPrintOptionsProvider fPrintOptionsProvider; > > > //---- Construction and disposal ------------------ >@@ -3908,6 +3915,20 @@ > PrinterData[] printerList= Printer.getPrinterList(); > return (printerList != null && printerList.length > 0); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IPrintOptionsConsumer#setPrintOptionProvider(org.eclipse.jface.text.IPrintOptionsProvider) >+ */ >+ public void setPrintOptionProvider(IPrintOptionsProvider provider) { >+ fPrintOptionsProvider = provider; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IPrintOptionsConsumer#getPreferredLineNumberDecorator(int) >+ */ >+ public StyledTextPrintMarginDecorator getPreferredLineNumberDecorator() { >+ return null; >+ } > > /** > * Brings up a print dialog and calls <code>printContents(Printer)</code> which >@@ -3921,7 +3942,14 @@ > if (data != null) { > > final Printer printer= new Printer(data); >- final Runnable styledTextPrinter= fTextWidget.print(printer); >+ StyledTextPrintOptions options = null; >+ if (fPrintOptionsProvider != null) >+ options = fPrintOptionsProvider.getPrintOptions(); >+ final Runnable styledTextPrinter = >+ options == null >+ ? fTextWidget.print(printer) >+ : fTextWidget.print(printer, options); >+ > > Thread printingThread= new Thread("Printing") { //$NON-NLS-1$ > public void run() { >Index: projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java,v >retrieving revision 1.84 >diff -u -r1.84 ProjectionViewer.java >--- projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java 27 Jan 2006 12:46:08 -0000 1.84 >+++ projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java 13 Feb 2006 15:48:50 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.swt.SWTError; > import org.eclipse.swt.custom.ST; > import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.custom.StyledTextPrintMarginDecorator; > import org.eclipse.swt.dnd.Clipboard; > import org.eclipse.swt.dnd.DND; > import org.eclipse.swt.dnd.TextTransfer; >@@ -1772,4 +1773,12 @@ > > return -1; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.source.SourceViewer#getPreferredLineNumberDecorator(int) >+ */ >+ public StyledTextPrintMarginDecorator getPreferredLineNumberDecorator() { >+ return new ProjectionLineNumberMarginDecorator(this); >+ } >+ > } >\ No newline at end of file >Index: src/org/eclipse/jface/text/IPrintOptionsConsumer.java >=================================================================== >RCS file: src/org/eclipse/jface/text/IPrintOptionsConsumer.java >diff -N src/org/eclipse/jface/text/IPrintOptionsConsumer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/IPrintOptionsConsumer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text; >+ >+import org.eclipse.swt.custom.StyledTextPrintMarginDecorator; >+ >+/** >+ * A print options consumer uses an {@link IPrintOptionsProvider} to acquire >+ * print options. The class {@link TextViewer} implements this interface to >+ * enable editors to set options providers. >+ * >+ * @since 3.2 >+ */ >+public interface IPrintOptionsConsumer { >+ >+ /** >+ * Implementors must return an instance of >+ * <code>StyledTextPrintOptions</code> suitable for printing the current >+ * contents of this viewer's <code>StyledText</code> control. >+ * >+ * @param provider the options provider >+ */ >+ public void setPrintOptionProvider(IPrintOptionsProvider provider); >+ >+ /** >+ * A consumer will have the opportunity to return an instance of their >+ * preferred <code>StyledTextPrintMarginDecorator</code> implementation. >+ * It is permissible to return <code>null</code>. >+ * >+ * @return the preferred line number print margin decorator >+ */ >+ public StyledTextPrintMarginDecorator getPreferredLineNumberDecorator(); >+} >Index: src/org/eclipse/jface/text/source/SourceLineNumberMarginDecorator.java >=================================================================== >RCS file: src/org/eclipse/jface/text/source/SourceLineNumberMarginDecorator.java >diff -N src/org/eclipse/jface/text/source/SourceLineNumberMarginDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/source/SourceLineNumberMarginDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text.source; >+ >+import org.eclipse.jface.internal.text.JFaceTextUtil; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.swt.custom.StyledTextPrintMarginDecorator; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.TextStyle; >+ >+/** >+ * A simple implementation of StyledTextPrintMarginDecorator that prints right >+ * aligned line numbers. The line numbers are mapped to the document line >+ * numbers. >+ */ >+public class SourceLineNumberMarginDecorator implements >+ StyledTextPrintMarginDecorator { >+ >+ private ITextViewer fTextViewer = null; >+ >+ private int fGutter = 0; >+ >+ /** >+ * Constructs a decorator with a gutter as specified. >+ * >+ * @param viewer the viewer for line number conversion. If <code>null</code> >+ * is passed, null is returned from {@link #getMarginText(int)} >+ */ >+ public SourceLineNumberMarginDecorator(ITextViewer viewer) { >+ super(); >+ fTextViewer = viewer; >+ >+ GC gc = new GC(fTextViewer.getTextWidget()); >+ fGutter = gc.getAdvanceWidth(' '); >+ gc.dispose(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ */ >+ protected SourceLineNumberMarginDecorator(ITextViewer viewer, int gutter) { >+ super(); >+ fTextViewer = viewer; >+ fGutter = gutter; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.custom.StyledTextPrintMarginDecorator#getAlignment() >+ */ >+ public int getAlignment() { >+ return FORCE_RIGHT; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.custom.StyledTextPrintMarginDecorator#getGutter() >+ */ >+ public int getGutter() { >+ return fGutter; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.custom.StyledTextPrintMarginDecorator#getMarginText(int) >+ */ >+ public String getMarginText(int line) { >+ String text = null; >+ // This should not happen but degrade non-essential function gracefully. >+ if (fTextViewer != null) >+ text = Integer.toString(getModelLineNumber(line) + 1); >+ return text; >+ } >+ >+ /** >+ * @param line the widget line number >+ * @return the model line number >+ */ >+ protected int getModelLineNumber(int line) { >+ return JFaceTextUtil.widgetLine2ModelLine(fTextViewer, line); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.custom.StyledTextPrintMarginDecorator#getMarginTextStyle() >+ */ >+ public TextStyle getMarginTextStyle() { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/jface/text/IPrintOptionsProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/text/IPrintOptionsProvider.java >diff -N src/org/eclipse/jface/text/IPrintOptionsProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/IPrintOptionsProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text; >+ >+import org.eclipse.swt.custom.StyledTextPrintOptions; >+ >+/** >+ * A print options provider is used by <code>TextViewer.print()</code> to >+ * retrieve the appropriate <code>StyledTextPrintOptions</code>demaps an >+ * element of the viewer's model to for the active print job. >+ * >+ * @since 3.2 >+ */ >+public interface IPrintOptionsProvider { >+ /** >+ * Implementors must return an instance of >+ * <code>StyledTextPrintOptions</code> suitable for printing the current >+ * contents of this viewer's <code>StyledText</code> control. >+ * >+ * @return the options >+ */ >+ public StyledTextPrintOptions getPrintOptions(); >+} >Index: projection/org/eclipse/jface/text/source/projection/ProjectionLineNumberMarginDecorator.java >=================================================================== >RCS file: projection/org/eclipse/jface/text/source/projection/ProjectionLineNumberMarginDecorator.java >diff -N projection/org/eclipse/jface/text/source/projection/ProjectionLineNumberMarginDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ projection/org/eclipse/jface/text/source/projection/ProjectionLineNumberMarginDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text.source.projection; >+ >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.source.SourceLineNumberMarginDecorator; >+ >+/** >+ * An implementation of StyledTextPrintMarginDecorator that prints right aligned >+ * line numbers. The line numbers are mapped to the document line numbers. If a >+ * projection is collapsed a '+' annotation is printed. >+ */ >+public class ProjectionLineNumberMarginDecorator extends >+ SourceLineNumberMarginDecorator { >+ >+ /** >+ * Constructs a decorator with a gutter as specified. >+ * >+ * @param viewer the viewer for line number conversion. If <code>null</code> >+ * is passed, null is returned from {@link #getMarginText(int)} >+ */ >+ public ProjectionLineNumberMarginDecorator(ITextViewer viewer) { >+ super(viewer, 0); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.custom.StyledTextPrintMarginDecorator#getMarginText(int) >+ */ >+ public String getMarginText(int line) { >+ String text = super.getMarginText(line); >+ if (text != null) { >+ int nextModelLine = getModelLineNumber(line + 1); >+ if (((getModelLineNumber(line) + 1) == nextModelLine) >+ || (nextModelLine == -1)) >+ text = text + ' '; >+ else >+ text = text + '+'; >+ } >+ return text; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19602
:
26998
|
34574
| 34575 |
34576
|
34577
|
59913
|
80953