View | Details | Raw Unified | Return to bug 63808 | Differences between
and this patch

Collapse All | Expand All

(-)projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java (-33 / +63 lines)
Lines 13-18 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.jface.text.IInformationControlCreator;
17
import org.eclipse.jface.text.source.Annotation;
18
import org.eclipse.jface.text.source.AnnotationPainter;
19
import org.eclipse.jface.text.source.IAnnotationAccess;
20
import org.eclipse.jface.text.source.IAnnotationHover;
21
import org.eclipse.jface.text.source.IAnnotationModel;
22
import org.eclipse.jface.text.source.ISharedTextColors;
23
import org.eclipse.jface.text.source.ISourceViewer;
16
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.custom.StyledText;
25
import org.eclipse.swt.custom.StyledText;
18
import org.eclipse.swt.custom.StyledTextContent;
26
import org.eclipse.swt.custom.StyledTextContent;
Lines 23-37 Link Here
23
import org.eclipse.swt.graphics.RGB;
31
import org.eclipse.swt.graphics.RGB;
24
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.swt.widgets.Display;
25
33
26
import org.eclipse.jface.text.IInformationControlCreator;
27
import org.eclipse.jface.text.source.Annotation;
28
import org.eclipse.jface.text.source.AnnotationPainter;
29
import org.eclipse.jface.text.source.IAnnotationAccess;
30
import org.eclipse.jface.text.source.IAnnotationHover;
31
import org.eclipse.jface.text.source.IAnnotationModel;
32
import org.eclipse.jface.text.source.ISharedTextColors;
33
import org.eclipse.jface.text.source.ISourceViewer;
34
35
/**
34
/**
36
 * Supports the configuration of projection capabilities a {@link org.eclipse.jface.text.source.projection.ProjectionViewer}.
35
 * Supports the configuration of projection capabilities a {@link org.eclipse.jface.text.source.projection.ProjectionViewer}.
37
 * <p>
36
 * <p>
Lines 90-130 Link Here
90
				ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
89
				ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
91
				if (projectionAnnotation.isCollapsed()) {
90
				if (projectionAnnotation.isCollapsed()) {
92
91
93
					if (gc != null) {
92
					if (gc != null) {						
94
95
						StyledTextContent content= textWidget.getContent();
93
						StyledTextContent content= textWidget.getContent();
96
						int line= content.getLineAtOffset(offset);
94
						int line= content.getLineAtOffset(offset);
97
						int lineStart= content.getOffsetAtLine(line);
95
						int lineStart= content.getOffsetAtLine(line);
96
						boolean titled = projectionAnnotation instanceof IProjectionAnnotationTitled;
97
						String title = null;
98
						if (titled) {																					
99
							title = ((IProjectionAnnotationTitled) projectionAnnotation)
100
									.getTitle();
101
							titled = (title != null);
102
						}
98
						String text= content.getLine(line);
103
						String text= content.getLine(line);
99
						int lineLength= text == null ? 0 : text.length();
104
						int lineLength= text == null ? 0 : text.length();
100
						int lineEnd= lineStart + lineLength;
105
						int lineEnd= lineStart + lineLength;
101
						Point p= textWidget.getLocationAtOffset(lineEnd);
106
						Point p;						
107
						if (titled) {
108
							// TODO: Medium Hack!
109
							// Find first "//"
110
							int index = text.indexOf("//"); //$NON-NLS-1$
111
							if (index >= 0) {
112
								p = textWidget
113
										.getLocationAtOffset(lineStart + index);
114
							} else {
115
								// Animation step while expanding/collapsing.
116
								titled = false;
117
								p = textWidget.getLocationAtOffset(lineEnd);
118
							}
119
						} else {
120
							p = textWidget.getLocationAtOffset(lineEnd);
121
						}
102
122
103
						Color c= gc.getForeground();
123
						Color c= gc.getForeground();
104
						gc.setForeground(color);
124
						gc.setForeground(color);
105
125
106
						FontMetrics metrics= gc.getFontMetrics();
126
						FontMetrics metrics= gc.getFontMetrics();
107
127
						int width = metrics.getAverageCharWidth();						
108
						// baseline: where the dots are drawn
128
																		
109
						int baseline= textWidget.getBaseline(offset);
129
						if (!titled) {
110
						// descent: number of pixels that the box extends over baseline
130
							// baseline: where the dots are drawn
111
						int descent= Math.min(2, textWidget.getLineHeight(offset) - baseline);
131
							int baseline= textWidget.getBaseline(offset);
112
						// ascent: so much does the box stand up from baseline
132
							// descent: number of pixels that the box extends over baseline
113
						int ascent= metrics.getAscent();
133
							int descent= Math.min(2, textWidget.getLineHeight(offset) - baseline);
114
						// leading: free space from line top to box upper line
134
							// ascent: so much does the box stand up from baseline
115
						int leading= baseline - ascent;
135
							int ascent= metrics.getAscent();
116
						// height: height of the box
136
							// leading: free space from line top to box upper line
117
						int height= ascent + descent;
137
							int leading= baseline - ascent;
118
138
							// height: height of the box
119
						int width= metrics.getAverageCharWidth();
139
							int height= ascent + descent;
120
						gc.drawRectangle(p.x, p.y + leading, width, height);
140
							
121
						int third= width/3;
141
							int dotsVertical= p.y + baseline - 1;
122
						int dotsVertical= p.y + baseline - 1;
142
							
123
						gc.drawPoint(p.x + third, dotsVertical);
143
							gc.drawRectangle(p.x, p.y + leading, width, height);
124
						gc.drawPoint(p.x + width - third, dotsVertical);
144
							int third= width/3;							
125
145
							gc.drawPoint(p.x + third, dotsVertical);
126
						gc.setForeground(c);
146
							gc.drawPoint(p.x + width - third, dotsVertical);
127
147
						} else {
148
							int charHeight = metrics.getHeight();
149
							// TODO: Dirty Hack! -> Remove immediately
150
							// White out old stuff.
151
							gc.fillRectangle(p.x-1, p.y, width*lineLength+1, charHeight+1);
152
							// Draw end-user customized text instead.
153
							gc.drawText(title, p.x, p.y);
154
							// Don't remove, should be this way:
155
							gc.drawRectangle(p.x-1, p.y, width*title.length()+1, charHeight);							
156
						}
157
						gc.setForeground(c);					
128
					} else {
158
					} else {
129
						textWidget.redrawRange(offset, length, true);
159
						textWidget.redrawRange(offset, length, true);
130
					}
160
					}
(-)projection/org/eclipse/jface/text/source/projection/IProjectionAnnotationTitled.java (+12 lines)
Added Link Here
1
package org.eclipse.jface.text.source.projection;
2
3
4
public interface IProjectionAnnotationTitled {
5
	
6
	/**
7
	 * Titled Projection Annotation.
8
	 * 
9
	 * @return title of the projection annotation. Must not be <code>null</code>.
10
	 */
11
	String getTitle();
12
}

Return to bug 63808