1 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 33 public class TextChangeHover extends LineChangeHover { 34 35 36 private int fLastScrollIndex= 0; 37 38 41 protected String getTabReplacement() { 42 return Character.toString('\t'); 43 } 44 45 46 49 public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) { 50 fLastScrollIndex= sourceViewer.getTextWidget().getHorizontalPixel(); 51 return super.getHoverInfo(sourceViewer, lineRange, visibleLines); 52 } 53 54 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 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 |