KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > texteditor > TextChangeHover


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.ui.internal.texteditor;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.widgets.Shell;
15
16 import org.eclipse.jface.resource.JFaceResources;
17
18 import org.eclipse.jface.text.IInformationControl;
19 import org.eclipse.jface.text.IInformationControlCreator;
20 import org.eclipse.jface.text.source.ILineRange;
21 import org.eclipse.jface.text.source.ISourceViewer;
22 import org.eclipse.jface.text.source.LineChangeHover;
23
24 import org.eclipse.ui.editors.text.EditorsUI;
25
26
27
28 /**
29  * Change hover for text editors. Respects tab settings and text editor font.
30  *
31  * @since 3.0
32  */

33 public class TextChangeHover extends LineChangeHover {
34
35     /** The last created information control. */
36     private int fLastScrollIndex= 0;
37
38     /*
39      * @see org.eclipse.jface.text.source.LineChangeHover#getTabReplacement()
40      */

41     protected String JavaDoc getTabReplacement() {
42         return Character.toString('\t');
43     }
44
45
46     /*
47      * @see org.eclipse.jface.text.source.LineChangeHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, org.eclipse.jface.text.source.ILineRange, int)
48      */

49     public Object JavaDoc getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) {
50         fLastScrollIndex= sourceViewer.getTextWidget().getHorizontalPixel();
51         return super.getHoverInfo(sourceViewer, lineRange, visibleLines);
52     }
53
54     /*
55      * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator()
56      */

57     public IInformationControlCreator getHoverControlCreator() {
58         return new IInformationControlCreator() {
59             public IInformationControl createInformationControl(Shell parent) {
60                 SourceViewerInformationControl control= new SourceViewerInformationControl(parent, SWT.NO_TRIM | SWT.TOOL, SWT.NONE, JFaceResources.TEXT_FONT, EditorsUI.getTooltipAffordanceString());
61                 control.setHorizontalScrollPixel(fLastScrollIndex);
62                 return control;
63             }
64         };
65     }
66     
67     /*
68      * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
69      * @since 3.3
70      */

71     public IInformationControlCreator getInformationPresenterControlCreator() {
72         return new IInformationControlCreator() {
73             public IInformationControl createInformationControl(Shell parent) {
74                 int shellStyle= SWT.RESIZE | SWT.TOOL;
75                 int style= SWT.V_SCROLL | SWT.H_SCROLL;
76                 return new SourceViewerInformationControl(parent, shellStyle, style, JFaceResources.TEXT_FONT, null);
77             }
78         };
79     }
80
81 }
82
Popular Tags