@SuppressWarnings("deprecation") public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (currentHover != null) { if (currentHover instanceof ITextHoverExtension2) return ((ITextHoverExtension2) currentHover).getHoverInfo2(textViewer, hoverRegion); else { return currentHover.getHoverInfo(textViewer, hoverRegion); } } return null; }
@SuppressWarnings("deprecation") public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (activeTextHover != null) { Object info = null; if (activeTextHover instanceof AbstractCommonTextHover) { AbstractCommonTextHover commonHover = (AbstractCommonTextHover) activeTextHover; commonHover.setEditor(getEditor()); } if (activeTextHover instanceof ITextHoverExtension2) { info = ((ITextHoverExtension2) activeTextHover).getHoverInfo2(textViewer, hoverRegion); } else { info = activeTextHover.getHoverInfo(textViewer, hoverRegion); } if (info != null) { return info; } } String defaultInfo = super.getHoverInfo(textViewer, hoverRegion); if (defaultInfo != null) { // wrap it in a SimpleTextHover so it will look the same as other hovers (i.e. use the theme colors, // etc.) return new SimpleTextHover(defaultInfo, null).getHoverInfo2(textViewer, hoverRegion); } return null; }
@SuppressWarnings("deprecation") @Override public IRegion getHoverRegion(ITextViewer textViewer, int offset) { activeTextHover = null; List<TextHoverDescriptor> descriptors = getEnabledTextHoverDescriptors(textViewer, offset); for (TextHoverDescriptor descriptor : descriptors) { ITextHover textHover = descriptor.createTextHover(); IRegion region = null; if (textHover != null) { region = textHover.getHoverRegion(textViewer, offset); } if (region != null) { if (descriptors.size() > 1) { if (textHover instanceof ITextHoverExtension2) { if (((ITextHoverExtension2) textHover).getHoverInfo2(textViewer, region) == null) { continue; } } else if (textHover.getHoverInfo(textViewer, region) == null) { continue; } } activeTextHover = textHover; return region; } } return super.getHoverRegion(textViewer, offset); }
/** * Returns the information which should be presented when a hover or persistent popup is shown * for the specified hover region. * * @param textViewer the viewer on which the hover popup should be shown * @param hoverRegion the text range in the viewer which is used to determine the hover display * information * @param forInformationProvider <code>true</code> iff the hover info is requested by the * information presenter. In this case, the method only considers text hovers for * which a proper IInformationControlCreator is available that can supply focusable * and resizable information controls. * * @return the hover popup display information, or <code>null</code> if none available * * @see ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion) * @since 3.8 */ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion, boolean forInformationProvider) { checkTextHovers(); fBestHover= null; if (fInstantiatedTextHovers == null) return null; for (Iterator<IJavaEditorTextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) { ITextHover hover= iterator.next(); if (hover == null) continue; if (hover instanceof ITextHoverExtension2) { Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion); if (info != null && !(forInformationProvider && getInformationPresenterControlCreator(hover) == null)) { fBestHover= hover; return info; } } else { String s= hover.getHoverInfo(textViewer, hoverRegion); if (s != null && s.trim().length() > 0) { fBestHover= hover; return s; } } } return null; }
@Override public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (ensureHoverCreated()) { if (fHover instanceof ITextHoverExtension2) return ((ITextHoverExtension2) fHover).getHoverInfo2(textViewer, hoverRegion); else return fHover.getHoverInfo(textViewer, hoverRegion); } return null; }
@SuppressWarnings("deprecation") @Override public Object getHoverInfo(ISourceBuffer sourceBuffer, IRegion hoverRegion, ITextViewer textViewer) { fDelegate = getDelegate(); if (fDelegate instanceof ITextHoverExtension2) { return ((ITextHoverExtension2) fDelegate).getHoverInfo2(textViewer, hoverRegion); } // fall back to legacy method if (fDelegate != null) { return fDelegate.getHoverInfo(textViewer, hoverRegion); } return null; }