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

Collapse All | Expand All

(-)src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java (-2 / +25 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 652-657 Link Here
652
	private boolean fWaitForMouseUp= false;
652
	private boolean fWaitForMouseUp= false;
653
653
654
	/**
654
	/**
655
	 * Indicates whether in keyboard mode or mouse mode
656
	 * 
657
	 * @since 3.6
658
	 */
659
	private boolean fKeyboardMode= false;
660
661
	/**
655
	 * Creates a new hover information control manager using the given information control creator.
662
	 * Creates a new hover information control manager using the given information control creator.
656
	 * By default a <code>Closer</code> instance is set as this manager's closer.
663
	 * By default a <code>Closer</code> instance is set as this manager's closer.
657
	 *
664
	 *
Lines 885-891 Link Here
885
	 * @see org.eclipse.jface.text.AbstractInformationControlManager#presentInformation()
892
	 * @see org.eclipse.jface.text.AbstractInformationControlManager#presentInformation()
886
	 */
893
	 */
887
	protected void presentInformation() {
894
	protected void presentInformation() {
888
		if (fMouseTracker == null) {
895
		if (fMouseTracker == null || isKeyboardMode()) {
889
			super.presentInformation();
896
			super.presentInformation();
890
			return;
897
			return;
891
		}
898
		}
Lines 980-983 Link Here
980
		};
987
		};
981
	}
988
	}
982
989
990
	/**
991
	 * @return <code>true</code> if in keyboard mode, <code>false</code> otherwise
992
	 * @since 3.6
993
	 */
994
	protected boolean isKeyboardMode() {
995
		return fKeyboardMode;
996
	}
997
998
	/**
999
	 * @param keyboardMode <code>true</code> to set to keyboard mode, <code>false</code> otherwise
1000
	 * @since 3.6
1001
	 */
1002
	protected void setKeyboardMode(boolean keyboardMode) {
1003
		this.fKeyboardMode= keyboardMode;
1004
	}
1005
983
}
1006
}
(-)src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java (-1 / +42 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 747-752 Link Here
747
    }
747
    }
748
748
749
	/**
749
	/**
750
	 * Shows the annotation hover for the current keyboard action.
751
	 * @since 3.6
752
	 */
753
	public void showAnnotationHoverForKeyboardAction() {
754
		setKeyboardMode(true);
755
		IAnnotationHover hover= null;
756
		if (fVerticalRulerInfo instanceof CompositeRuler) {
757
			CompositeRuler comp= (CompositeRuler)fVerticalRulerInfo;
758
			for (Iterator it= comp.getDecoratorIterator(); it.hasNext();) {
759
				Object o= it.next();
760
				if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) {
761
					hover= ((IVerticalRulerInfoExtension)o).getHover();
762
					break;
763
				}
764
			}
765
		}
766
767
		if (hover == null) {
768
			hover= fAnnotationHover;
769
		}
770
		int line= fVerticalRulerInfo.getLineOfLastMouseButtonActivity();
771
772
		if (hover instanceof IAnnotationHoverExtension) {
773
				IAnnotationHoverExtension extension= (IAnnotationHoverExtension)hover;
774
				ILineRange range= extension.getHoverLineRange(fSourceViewer, line);
775
				setCustomInformationControlCreator(extension.getHoverControlCreator());
776
				range= adaptLineRange(range, line);
777
				if (range != null)
778
					setInformation(extension.getHoverInfo(fSourceViewer, range, computeNumberOfVisibleLines()), computeArea(range));
779
				else
780
					setInformation(null, null);
781
782
			} else {
783
				setCustomInformationControlCreator(null);
784
				setInformation(hover.getHoverInfo(fSourceViewer, line), computeArea(line));
785
		}
786
		getInformationControl().setFocus();
787
		setKeyboardMode(false);
788
	}
789
790
	/**
750
	 * Returns an adapter that gives access to internal methods.
791
	 * Returns an adapter that gives access to internal methods.
751
	 * <p>
792
	 * <p>
752
	 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.
793
	 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.
(-)src/org/eclipse/jface/text/source/ISourceViewerExtension5.java (+31 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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
12
package org.eclipse.jface.text.source;
13
14
15
/**
16
 * Extension interface for {@link org.eclipse.jface.text.source.ISourceViewer}.
17
 * <p>
18
 * It shows the annotation hover for the current keyboard action.
19
 * </p>
20
 * 
21
 * @since 3.6
22
 */
23
public interface ISourceViewerExtension5 {
24
25
	/**
26
	 * Shows the annotation hover for the current keyboard action if any.
27
	 * @since 3.6
28
	 */
29
	void showAnnotationHoverForKeyboardAction();
30
31
}
(-)src/org/eclipse/jface/text/source/SourceViewer.java (-8 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Tom Eicher (Avaloq Evolution AG) - block selection mode
10
 *     Tom Eicher (Avaloq Evolution AG) - block selection mode
11
 *     Tom Hofmann (Perspectix AG) - bug 297572  
11
 *     Tom Hofmann (Perspectix AG) - bug 297572
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.jface.text.source;
13
package org.eclipse.jface.text.source;
14
14
Lines 80-86 Link Here
80
 * <p>
80
 * <p>
81
 * Clients may subclass this class but should expect some breakage by future releases.</p>
81
 * Clients may subclass this class but should expect some breakage by future releases.</p>
82
 */
82
 */
83
public class SourceViewer extends TextViewer implements ISourceViewer, ISourceViewerExtension, ISourceViewerExtension2, ISourceViewerExtension3, ISourceViewerExtension4 {
83
public class SourceViewer extends TextViewer implements ISourceViewer, ISourceViewerExtension, ISourceViewerExtension2, ISourceViewerExtension3, ISourceViewerExtension4, ISourceViewerExtension5 {
84
84
85
85
86
	/**
86
	/**
Lines 186-192 Link Here
186
			} else if (fScrollArrowHeights != null) {
186
			} else if (fScrollArrowHeights != null) {
187
				return fScrollArrowHeights;
187
				return fScrollArrowHeights;
188
			} else {
188
			} else {
189
				// No arrow heights available. Enlarge textWidget and tweak scroll bar to get reasonable values. 
189
				// No arrow heights available. Enlarge textWidget and tweak scroll bar to get reasonable values.
190
				Point originalSize= textWidget.getSize();
190
				Point originalSize= textWidget.getSize();
191
				try {
191
				try {
192
					int fakeHeight= 1000;
192
					int fakeHeight= 1000;
Lines 1181-1193 Link Here
1181
		}
1181
		}
1182
	}
1182
	}
1183
1183
1184
    /*
1184
	/*
1185
     * @see org.eclipse.jface.text.source.ISourceViewer#getCurrentAnnotationHover()
1185
	 * @see org.eclipse.jface.text.source.ISourceViewerExtension3#getCurrentAnnotationHover()
1186
     * @since 3.2
1186
	 * @since 3.2
1187
     */
1187
	 */
1188
    public IAnnotationHover getCurrentAnnotationHover() {
1188
    public IAnnotationHover getCurrentAnnotationHover() {
1189
    	if (fVerticalRulerHoveringController == null)
1189
    	if (fVerticalRulerHoveringController == null)
1190
    		return null;
1190
    		return null;
1191
    	return fVerticalRulerHoveringController.getCurrentAnnotationHover();
1191
    	return fVerticalRulerHoveringController.getCurrentAnnotationHover();
1192
    }
1192
    }
1193
1194
	/**
1195
	 * @see org.eclipse.jface.text.source.ISourceViewerExtension5#showAnnotationHoverForKeyboardAction()
1196
	 * @since 3.6
1197
	 */
1198
	public void showAnnotationHoverForKeyboardAction() {
1199
		if (fVerticalRulerHoveringController == null)
1200
			return;
1201
		fVerticalRulerHoveringController.showAnnotationHoverForKeyboardAction();
1202
	}
1193
}
1203
}
(-)plugin.properties (-1 / +4 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
2
# Copyright (c) 2000, 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 111-116 Link Here
111
command.showChangeRulerInformation.name = Show Quick Diff Ruler Tooltip
111
command.showChangeRulerInformation.name = Show Quick Diff Ruler Tooltip
112
command.showChangeRulerInformation.description = Displays quick diff or revision information for the caret line in a focused hover
112
command.showChangeRulerInformation.description = Displays quick diff or revision information for the caret line in a focused hover
113
113
114
command.showRulerAnnotationInformation.name = Show Ruler Annotation Tooltip
115
command.showRulerAnnotationInformation.description = Displays annotation information for the caret line in a focused hover
116
114
conversionActionSet.label= Convert Line Delimiters
117
conversionActionSet.label= Convert Line Delimiters
115
conversionSubMenu.label= Con&vert Line Delimiters To
118
conversionSubMenu.label= Con&vert Line Delimiters To
116
119
(-)plugin.xml (+6 lines)
Lines 135-140 Link Here
135
	        categoryId="org.eclipse.ui.category.textEditor"
135
	        categoryId="org.eclipse.ui.category.textEditor"
136
            id="org.eclipse.ui.edit.text.showChangeRulerInformation">
136
            id="org.eclipse.ui.edit.text.showChangeRulerInformation">
137
      </command>
137
      </command>
138
      <command
139
            name="%command.showRulerAnnotationInformation.name"
140
            description="%command.showRulerAnnotationInformation.description"
141
	        categoryId="org.eclipse.ui.category.textEditor"
142
            id="org.eclipse.ui.edit.text.showRulerAnnotationInformation">
143
      </command>
138
   </extension>
144
   </extension>
139
   
145
   
140
   <extension
146
   <extension
(-)src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java (+38 lines)
Lines 100-105 Link Here
100
import org.eclipse.jface.text.source.ISourceViewer;
100
import org.eclipse.jface.text.source.ISourceViewer;
101
import org.eclipse.jface.text.source.ISourceViewerExtension;
101
import org.eclipse.jface.text.source.ISourceViewerExtension;
102
import org.eclipse.jface.text.source.ISourceViewerExtension3;
102
import org.eclipse.jface.text.source.ISourceViewerExtension3;
103
import org.eclipse.jface.text.source.ISourceViewerExtension5;
103
import org.eclipse.jface.text.source.IVerticalRuler;
104
import org.eclipse.jface.text.source.IVerticalRuler;
104
import org.eclipse.jface.text.source.IVerticalRulerColumn;
105
import org.eclipse.jface.text.source.IVerticalRulerColumn;
105
import org.eclipse.jface.text.source.LineChangeHover;
106
import org.eclipse.jface.text.source.LineChangeHover;
Lines 1255-1260 Link Here
1255
		};
1256
		};
1256
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_CHANGE_RULER_INFORMATION_ID);
1257
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_CHANGE_RULER_INFORMATION_ID);
1257
		setAction(ITextEditorActionConstants.SHOW_CHANGE_RULER_INFORMATION, action);
1258
		setAction(ITextEditorActionConstants.SHOW_CHANGE_RULER_INFORMATION, action);
1259
1260
		action= new ResourceAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ShowRulerAnnotationInformation.", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$
1261
			public void run() {
1262
				showRulerAnnotationInformation();
1263
			}
1264
		};
1265
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_RULER_ANNOTATION_INFORMATION_ID);
1266
		setAction(ITextEditorActionConstants.SHOW_RULER_ANNOTATION_INFORMATION, action);
1258
	}
1267
	}
1259
1268
1260
	/**
1269
	/**
Lines 1305-1310 Link Here
1305
    }
1314
    }
1306
1315
1307
	/**
1316
	/**
1317
	 * Opens a sticky ruler annotation hover for the caret line. Does nothing if no annotation hover
1318
	 * is available.
1319
	 * 
1320
	 * @since 3.6
1321
	 */
1322
	private void showRulerAnnotationInformation() {
1323
		IVerticalRuler ruler= getVerticalRuler();
1324
		if (!(ruler instanceof CompositeRuler) || fLineColumn == null)
1325
			return;
1326
1327
		ISourceViewer sourceViewer= getSourceViewer();
1328
		CompositeRuler compositeRuler= (CompositeRuler)ruler;
1329
1330
		// fake a mouse move (some hovers rely on this to determine the hovered line):
1331
		int x= fLineColumn.getControl().getLocation().x;
1332
1333
		StyledText textWidget= sourceViewer.getTextWidget();
1334
		int caretOffset= textWidget.getCaretOffset();
1335
		int caretLine= textWidget.getLineAtOffset(caretOffset);
1336
		int y= textWidget.getLinePixel(caretLine);
1337
1338
		compositeRuler.setLocationOfLastMouseButtonActivity(x, y);
1339
1340
		if (sourceViewer instanceof ISourceViewerExtension5) {
1341
			((ISourceViewerExtension5)sourceViewer).showAnnotationHoverForKeyboardAction();
1342
		}
1343
	}
1344
1345
	/**
1308
	 * Creates and registers the print action.
1346
	 * Creates and registers the print action.
1309
	 *
1347
	 *
1310
	 * @since 3.4
1348
	 * @since 3.4
(-)src/org/eclipse/ui/texteditor/ConstructedTextEditorMessages.properties (-1 / +6 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
2
# Copyright (c) 2000, 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 109-111 Link Here
109
Editor.ShowChangeRulerInformation.tooltip= Show Quick Diff Ruler Tooltip
109
Editor.ShowChangeRulerInformation.tooltip= Show Quick Diff Ruler Tooltip
110
Editor.ShowChangeRulerInformation.image=
110
Editor.ShowChangeRulerInformation.image=
111
Editor.ShowChangeRulerInformation.description= Displays change information for the caret line in a focused hover
111
Editor.ShowChangeRulerInformation.description= Displays change information for the caret line in a focused hover
112
113
Editor.ShowRulerAnnotationInformation.label= Show Ruler Annotation Tooltip
114
Editor.ShowRulerAnnotationInformation.tooltip= Show Ruler Annotation Tooltip
115
Editor.ShowRulerAnnotationInformation.image=
116
Editor.ShowRulerAnnotationInformation.description= Displays annotation information for the caret line in a focused hover
(-)src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 680-683 Link Here
680
	 * @since 3.6
680
	 * @since 3.6
681
	 */
681
	 */
682
	public static final String SHOW_CHANGE_RULER_INFORMATION= "ShowChangeRulerInformation"; //$NON-NLS-1$
682
	public static final String SHOW_CHANGE_RULER_INFORMATION= "ShowChangeRulerInformation"; //$NON-NLS-1$
683
684
	/**
685
	 * Name of the action displaying a sticky ruler annotation hover for the current caret location.
686
	 * 
687
	 * Value: <code>"ShowRulerAnnotationInformation"</code>
688
	 * @since 3.6
689
	 */
690
	public static final String SHOW_RULER_ANNOTATION_INFORMATION= "ShowRulerAnnotationInformation"; //$NON-NLS-1$
683
}
691
}
(-)src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 585-588 Link Here
585
	 * @since 3.6
585
	 * @since 3.6
586
	 */
586
	 */
587
	public static final String SHOW_CHANGE_RULER_INFORMATION_ID= "org.eclipse.ui.edit.text.showChangeRulerInformation"; //$NON-NLS-1$
587
	public static final String SHOW_CHANGE_RULER_INFORMATION_ID= "org.eclipse.ui.edit.text.showChangeRulerInformation"; //$NON-NLS-1$
588
589
	/**
590
	 * Command ID of the command to display a sticky ruler annotation hover for the current caret
591
	 * location. Value <code>"org.eclipse.ui.edit.text.showRulerAnnotationInformation"</code>.
592
	 * 
593
	 * @since 3.6
594
	 */
595
	public static final String SHOW_RULER_ANNOTATION_INFORMATION_ID= "org.eclipse.ui.edit.text.showRulerAnnotationInformation"; //$NON-NLS-1$
588
}
596
}

Return to bug 272172