|
Lines 109-122
Link Here
|
| 109 |
|
109 |
|
| 110 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
110 |
import org.eclipse.jface.text.AbstractInformationControlManager; |
| 111 |
import org.eclipse.jface.text.BadLocationException; |
111 |
import org.eclipse.jface.text.BadLocationException; |
| 112 |
import org.eclipse.jface.text.DefaultInformationControl; |
|
|
| 113 |
import org.eclipse.jface.text.DefaultLineTracker; |
112 |
import org.eclipse.jface.text.DefaultLineTracker; |
| 114 |
import org.eclipse.jface.text.DocumentEvent; |
113 |
import org.eclipse.jface.text.DocumentEvent; |
| 115 |
import org.eclipse.jface.text.IDocument; |
114 |
import org.eclipse.jface.text.IDocument; |
| 116 |
import org.eclipse.jface.text.IDocumentListener; |
115 |
import org.eclipse.jface.text.IDocumentListener; |
| 117 |
import org.eclipse.jface.text.IFindReplaceTarget; |
116 |
import org.eclipse.jface.text.IFindReplaceTarget; |
| 118 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
117 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
| 119 |
import org.eclipse.jface.text.IInformationControl; |
|
|
| 120 |
import org.eclipse.jface.text.IInformationControlCreator; |
118 |
import org.eclipse.jface.text.IInformationControlCreator; |
| 121 |
import org.eclipse.jface.text.IMarkRegionTarget; |
119 |
import org.eclipse.jface.text.IMarkRegionTarget; |
| 122 |
import org.eclipse.jface.text.IRegion; |
120 |
import org.eclipse.jface.text.IRegion; |
|
Lines 130-136
Link Here
|
| 130 |
import org.eclipse.jface.text.ITextViewer; |
128 |
import org.eclipse.jface.text.ITextViewer; |
| 131 |
import org.eclipse.jface.text.ITextViewerExtension; |
129 |
import org.eclipse.jface.text.ITextViewerExtension; |
| 132 |
import org.eclipse.jface.text.ITextViewerExtension2; |
130 |
import org.eclipse.jface.text.ITextViewerExtension2; |
| 133 |
import org.eclipse.jface.text.ITextViewerExtension4; |
|
|
| 134 |
import org.eclipse.jface.text.ITextViewerExtension5; |
131 |
import org.eclipse.jface.text.ITextViewerExtension5; |
| 135 |
import org.eclipse.jface.text.ITextViewerExtension6; |
132 |
import org.eclipse.jface.text.ITextViewerExtension6; |
| 136 |
import org.eclipse.jface.text.ITextViewerExtension7; |
133 |
import org.eclipse.jface.text.ITextViewerExtension7; |
|
Lines 146-154
Link Here
|
| 146 |
import org.eclipse.jface.text.ITextViewerExtension8.EnrichMode; |
143 |
import org.eclipse.jface.text.ITextViewerExtension8.EnrichMode; |
| 147 |
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; |
144 |
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; |
| 148 |
import org.eclipse.jface.text.information.IInformationProvider; |
145 |
import org.eclipse.jface.text.information.IInformationProvider; |
| 149 |
import org.eclipse.jface.text.information.IInformationProviderExtension; |
|
|
| 150 |
import org.eclipse.jface.text.information.IInformationProviderExtension2; |
146 |
import org.eclipse.jface.text.information.IInformationProviderExtension2; |
| 151 |
import org.eclipse.jface.text.information.InformationPresenter; |
|
|
| 152 |
import org.eclipse.jface.text.link.LinkedModeModel; |
147 |
import org.eclipse.jface.text.link.LinkedModeModel; |
| 153 |
import org.eclipse.jface.text.link.LinkedPosition; |
148 |
import org.eclipse.jface.text.link.LinkedPosition; |
| 154 |
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; |
149 |
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; |
|
Lines 156-164
Link Here
|
| 156 |
import org.eclipse.jface.text.source.Annotation; |
151 |
import org.eclipse.jface.text.source.Annotation; |
| 157 |
import org.eclipse.jface.text.source.CompositeRuler; |
152 |
import org.eclipse.jface.text.source.CompositeRuler; |
| 158 |
import org.eclipse.jface.text.source.IAnnotationHover; |
153 |
import org.eclipse.jface.text.source.IAnnotationHover; |
| 159 |
import org.eclipse.jface.text.source.IAnnotationHoverExtension; |
|
|
| 160 |
import org.eclipse.jface.text.source.IAnnotationModel; |
154 |
import org.eclipse.jface.text.source.IAnnotationModel; |
| 161 |
import org.eclipse.jface.text.source.ILineRange; |
|
|
| 162 |
import org.eclipse.jface.text.source.ISourceViewer; |
155 |
import org.eclipse.jface.text.source.ISourceViewer; |
| 163 |
import org.eclipse.jface.text.source.ISourceViewerExtension3; |
156 |
import org.eclipse.jface.text.source.ISourceViewerExtension3; |
| 164 |
import org.eclipse.jface.text.source.ISourceViewerExtension4; |
157 |
import org.eclipse.jface.text.source.ISourceViewerExtension4; |
|
Lines 201-206
Link Here
|
| 201 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
194 |
import org.eclipse.ui.dialogs.PropertyDialogAction; |
| 202 |
import org.eclipse.ui.dnd.IDragAndDropService; |
195 |
import org.eclipse.ui.dnd.IDragAndDropService; |
| 203 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
196 |
import org.eclipse.ui.internal.texteditor.EditPosition; |
|
|
197 |
import org.eclipse.ui.internal.texteditor.FocusedInformationPresenter; |
| 204 |
import org.eclipse.ui.internal.texteditor.NLSUtility; |
198 |
import org.eclipse.ui.internal.texteditor.NLSUtility; |
| 205 |
import org.eclipse.ui.internal.texteditor.TextEditorPlugin; |
199 |
import org.eclipse.ui.internal.texteditor.TextEditorPlugin; |
| 206 |
import org.eclipse.ui.internal.texteditor.rulers.StringSetSerializer; |
200 |
import org.eclipse.ui.internal.texteditor.rulers.StringSetSerializer; |
|
Lines 1840-1890
Link Here
|
| 1840 |
|
1834 |
|
| 1841 |
|
1835 |
|
| 1842 |
/** |
1836 |
/** |
| 1843 |
* Information provider used to present focusable information shells. |
|
|
| 1844 |
* |
| 1845 |
* @since 3.3 |
| 1846 |
*/ |
| 1847 |
private static final class InformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 { |
| 1848 |
|
| 1849 |
private IRegion fHoverRegion; |
| 1850 |
private Object fHoverInfo; |
| 1851 |
private IInformationControlCreator fControlCreator; |
| 1852 |
|
| 1853 |
InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator) { |
| 1854 |
fHoverRegion= hoverRegion; |
| 1855 |
fHoverInfo= hoverInfo; |
| 1856 |
fControlCreator= controlCreator; |
| 1857 |
} |
| 1858 |
/* |
| 1859 |
* @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int) |
| 1860 |
*/ |
| 1861 |
public IRegion getSubject(ITextViewer textViewer, int invocationOffset) { |
| 1862 |
return fHoverRegion; |
| 1863 |
} |
| 1864 |
/** |
| 1865 |
* {@inheritDoc} |
| 1866 |
* |
| 1867 |
* @deprecated As of 2.1, replaced by {@link IInformationProviderExtension#getInformation2(ITextViewer, IRegion)} |
| 1868 |
*/ |
| 1869 |
public String getInformation(ITextViewer textViewer, IRegion subject) { |
| 1870 |
return fHoverInfo == null ? null : fHoverInfo.toString(); |
| 1871 |
} |
| 1872 |
/* |
| 1873 |
* @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) |
| 1874 |
* @since 3.2 |
| 1875 |
*/ |
| 1876 |
public Object getInformation2(ITextViewer textViewer, IRegion subject) { |
| 1877 |
return fHoverInfo; |
| 1878 |
} |
| 1879 |
/* |
| 1880 |
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator() |
| 1881 |
*/ |
| 1882 |
public IInformationControlCreator getInformationPresenterControlCreator() { |
| 1883 |
return fControlCreator; |
| 1884 |
} |
| 1885 |
} |
| 1886 |
|
| 1887 |
/** |
| 1888 |
* This action behaves in two different ways: If there is no current text |
1837 |
* This action behaves in two different ways: If there is no current text |
| 1889 |
* hover, the javadoc is displayed using information presenter. If there is |
1838 |
* hover, the javadoc is displayed using information presenter. If there is |
| 1890 |
* a current text hover, it is converted into a information presenter in |
1839 |
* a current text hover, it is converted into a information presenter in |
|
Lines 1923-1933
Link Here
|
| 1923 |
return; |
1872 |
return; |
| 1924 |
} |
1873 |
} |
| 1925 |
|
1874 |
|
| 1926 |
if (sourceViewer instanceof ITextViewerExtension4) { |
1875 |
// if (sourceViewer instanceof ITextViewerExtension4) { |
| 1927 |
ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; |
1876 |
// ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; |
| 1928 |
if (extension4.moveFocusToWidgetToken()) |
1877 |
// if (extension4.moveFocusToWidgetToken()) |
| 1929 |
return; |
1878 |
// return; |
| 1930 |
} |
1879 |
// } |
| 1931 |
|
1880 |
|
| 1932 |
if (sourceViewer instanceof ITextViewerExtension2) { |
1881 |
if (sourceViewer instanceof ITextViewerExtension2) { |
| 1933 |
// does a text hover exist? |
1882 |
// does a text hover exist? |
|
Lines 1939-1945
Link Here
|
| 1939 |
if (sourceViewer instanceof ISourceViewerExtension3) { |
1888 |
if (sourceViewer instanceof ISourceViewerExtension3) { |
| 1940 |
// does an annotation hover exist? |
1889 |
// does an annotation hover exist? |
| 1941 |
IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); |
1890 |
IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); |
| 1942 |
if (annotationHover != null && makeAnnotationHoverFocusable(sourceViewer, annotationHover)) |
1891 |
if (annotationHover != null && makeAnnotationHoverFocusable(annotationHover)) |
| 1943 |
return; |
1892 |
return; |
| 1944 |
} |
1893 |
} |
| 1945 |
|
1894 |
|
|
Lines 1972-1985
Link Here
|
| 1972 |
if (textHover instanceof IInformationProviderExtension2) // this is conceptually wrong, but left here for backwards compatibility |
1921 |
if (textHover instanceof IInformationProviderExtension2) // this is conceptually wrong, but left here for backwards compatibility |
| 1973 |
controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator(); |
1922 |
controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator(); |
| 1974 |
|
1923 |
|
| 1975 |
IInformationProvider informationProvider= new InformationProvider(hoverRegion, hoverInfo, controlCreator); |
1924 |
IInformationProvider informationProvider= new FocusedInformationPresenter.InformationProvider(hoverRegion, hoverInfo, controlCreator); |
| 1976 |
|
1925 |
|
| 1977 |
fInformationPresenter.setOffset(offset); |
1926 |
FocusedInformationPresenter informationPresenter= getInformationPresenter(); |
| 1978 |
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM); |
1927 |
informationPresenter.setOffset(offset); |
| 1979 |
fInformationPresenter.setMargins(6, 6); // default values from AbstractInformationControlManager |
1928 |
informationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM); |
|
|
1929 |
informationPresenter.setMargins(6, 6); // default values from AbstractInformationControlManager |
| 1980 |
String contentType= TextUtilities.getContentType(sourceViewer.getDocument(), getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()), offset, true); |
1930 |
String contentType= TextUtilities.getContentType(sourceViewer.getDocument(), getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()), offset, true); |
| 1981 |
fInformationPresenter.setInformationProvider(informationProvider, contentType); |
1931 |
informationPresenter.setInformationProvider(informationProvider, contentType); |
| 1982 |
fInformationPresenter.showInformation(); |
1932 |
informationPresenter.showInformation(); |
| 1983 |
|
1933 |
|
| 1984 |
return true; |
1934 |
return true; |
| 1985 |
|
1935 |
|
|
Lines 1991-2046
Link Here
|
| 1991 |
/** |
1941 |
/** |
| 1992 |
* Tries to make an annotation hover focusable (or "sticky"). |
1942 |
* Tries to make an annotation hover focusable (or "sticky"). |
| 1993 |
* |
1943 |
* |
| 1994 |
* @param sourceViewer the source viewer to display the hover over |
|
|
| 1995 |
* @param annotationHover the hover to make focusable |
1944 |
* @param annotationHover the hover to make focusable |
| 1996 |
* @return <code>true</code> if successful, <code>false</code> otherwise |
1945 |
* @return <code>true</code> if successful, <code>false</code> otherwise |
| 1997 |
*/ |
1946 |
*/ |
| 1998 |
private boolean makeAnnotationHoverFocusable(ISourceViewer sourceViewer, IAnnotationHover annotationHover) { |
1947 |
private boolean makeAnnotationHoverFocusable(IAnnotationHover annotationHover) { |
| 1999 |
IVerticalRulerInfo info= getVerticalRuler(); |
1948 |
IVerticalRulerInfo info= getVerticalRuler(); |
| 2000 |
int line= info.getLineOfLastMouseButtonActivity(); |
1949 |
int line= info.getLineOfLastMouseButtonActivity(); |
| 2001 |
if (line == -1) |
1950 |
if (line == -1) |
| 2002 |
return false; |
1951 |
return false; |
| 2003 |
|
1952 |
|
| 2004 |
try { |
1953 |
return getInformationPresenter().openFocusedAnnotationHover(annotationHover, line); |
| 2005 |
|
|
|
| 2006 |
// compute the hover information |
| 2007 |
Object hoverInfo; |
| 2008 |
if (annotationHover instanceof IAnnotationHoverExtension) { |
| 2009 |
IAnnotationHoverExtension extension= (IAnnotationHoverExtension) annotationHover; |
| 2010 |
ILineRange hoverLineRange= extension.getHoverLineRange(sourceViewer, line); |
| 2011 |
if (hoverLineRange == null) |
| 2012 |
return false; |
| 2013 |
final int maxVisibleLines= Integer.MAX_VALUE; // allow any number of lines being displayed, as we support scrolling |
| 2014 |
hoverInfo= extension.getHoverInfo(sourceViewer, hoverLineRange, maxVisibleLines); |
| 2015 |
} else { |
| 2016 |
hoverInfo= annotationHover.getHoverInfo(sourceViewer, line); |
| 2017 |
} |
| 2018 |
|
| 2019 |
// hover region: the beginning of the concerned line to place the control right over the line |
| 2020 |
IDocument document= sourceViewer.getDocument(); |
| 2021 |
int offset= document.getLineOffset(line); |
| 2022 |
String contentType= TextUtilities.getContentType(document, getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()), offset, true); |
| 2023 |
|
| 2024 |
IInformationControlCreator controlCreator= null; |
| 2025 |
if (annotationHover instanceof IInformationProviderExtension2) // this is undocumented, but left here for backwards compatibility |
| 2026 |
controlCreator= ((IInformationProviderExtension2) annotationHover).getInformationPresenterControlCreator(); |
| 2027 |
else if (annotationHover instanceof IAnnotationHoverExtension) |
| 2028 |
controlCreator= ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator(); |
| 2029 |
|
| 2030 |
IInformationProvider informationProvider= new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator); |
| 2031 |
|
| 2032 |
fInformationPresenter.setOffset(offset); |
| 2033 |
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT); |
| 2034 |
fInformationPresenter.setMargins(4, 0); // AnnotationBarHoverManager sets (5,0), minus SourceViewer.GAP_SIZE_1 |
| 2035 |
fInformationPresenter.setInformationProvider(informationProvider, contentType); |
| 2036 |
fInformationPresenter.showInformation(); |
| 2037 |
|
| 2038 |
return true; |
| 2039 |
|
| 2040 |
} catch (BadLocationException e) { |
| 2041 |
return false; |
| 2042 |
} |
| 2043 |
} |
1954 |
} |
|
|
1955 |
|
| 1956 |
/** |
| 1957 |
* Returns the information presenter (creates it if necessary). |
| 1958 |
* |
| 1959 |
* @return the information presenter |
| 1960 |
* @since 3.6 |
| 1961 |
*/ |
| 1962 |
private FocusedInformationPresenter getInformationPresenter() { |
| 1963 |
if (fInformationPresenter == null) { |
| 1964 |
fInformationPresenter= new FocusedInformationPresenter(getSourceViewer(), getSourceViewerConfiguration()); |
| 1965 |
} |
| 1966 |
return fInformationPresenter; |
| 1967 |
} |
| 2044 |
|
1968 |
|
| 2045 |
// modified version from TextViewer |
1969 |
// modified version from TextViewer |
| 2046 |
private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) { |
1970 |
private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) { |
|
Lines 2066-2072
Link Here
|
| 2066 |
} catch (IllegalArgumentException e) { |
1990 |
} catch (IllegalArgumentException e) { |
| 2067 |
return -1; |
1991 |
return -1; |
| 2068 |
} |
1992 |
} |
| 2069 |
|
|
|
| 2070 |
} |
1993 |
} |
| 2071 |
} |
1994 |
} |
| 2072 |
|
1995 |
|
|
Lines 2583-2592
Link Here
|
| 2583 |
*/ |
2506 |
*/ |
| 2584 |
private Object fTextDragAndDropToken; |
2507 |
private Object fTextDragAndDropToken; |
| 2585 |
/** |
2508 |
/** |
| 2586 |
* The information presenter. |
2509 |
* The information presenter, may be <code>null</code>. |
| 2587 |
* @since 3.3 |
2510 |
* @since 3.3 |
| 2588 |
*/ |
2511 |
*/ |
| 2589 |
private InformationPresenter fInformationPresenter; |
2512 |
private FocusedInformationPresenter fInformationPresenter; |
| 2590 |
|
2513 |
|
| 2591 |
/** |
2514 |
/** |
| 2592 |
* Tells whether this editor has been activated at least once. |
2515 |
* Tells whether this editor has been activated at least once. |
|
Lines 3472-3490
Link Here
|
| 3472 |
IVerticalRuler ruler= getVerticalRuler(); |
3395 |
IVerticalRuler ruler= getVerticalRuler(); |
| 3473 |
if (ruler instanceof CompositeRuler) |
3396 |
if (ruler instanceof CompositeRuler) |
| 3474 |
updateContributedRulerColumns((CompositeRuler) ruler); |
3397 |
updateContributedRulerColumns((CompositeRuler) ruler); |
| 3475 |
|
|
|
| 3476 |
IInformationControlCreator informationControlCreator= new IInformationControlCreator() { |
| 3477 |
public IInformationControl createInformationControl(Shell shell) { |
| 3478 |
return new DefaultInformationControl(shell, true); |
| 3479 |
} |
| 3480 |
}; |
| 3481 |
|
| 3482 |
fInformationPresenter= new InformationPresenter(informationControlCreator); |
| 3483 |
// sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS |
| 3484 |
fInformationPresenter.setSizeConstraints(100, 12, true, true); |
| 3485 |
fInformationPresenter.install(getSourceViewer()); |
| 3486 |
fInformationPresenter.setDocumentPartitioning(getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer())); |
| 3487 |
|
| 3488 |
} |
3398 |
} |
| 3489 |
|
3399 |
|
| 3490 |
/** |
3400 |
/** |
|
Lines 4406-4411
Link Here
|
| 4406 |
fKeyBindingSupportForQuickAssistant.dispose(); |
4316 |
fKeyBindingSupportForQuickAssistant.dispose(); |
| 4407 |
fKeyBindingSupportForQuickAssistant= null; |
4317 |
fKeyBindingSupportForQuickAssistant= null; |
| 4408 |
} |
4318 |
} |
|
|
4319 |
|
| 4320 |
if (fInformationPresenter != null) { |
| 4321 |
fInformationPresenter.uninstall(); |
| 4322 |
fInformationPresenter= null; |
| 4323 |
} |
| 4409 |
|
4324 |
|
| 4410 |
super.dispose(); |
4325 |
super.dispose(); |
| 4411 |
} |
4326 |
} |