类org.eclipse.jface.text.ITextHover源码实例Demo

下面列出了怎么用org.eclipse.jface.text.ITextHover的API类实例代码及写法,或者点击链接到github查看源代码。

@SuppressWarnings("deprecation")
@Test public void testNullHoverList () {
	AbstractCompositeHover hover = new AbstractCompositeHover() {

		@Override
		protected List<ITextHover> createHovers() {
			return null;
		}
	};

	assertEquals (null, hover.getHovers());
	assertNull (hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
	assertNull (hover.getHoverControlCreator());
	assertNull (hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0,0)));
	assertNull (hover.getHoverInfo2(editor.getInternalSourceViewer(), new Region(0,0)));
}
 
@SuppressWarnings("deprecation")
@Test public void testEmptyHoverList () {
	AbstractCompositeHover hover = new AbstractCompositeHover() {

		@Override
		protected List<ITextHover> createHovers() {
			List<ITextHover> hovers = Lists.newArrayList();
			return hovers;
		}
	};

	assertEquals (0, hover.getHovers().size());
	assertNull (hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
	assertNull (hover.getHoverControlCreator());
	assertNull (hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0,0)));
	assertNull (hover.getHoverInfo2(editor.getInternalSourceViewer(), new Region(0,0)));
}
 
源代码3 项目: xtext-eclipse   文件: AbstractCompositeHover.java
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
	if (getHovers() != null) {
		for (ITextHover hover : getHovers()) {
			IRegion region = hover.getHoverRegion(textViewer, offset);
			if (region != null) {
				// We always take the first that answers with a region
				// In org.eclipse.xtext.ui.editor.hover.DefaultCompositeHover.createHovers() the AnnotationWithQuickFixesHover 
				// is always the first and answers with a region only when there is a problemmarker
				// In all other cases an instance of org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover is the next in the order.
				currentHover = hover;
				return region;
			}
		}
	}
	currentHover = null;
	return null;
}
 
源代码4 项目: xds-ide   文件: ModulaEditorTextHover.java
/**
   * {@inheritDoc}
   */
  @Override
  public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
// Check through the contributed hover providers.
for (ITextHover hoverContributer : hoverContributors) {
	@SuppressWarnings("deprecation")
	String hoverText = hoverContributer.getHoverInfo(textViewer,
			hoverRegion);

	if (hoverText != null) {
		lastReturnedHover = hoverContributer;

		return hoverText;
	}
}
      
      return String.valueOf(getHoverInfo2(textViewer, hoverRegion));
  }
 
源代码5 项目: gef   文件: DotHtmlLabelAdaptingTextHover.java
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
	HtmlOffsetPair html = htmlOffsetPair(offset, textViewer);
	if (html == null) {
		return super.getHoverRegion(textViewer, offset);
	}
	synchronized (sourceViewer) {
		try {
			sourceViewer.setDocument(
					DotEditorUtils.getDocument(injector, html.code));
		} catch (Exception e) {
			return super.getHoverRegion(textViewer, offset);
		}
		if (hover instanceof ITextHover) {
			IRegion htmlRegion = ((ITextHover) hover)
					.getHoverRegion(sourceViewer, offset - html.offset);
			if (htmlRegion == null) {
				return null;
			}
			return new Region(html.offset + htmlRegion.getOffset(),
					htmlRegion.getLength());
		}
	}
	return super.getHoverRegion(textViewer, offset);
}
 
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {

		checkTextHovers();
		fBestHover= null;

		if (fInstantiatedTextHovers == null)
			return null;

		for (Iterator<IJavaEditorTextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
			ITextHover hover= iterator.next();
			if (hover == null)
				continue;

			String s= hover.getHoverInfo(textViewer, hoverRegion);
			if (s != null && s.trim().length() > 0) {
				fBestHover= hover;
				return s;
			}
		}

		return null;
	}
 
源代码7 项目: xtext-eclipse   文件: AbstractCompositeHover.java
@Override
public void setSourceViewer(ISourceViewer sourceViewer) {
	if (getHovers() != null) {
		for (ITextHover hover : getHovers()) {
			if (hover instanceof ISourceViewerAware)
				((ISourceViewerAware) hover).setSourceViewer(sourceViewer);
		}
	}
}
 
源代码8 项目: xtext-eclipse   文件: DefaultCompositeHover.java
@Override
protected List<ITextHover> createHovers() {
	List<ITextHover> list = new ArrayList<ITextHover>();
	list.add (annotationHover);
	if(htmlHover instanceof ITextHover)
		list.add ((ITextHover) htmlHover);
	return list;
}
 
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	ITextHover hover = textHoverProvider.get();
	if (hover instanceof ISourceViewerAware) {
		((ISourceViewerAware) hover).setSourceViewer(sourceViewer);
	}
	return hover;
}
 
源代码10 项目: xds-ide   文件: ModulaEditorTextHover.java
public ModulaEditorTextHover(ITextEditor editor, ITextHover defaultHover, ResourceRegistry resourceRegistry) {
      this.editor = editor;
      if (editor != null) {
      	this.project = CoreEditorUtils.getIProjectFrom(editor.getEditorInput());
      }
      else{
      	this.project = null;
      }
      this.defaultHover = defaultHover;
      this.fDecorationColor = JFaceResources.getColorRegistry().get(JFacePreferences.DECORATIONS_COLOR);
      this.resourceRegistry = resourceRegistry;
      
ModulaEditorHoverRegistry.get().contributions().stream()
		.forEach(ModulaEditorTextHover::addContributer);
  }
 
源代码11 项目: xds-ide   文件: ModulaEditorTextHover.java
/**
   * {@inheritDoc}
   */
  @Override
  public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
// Overridden from ITextHoverExtension2. We try and return the richest
// help available; this
// means trying to call getHoverInfo2() on any contributors, and falling
// back on getHoverInfo().
lastReturnedHover = null;

// Check through the contributed hover providers.
for (ITextHover hoverContributer : hoverContributors) {
	if (hoverContributer instanceof ITextHoverExtension2) {
		Object hoverInfo = ((ITextHoverExtension2) hoverContributer)
				.getHoverInfo2(textViewer, hoverRegion);

		if (hoverInfo != null) {
			lastReturnedHover = hoverContributer;
			return hoverInfo;
		}
	} else {
		@SuppressWarnings("deprecation")
		String hoverText = hoverContributer.getHoverInfo(textViewer,
				hoverRegion);

		if (hoverText != null) {
			lastReturnedHover = hoverContributer;
			return hoverText;
		}
	}
}
      
      return getModulaDocHover(textViewer, hoverRegion);
  }
 
源代码12 项目: gef   文件: DotSourceViewerConfiguration.java
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer,
		String contentType) {
	if (contentType.equals(
			DotTerminalsTokenTypeToPartitionMapper.HTML_STRING_PARTITION)) {
		ITextHover hover = htmlHoverProvider.get();
		if (hover instanceof ISourceViewerAware) {
			((ISourceViewerAware) hover).setSourceViewer(sourceViewer);
		}
		return hover;
	}
	return super.getTextHover(sourceViewer, contentType);
}
 
源代码13 项目: tlaplus   文件: TLASourceViewerConfiguration.java
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	if (TLAPartitionScanner.TLA_PCAL.equals(contentType)) {
		return new PCalHover();
	}
	return new ToolboxHover();
}
 
源代码14 项目: tlaplus   文件: TLACoverageEditor.java
@Override
public ITextHover getTextHover(final ISourceViewer sourceViewer, String contentType) {
	return new DefaultTextHover(sourceViewer) {
		@Override
		public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
			return coverage.getHoverInfo(hoverRegion.getOffset());
		}
	};
}
 
@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);
}
 
源代码16 项目: APICloud-Studio   文件: TextHoverDescriptor.java
/**
 * Creates text hover
 * @return
 */
public ITextHover createTextHover() {
	try {
		return (ITextHover) configurationElement.createExecutableExtension(ATT_CLASS);
	} catch (CoreException e) {
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
	return null;
}
 
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
	JavaEditorTextHoverDescriptor[] hoverDescs= JavaPlugin.getDefault().getJavaEditorTextHoverDescriptors();
	int i= 0;
	while (i < hoverDescs.length) {
		if (hoverDescs[i].isEnabled() &&  hoverDescs[i].getStateMask() == stateMask)
			return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
		i++;
	}

	return null;
}
 
/**
 * 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;
}
 
private static IInformationControlCreator getInformationPresenterControlCreator(ITextHover hover) {
	if (hover instanceof IInformationProviderExtension2) // this is wrong, but left here for backwards compatibility
		return ((IInformationProviderExtension2)hover).getInformationPresenterControlCreator();

	if (hover instanceof AbstractJavaEditorTextHover) {
		return ((AbstractJavaEditorTextHover) hover).getInformationPresenterControlCreator();
	}
	return null;
}
 
public ITextHover getTextHover( ISourceViewer sourceViewer,
		String contentType, int stateMask )
{

	if ( !( JSPartitionScanner.JS_COMMENT.equals( contentType )
			//|| JSPartitionScanner.JS_KEYWORD.equals( contentType ) 
			|| JSPartitionScanner.JS_STRING.equals( contentType ) ) )
	{
		return new ScriptDebugHover( );
	}
	return super.getTextHover( sourceViewer, contentType, stateMask );
}
 
源代码21 项目: Pydev   文件: PyEditConfiguration.java
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
    /**
     * Return the combining hover if the preferences are set accordingly and the state mask matches.
     */
    if (PyHoverPreferencesPage.getCombineHoverInfo()) {
        PyEditorTextHoverDescriptor combiningHover = PydevPlugin.getCombiningHoverDescriptor();
        if (combiningHover.getStateMask() == stateMask) {
            return new PyEditorTextHoverProxy(combiningHover, contentType);
        }
    }

    /**
     * We return the highest priority registered hover whose state mask matches. If two or more hovers
     * have the highest priority, it is indeterminate which will be selected. The proper way to combine
     * hover info is to select that option on the PyDev->Editor->Hover preference page. This will cause
     * the combining hover to be returned by the code above.
     */
    PyEditorTextHoverDescriptor[] hoverDescs = PydevPlugin.getDefault().getPyEditorTextHoverDescriptors();
    int i = 0;
    while (i < hoverDescs.length) {
        if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask) {
            return new PyEditorTextHoverProxy(hoverDescs[i], contentType);
        }
        i++;
    }

    return null;
}
 
源代码22 项目: http4e   文件: HConfiguration.java
/**
 * @Override
 */
public ITextHover getTextHover( ISourceViewer sourceViewer, String contentType){
   return new MyTextHover();
}
 
源代码23 项目: xtext-eclipse   文件: DummyTextViewer.java
@Override
public void setTextHover(ITextHover textViewerHover, String contentType) {
	throw new UnsupportedOperationException();
}
 
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
	return null;
}
 
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	return null;
}
 
源代码26 项目: xtext-eclipse   文件: XtextInformationProvider.java
protected IRegion computeRegion(ITextViewer textViewer, final int offset) {
	if(hover instanceof ITextHover)
		return ((ITextHover) hover).getHoverRegion(textViewer, offset);
	return new Region(offset, 0);
}
 
源代码27 项目: xtext-eclipse   文件: AbstractCompositeHover.java
public List<ITextHover> getHovers() {
	if (hovers == null)
		hovers = createHovers();
	return hovers;
}
 
源代码28 项目: xtext-eclipse   文件: MockableTextViewer.java
@Override
public void setTextHover(ITextHover textViewerHover, String contentType) {
	throw new UnsupportedOperationException();
}
 
源代码29 项目: xtext-eclipse   文件: MockableTextViewer.java
@Override
public void setTextHover(ITextHover textViewerHover, String contentType) {
	throw new UnsupportedOperationException();
}
 
源代码30 项目: JAADAS   文件: JimpleConfiguration.java
/**
 * This allows text hover on Jimple Editor 
 */
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	return new SootAttributesJimpleHover(getEditor());
}
 
 类所在包
 类方法
 同包方法