Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 163769 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.jface.text
4
Bundle-SymbolicName: org.eclipse.jface.text
5
Bundle-Version: 3.5.100.qualifier
5
Bundle-Version: 3.6.0.qualifier
6
Bundle-Vendor: %providerName
6
Bundle-Vendor: %providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Export-Package: 
8
Export-Package: 
(-)src/org/eclipse/jface/text/source/DefaultAnnotationHover.java (-1 / +13 lines)
Lines 26-32 Link Here
26
 *
26
 *
27
 * @since 3.2
27
 * @since 3.2
28
 */
28
 */
29
public class DefaultAnnotationHover implements IAnnotationHover {
29
public class DefaultAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension3 {
30
30
31
31
32
	/**
32
	/**
Lines 90-96 Link Here
90
					return formatMultipleMessages(messages);
90
					return formatMultipleMessages(messages);
91
			}
91
			}
92
		}
92
		}
93
		
94
		return getHoverInfo(lineNumber);
93
95
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.text.source.IAnnotationHoverExtension3#getHoverInfo(int)
100
	 */
101
	/**
102
	 * @since 3.6
103
	 */
104
	public String getHoverInfo(int lineNumber) {
94
		if (fShowLineNumber && lineNumber > -1)
105
		if (fShowLineNumber && lineNumber > -1)
95
			return JFaceTextMessages.getFormattedString("DefaultAnnotationHover.lineNumber", new String[] { Integer.toString(lineNumber + 1) }); //$NON-NLS-1$
106
			return JFaceTextMessages.getFormattedString("DefaultAnnotationHover.lineNumber", new String[] { Integer.toString(lineNumber + 1) }); //$NON-NLS-1$
96
107
Lines 232-235 Link Here
232
243
233
		return javaAnnotations;
244
		return javaAnnotations;
234
	}
245
	}
246
235
}
247
}
(-)src/org/eclipse/jface/text/source/IAnnotationHoverExtension3.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jface.text.source;
12
13
/**
14
 * Extension interface for {@link org.eclipse.jface.text.source.IAnnotationHover} for
15
 * <ul>
16
 * <li>providing the hover information of a line without any annotations</li>
17
 * </ul>
18
 * 
19
 * @since 3.6
20
 * @author Prakash G.R.
21
 * 
22
 */
23
public interface IAnnotationHoverExtension3 {
24
	
25
	/**
26
	 * Returns the text which should be presented in the a
27
	 * hover popup window. This information is requested based on
28
	 * the specified line number. The implementation should ignore any 
29
	 * annotations in the line
30
	 *
31
	 * @param lineNumber the line number for which information is requested
32
	 * @return the requested information or <code>null</code> if no such information exists
33
	 * @since 3.6
34
	 */
35
	String getHoverInfo(int lineNumber);
36
37
38
}
(-)src/org/eclipse/jface/text/source/OverviewRuler.java (-12 / +27 lines)
Lines 804-818 Link Here
804
	}
804
	}
805
805
806
	/**
806
	/**
807
	 * Translates a given y-coordinate of this ruler into the corresponding
807
	 * Translates a given y-coordinate of this ruler into the corresponding document lines. The
808
	 * document lines. The number of lines depends on the concrete scaling
808
	 * number of lines depends on the concrete scaling given as the ration between the height of
809
	 * given as the ration between the height of this ruler and the length
809
	 * this ruler and the length of the document.
810
	 * of the document.
810
	 * 
811
	 *
811
	 * When restrictForAnnotation is true, then line number calculation is done only for the height
812
	 * of the annotation, else it will be done for the entire lenght of the line.
813
	 * 
812
	 * @param y_coordinate the y-coordinate
814
	 * @param y_coordinate the y-coordinate
815
	 * @param restrictForAnnotation <code>true</code> if calculation is for annotation
813
	 * @return the corresponding document lines
816
	 * @return the corresponding document lines
814
	 */
817
	 */
815
	private int[] toLineNumbers(int y_coordinate) {
818
	private int[] toLineNumbers(int y_coordinate, boolean restrictForAnnotation) {
816
819
817
		StyledText textWidget=  fTextViewer.getTextWidget();
820
		StyledText textWidget=  fTextViewer.getTextWidget();
818
		int maxLines= textWidget.getContent().getLineCount();
821
		int maxLines= textWidget.getContent().getLineCount();
Lines 832-839 Link Here
832
		int pixel1= Math.min(rulerLength, y_coordinate + 1);
835
		int pixel1= Math.min(rulerLength, y_coordinate + 1);
833
		rulerLength= Math.max(rulerLength, 1);
836
		rulerLength= Math.max(rulerLength, 1);
834
837
835
		lines[0]= (pixel0 * maxLines) / rulerLength;
838
		// if the ruler is very big, rounding off is heavy
836
		lines[1]= (pixel1 * maxLines) / rulerLength;
839
		if(rulerLength > maxLines){
840
			lines[0]= (int)(pixel0 * (maxLines / (double)rulerLength));
841
			lines[1]= (int)(pixel1 * (maxLines / (double)rulerLength));
842
		}else{
843
			lines[0]= pixel0 * (maxLines / rulerLength);
844
			lines[1]= pixel1 * (maxLines / rulerLength);
845
		}
846
		
847
		if (restrictForAnnotation) {
848
			// hit test should be only for the annotation height - not for the entire line length
849
			if (y_coordinate > (((lines[0] * rulerLength) / maxLines) + fAnnotationHeight))
850
				return new int[] { -1, -1 };
851
		}
837
852
838
		if (fTextViewer instanceof ITextViewerExtension5) {
853
		if (fTextViewer instanceof ITextViewerExtension5) {
839
			ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
854
			ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
Lines 937-943 Link Here
937
	 */
952
	 */
938
	private void handleMouseDown(MouseEvent event) {
953
	private void handleMouseDown(MouseEvent event) {
939
		if (fTextViewer != null) {
954
		if (fTextViewer != null) {
940
			int[] lines= toLineNumbers(event.y);
955
			int[] lines= toLineNumbers(event.y, false);
941
			Position p= getAnnotationPosition(lines);
956
			Position p= getAnnotationPosition(lines);
942
			if (p == null && event.button == 1) {
957
			if (p == null && event.button == 1) {
943
				try {
958
				try {
Lines 962-968 Link Here
962
	 */
977
	 */
963
	private void handleMouseMove(MouseEvent event) {
978
	private void handleMouseMove(MouseEvent event) {
964
		if (fTextViewer != null) {
979
		if (fTextViewer != null) {
965
			int[] lines= toLineNumbers(event.y);
980
			int[] lines= toLineNumbers(event.y, true);
966
			Position p= getAnnotationPosition(lines);
981
			Position p= getAnnotationPosition(lines);
967
			Cursor cursor= (p != null ? fHitDetectionCursor : null);
982
			Cursor cursor= (p != null ? fHitDetectionCursor : null);
968
			if (cursor != fLastCursor) {
983
			if (cursor != fLastCursor) {
Lines 1216-1222 Link Here
1216
		if (fTextViewer == null || y_coordinate == -1)
1231
		if (fTextViewer == null || y_coordinate == -1)
1217
			return -1;
1232
			return -1;
1218
1233
1219
		int[] lineNumbers= toLineNumbers(y_coordinate);
1234
		int[] lineNumbers= toLineNumbers(y_coordinate, false);
1220
		int bestLine= findBestMatchingLineNumber(lineNumbers);
1235
		int bestLine= findBestMatchingLineNumber(lineNumbers);
1221
		if (bestLine == -1 && lineNumbers.length > 0)
1236
		if (bestLine == -1 && lineNumbers.length > 0)
1222
			return lineNumbers[0];
1237
			return lineNumbers[0];
Lines 1241-1247 Link Here
1241
	 * @see org.eclipse.jface.text.source.IOverviewRuler#hasAnnotation(int)
1256
	 * @see org.eclipse.jface.text.source.IOverviewRuler#hasAnnotation(int)
1242
	 */
1257
	 */
1243
	public boolean hasAnnotation(int y) {
1258
	public boolean hasAnnotation(int y) {
1244
		return findBestMatchingLineNumber(toLineNumbers(y)) != -1;
1259
		return findBestMatchingLineNumber(toLineNumbers(y, true)) != -1;
1245
	}
1260
	}
1246
1261
1247
	/*
1262
	/*
(-)src/org/eclipse/jface/text/source/OverviewRulerHoverManager.java (-2 / +31 lines)
Lines 51-57 Link Here
51
	 */
51
	 */
52
	protected void computeInformation() {
52
	protected void computeInformation() {
53
		Point location= getHoverEventLocation();
53
		Point location= getHoverEventLocation();
54
		int line= getVerticalRulerInfo().toDocumentLineNumber(location.y);
54
		IVerticalRulerInfo verticalRulerInfo= getVerticalRulerInfo();
55
		int line= verticalRulerInfo.toDocumentLineNumber(location.y);
55
		IAnnotationHover hover= getAnnotationHover();
56
		IAnnotationHover hover= getAnnotationHover();
56
57
57
		IInformationControlCreator controlCreator= null;
58
		IInformationControlCreator controlCreator= null;
Lines 59-65 Link Here
59
			controlCreator= ((IAnnotationHoverExtension)hover).getHoverControlCreator();
60
			controlCreator= ((IAnnotationHoverExtension)hover).getHoverControlCreator();
60
		setCustomInformationControlCreator(controlCreator);
61
		setCustomInformationControlCreator(controlCreator);
61
62
62
		setInformation(hover.getHoverInfo(getSourceViewer(), line), computeArea(location.y));
63
		String hoverInfo;
64
		if(hover instanceof IAnnotationHoverExtension3 && !hasAnnotation(verticalRulerInfo, location.y)) {
65
			hoverInfo= ((IAnnotationHoverExtension3)hover).getHoverInfo(line);
66
		}else {
67
			hoverInfo= hover.getHoverInfo(getSourceViewer(), line);
68
		}
69
		
70
		setInformation(hoverInfo, computeArea(location.y));
71
	}
72
73
	/**
74
	 *  This method calculates whether an annotation is shown in the particular y coordinate.
75
	 *  
76
	 * @param verticalRulerInfo	The vertical ruler in which annotions are searched for
77
	 * @param y_coordinate The coordinate in the ruler's SWT control
78
	 * 
79
	 * @return <code>true</code> if an annotation exists, <code>false</code> otherwise 
80
	 */
81
	private boolean hasAnnotation(IVerticalRulerInfo verticalRulerInfo, int y_coordinate) {
82
		
83
		if(verticalRulerInfo instanceof IOverviewRuler) {
84
			IOverviewRuler overviewRuler = (IOverviewRuler)verticalRulerInfo;
85
			int height= overviewRuler.getAnnotationHeight();
86
			for (int i= y_coordinate-height; i <y_coordinate+height; i++) {
87
				if(overviewRuler.hasAnnotation(i))
88
					return true;
89
			}
90
		}
91
		return false;
63
	}
92
	}
64
93
65
	/**
94
	/**

Return to bug 163769