|
Lines 110-123
Link Here
|
| 110 |
|
110 |
|
| 111 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
111 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
| 112 |
import org.eclipse.jface.text.BadLocationException; |
112 |
import org.eclipse.jface.text.BadLocationException; |
| 113 |
import org.eclipse.jface.text.DefaultInformationControl; |
|
|
| 114 |
import org.eclipse.jface.text.DefaultLineTracker; |
113 |
import org.eclipse.jface.text.DefaultLineTracker; |
| 115 |
import org.eclipse.jface.text.DocumentEvent; |
114 |
import org.eclipse.jface.text.DocumentEvent; |
| 116 |
import org.eclipse.jface.text.IDocument; |
115 |
import org.eclipse.jface.text.IDocument; |
| 117 |
import org.eclipse.jface.text.IDocumentListener; |
116 |
import org.eclipse.jface.text.IDocumentListener; |
| 118 |
import org.eclipse.jface.text.IFindReplaceTarget; |
117 |
import org.eclipse.jface.text.IFindReplaceTarget; |
| 119 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
118 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
| 120 |
import org.eclipse.jface.text.IInformationControl; |
|
|
| 121 |
import org.eclipse.jface.text.IInformationControlCreator; |
119 |
import org.eclipse.jface.text.IInformationControlCreator; |
| 122 |
import org.eclipse.jface.text.IMarkRegionTarget; |
120 |
import org.eclipse.jface.text.IMarkRegionTarget; |
| 123 |
import org.eclipse.jface.text.IRegion; |
121 |
import org.eclipse.jface.text.IRegion; |
|
Lines 147-155
Link Here
|
| 147 |
import org.eclipse.jface.text.ITextViewerExtension8.EnrichMode; |
145 |
import org.eclipse.jface.text.ITextViewerExtension8.EnrichMode; |
| 148 |
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; |
146 |
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; |
| 149 |
import org.eclipse.jface.text.information.IInformationProvider; |
147 |
import org.eclipse.jface.text.information.IInformationProvider; |
| 150 |
import org.eclipse.jface.text.information.IInformationProviderExtension; |
|
|
| 151 |
import org.eclipse.jface.text.information.IInformationProviderExtension2; |
148 |
import org.eclipse.jface.text.information.IInformationProviderExtension2; |
| 152 |
import org.eclipse.jface.text.information.InformationPresenter; |
|
|
| 153 |
import org.eclipse.jface.text.link.LinkedModeModel; |
149 |
import org.eclipse.jface.text.link.LinkedModeModel; |
| 154 |
import org.eclipse.jface.text.link.LinkedPosition; |
150 |
import org.eclipse.jface.text.link.LinkedPosition; |
| 155 |
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; |
151 |
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; |
|
Lines 157-165
Link Here
|
| 157 |
import org.eclipse.jface.text.source.Annotation; |
153 |
import org.eclipse.jface.text.source.Annotation; |
| 158 |
import org.eclipse.jface.text.source.CompositeRuler; |
154 |
import org.eclipse.jface.text.source.CompositeRuler; |
| 159 |
import org.eclipse.jface.text.source.IAnnotationHover; |
155 |
import org.eclipse.jface.text.source.IAnnotationHover; |
| 160 |
import org.eclipse.jface.text.source.IAnnotationHoverExtension; |
|
|
| 161 |
import org.eclipse.jface.text.source.IAnnotationModel; |
156 |
import org.eclipse.jface.text.source.IAnnotationModel; |
| 162 |
import org.eclipse.jface.text.source.ILineRange; |
|
|
| 163 |
import org.eclipse.jface.text.source.ISourceViewer; |
157 |
import org.eclipse.jface.text.source.ISourceViewer; |
| 164 |
import org.eclipse.jface.text.source.ISourceViewerExtension3; |
158 |
import org.eclipse.jface.text.source.ISourceViewerExtension3; |
| 165 |
import org.eclipse.jface.text.source.ISourceViewerExtension4; |
159 |
import org.eclipse.jface.text.source.ISourceViewerExtension4; |
|
Lines 202-207
Link Here
|
| 202 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
196 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
| 203 |
import org.eclipse.ui.dnd.IDragAndDropService; |
197 |
import org.eclipse.ui.dnd.IDragAndDropService; |
| 204 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
198 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
|
|
199 |
import org.eclipse.ui.internal.texteditor.FocusedInformationPresenter; |
| 205 |
import org.eclipse.ui.internal.texteditor.NLSUtility; |
200 |
import org.eclipse.ui.internal.texteditor.NLSUtility; |
| 206 |
import org.eclipse.ui.internal.texteditor.TextEditorPlugin; |
201 |
import org.eclipse.ui.internal.texteditor.TextEditorPlugin; |
| 207 |
import org.eclipse.ui.internal.texteditor.rulers.StringSetSerializer; |
202 |
import org.eclipse.ui.internal.texteditor.rulers.StringSetSerializer; |
|
Lines 1844-1894
Link Here
|
| 1844 |
|
1839 |
|
| 1845 |
|
1840 |
|
| 1846 |
/** |
1841 |
/** |
| 1847 |
* Information provider used to present focusable information shells. |
|
|
| 1848 |
* |
| 1849 |
* @since 3.3 |
| 1850 |
*/ |
| 1851 |
private static final class InformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 { |
| 1852 |
|
| 1853 |
private IRegion fHoverRegion; |
| 1854 |
private Object fHoverInfo; |
| 1855 |
private IInformationControlCreator fControlCreator; |
| 1856 |
|
| 1857 |
InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator) { |
| 1858 |
fHoverRegion= hoverRegion; |
| 1859 |
fHoverInfo= hoverInfo; |
| 1860 |
fControlCreator= controlCreator; |
| 1861 |
} |
| 1862 |
/* |
| 1863 |
* @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int) |
| 1864 |
*/ |
| 1865 |
public IRegion getSubject(ITextViewer textViewer, int invocationOffset) { |
| 1866 |
return fHoverRegion; |
| 1867 |
} |
| 1868 |
/** |
| 1869 |
* {@inheritDoc} |
| 1870 |
* |
| 1871 |
* @deprecated As of 2.1, replaced by {@link IInformationProviderExtension#getInformation2(ITextViewer, IRegion)} |
| 1872 |
*/ |
| 1873 |
public String getInformation(ITextViewer textViewer, IRegion subject) { |
| 1874 |
return fHoverInfo == null ? null : fHoverInfo.toString(); |
| 1875 |
} |
| 1876 |
/* |
| 1877 |
* @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) |
| 1878 |
* @since 3.2 |
| 1879 |
*/ |
| 1880 |
public Object getInformation2(ITextViewer textViewer, IRegion subject) { |
| 1881 |
return fHoverInfo; |
| 1882 |
} |
| 1883 |
/* |
| 1884 |
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator() |
| 1885 |
*/ |
| 1886 |
public IInformationControlCreator getInformationPresenterControlCreator() { |
| 1887 |
return fControlCreator; |
| 1888 |
} |
| 1889 |
} |
| 1890 |
|
| 1891 |
/** |
| 1892 |
* This action behaves in two different ways: If there is no current text |
1842 |
* This action behaves in two different ways: If there is no current text |
| 1893 |
* hover, the javadoc is displayed using information presenter. If there is |
1843 |
* hover, the javadoc is displayed using information presenter. If there is |
| 1894 |
* a current text hover, it is converted into a information presenter in |
1844 |
* a current text hover, it is converted into a information presenter in |
|
Lines 1943-1949
Link Here
|
| 1943 |
if (sourceViewer instanceof ISourceViewerExtension3) { |
1893 |
if (sourceViewer instanceof ISourceViewerExtension3) { |
| 1944 |
// does an annotation hover exist? |
1894 |
// does an annotation hover exist? |
| 1945 |
IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); |
1895 |
IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); |
| 1946 |
if (annotationHover != null && makeAnnotationHoverFocusable(sourceViewer, annotationHover)) |
1896 |
if (annotationHover != null && makeAnnotationHoverFocusable(annotationHover)) |
| 1947 |
return; |
1897 |
return; |
| 1948 |
} |
1898 |
} |
| 1949 |
|
1899 |
|
|
Lines 1976-1982
Link Here
|
| 1976 |
if (textHover instanceof IInformationProviderExtension2) // this is conceptually wrong, but left here for backwards compatibility |
1926 |
if (textHover instanceof IInformationProviderExtension2) // this is conceptually wrong, but left here for backwards compatibility |
| 1977 |
controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator(); |
1927 |
controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator(); |
| 1978 |
|
1928 |
|
| 1979 |
IInformationProvider informationProvider= new InformationProvider(hoverRegion, hoverInfo, controlCreator); |
1929 |
IInformationProvider informationProvider= new FocusedInformationPresenter.InformationProvider(hoverRegion, hoverInfo, controlCreator); |
| 1980 |
|
1930 |
|
| 1981 |
fInformationPresenter.setOffset(offset); |
1931 |
fInformationPresenter.setOffset(offset); |
| 1982 |
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM); |
1932 |
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM); |
|
Lines 1995-2049
Link Here
|
| 1995 |
/** |
1945 |
/** |
| 1996 |
* Tries to make an annotation hover focusable (or "sticky"). |
1946 |
* Tries to make an annotation hover focusable (or "sticky"). |
| 1997 |
* |
1947 |
* |
| 1998 |
* @param sourceViewer the source viewer to display the hover over |
|
|
| 1999 |
* @param annotationHover the hover to make focusable |
1948 |
* @param annotationHover the hover to make focusable |
| 2000 |
* @return <code>true</code> if successful, <code>false</code> otherwise |
1949 |
* @return <code>true</code> if successful, <code>false</code> otherwise |
| 2001 |
*/ |
1950 |
*/ |
| 2002 |
private boolean makeAnnotationHoverFocusable(ISourceViewer sourceViewer, IAnnotationHover annotationHover) { |
1951 |
private boolean makeAnnotationHoverFocusable(IAnnotationHover annotationHover) { |
| 2003 |
IVerticalRulerInfo info= getVerticalRuler(); |
1952 |
IVerticalRulerInfo info= getVerticalRuler(); |
| 2004 |
int line= info.getLineOfLastMouseButtonActivity(); |
1953 |
int line= info.getLineOfLastMouseButtonActivity(); |
| 2005 |
if (line == -1) |
1954 |
if (line == -1) |
| 2006 |
return false; |
1955 |
return false; |
| 2007 |
|
1956 |
|
| 2008 |
try { |
1957 |
return fInformationPresenter.openFocusedAnnotationHover(annotationHover, line); |
| 2009 |
|
|
|
| 2010 |
// compute the hover information |
| 2011 |
Object hoverInfo; |
| 2012 |
if (annotationHover instanceof IAnnotationHoverExtension) { |
| 2013 |
IAnnotationHoverExtension extension= (IAnnotationHoverExtension) annotationHover; |
| 2014 |
ILineRange hoverLineRange= extension.getHoverLineRange(sourceViewer, line); |
| 2015 |
if (hoverLineRange == null) |
| 2016 |
return false; |
| 2017 |
final int maxVisibleLines= Integer.MAX_VALUE; // allow any number of lines being displayed, as we support scrolling |
| 2018 |
hoverInfo= extension.getHoverInfo(sourceViewer, hoverLineRange, maxVisibleLines); |
| 2019 |
} else { |
| 2020 |
hoverInfo= annotationHover.getHoverInfo(sourceViewer, line); |
| 2021 |
} |
| 2022 |
|
| 2023 |
// hover region: the beginning of the concerned line to place the control right over the line |
| 2024 |
IDocument document= sourceViewer.getDocument(); |
| 2025 |
int offset= document.getLineOffset(line); |
| 2026 |
String contentType= TextUtilities.getContentType(document, getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()), offset, true); |
| 2027 |
|
| 2028 |
IInformationControlCreator controlCreator= null; |
| 2029 |
if (annotationHover instanceof IInformationProviderExtension2) // this is undocumented, but left here for backwards compatibility |
| 2030 |
controlCreator= ((IInformationProviderExtension2) annotationHover).getInformationPresenterControlCreator(); |
| 2031 |
else if (annotationHover instanceof IAnnotationHoverExtension) |
| 2032 |
controlCreator= ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator(); |
| 2033 |
|
| 2034 |
IInformationProvider informationProvider= new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator); |
| 2035 |
|
| 2036 |
fInformationPresenter.setOffset(offset); |
| 2037 |
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT); |
| 2038 |
fInformationPresenter.setMargins(4, 0); // AnnotationBarHoverManager sets (5,0), minus SourceViewer.GAP_SIZE_1 |
| 2039 |
fInformationPresenter.setInformationProvider(informationProvider, contentType); |
| 2040 |
fInformationPresenter.showInformation(); |
| 2041 |
|
| 2042 |
return true; |
| 2043 |
|
| 2044 |
} catch (BadLocationException e) { |
| 2045 |
return false; |
| 2046 |
} |
| 2047 |
} |
1958 |
} |
| 2048 |
|
1959 |
|
| 2049 |
// modified version from TextViewer |
1960 |
// modified version from TextViewer |
|
Lines 2590-2596
Link Here
|
| 2590 |
* The information presenter. |
2501 |
* The information presenter. |
| 2591 |
* @since 3.3 |
2502 |
* @since 3.3 |
| 2592 |
*/ |
2503 |
*/ |
| 2593 |
private InformationPresenter fInformationPresenter; |
2504 |
private FocusedInformationPresenter fInformationPresenter; |
| 2594 |
|
2505 |
|
| 2595 |
/** |
2506 |
/** |
| 2596 |
* Tells whether this editor has been activated at least once. |
2507 |
* Tells whether this editor has been activated at least once. |
|
Lines 3477-3494
Link Here
|
| 3477 |
if (ruler instanceof CompositeRuler) |
3388 |
if (ruler instanceof CompositeRuler) |
| 3478 |
updateContributedRulerColumns((CompositeRuler) ruler); |
3389 |
updateContributedRulerColumns((CompositeRuler) ruler); |
| 3479 |
|
3390 |
|
| 3480 |
IInformationControlCreator informationControlCreator= new IInformationControlCreator() { |
3391 |
fInformationPresenter= new FocusedInformationPresenter(getSourceViewer(), getSourceViewerConfiguration()); |
| 3481 |
public IInformationControl createInformationControl(Shell shell) { |
|
|
| 3482 |
return new DefaultInformationControl(shell, true); |
| 3483 |
} |
| 3484 |
}; |
| 3485 |
|
| 3486 |
fInformationPresenter= new InformationPresenter(informationControlCreator); |
| 3487 |
// sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS |
| 3488 |
fInformationPresenter.setSizeConstraints(100, 12, true, true); |
| 3489 |
fInformationPresenter.install(getSourceViewer()); |
| 3490 |
fInformationPresenter.setDocumentPartitioning(getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer())); |
| 3491 |
|
| 3492 |
} |
3392 |
} |
| 3493 |
|
3393 |
|
| 3494 |
/** |
3394 |
/** |