类org.eclipse.jface.text.hyperlink.IHyperlinkDetector源码实例Demo

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

@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	List<IHyperlinkDetector> detectors = new LinkedList<IHyperlinkDetector>();
	IHyperlinkDetector[] inheritedDetectors = super.getHyperlinkDetectors(sourceViewer);
	if (inheritedDetectors != null) {
		for (final IHyperlinkDetector detector : inheritedDetectors) {
			detectors.add(new IHyperlinkDetector() {
				@Override
				public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
						boolean canShowMultipleHyperlinks) {
					try {
						IHyperlink[] result = detector.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
						// fail safe detector: don't return an empty array
						// but null (see org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(IRegion))
						if (result != null && result.length == 0) {
							return null;
						}
						return result;
					}
					catch (Throwable e) {
						// fail safe hyperlink detector - prevent others
						// from failing
					}
					return null;
				}

			});
		}
	}
	detectors.add(detector);
	return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
 
源代码2 项目: tlaplus   文件: TLAEditor.java
public Object execute(ExecutionEvent event) throws ExecutionException
{
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    final TLAEditor tlaEditor = activeEditor.getAdapter(TLAEditor.class);

    final ITextSelection selection = (ITextSelection) tlaEditor.getSelectionProvider().getSelection();
    final IRegion region = new Region(selection.getOffset(), selection.getLength());

    // get the detectors
    final ISourceViewer internalSourceViewer = tlaEditor.getSourceViewer();
    final IHyperlinkDetector[] hyperlinkDetectors = tlaEditor.getSourceViewerConfiguration()
            .getHyperlinkDetectors(internalSourceViewer);
    if (hyperlinkDetectors != null)
    {
        for (int i = 0; i < hyperlinkDetectors.length; i++)
        {
            // detect
            final IHyperlink[] hyperlinks = hyperlinkDetectors[i].detectHyperlinks(internalSourceViewer, region,
                    false);
            if (hyperlinks != null && hyperlinks.length > 0)
            {
                // open
                final IHyperlink hyperlink = hyperlinks[0];
                hyperlink.open();
                break;
            }
        }
    }
    return null;
}
 
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
       return new IHyperlinkDetector[] { new URLHyperlinkDetector(), //
               new SwaggerReferenceHyperlinkDetector(), //
               new PathParamHyperlinkDetector(), //
               new DefinitionHyperlinkDetector() };
}
 
源代码4 项目: KaiZen-OpenAPI-Editor   文件: OpenApi3Editor.java
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    return new IHyperlinkDetector[] { new URLHyperlinkDetector(), //
            new PathParamHyperlinkDetector(), //
            new DefinitionHyperlinkDetector(), //
            new OpenApi3ReferenceHyperlinkDetector(), //
            new SecuritySchemeHyperlinkDetector(), //
            new LinkOperationHyperlinkDetector(), //
            new LinkOperationRefHyperlinkDetector() };
}
 
源代码5 项目: n4js   文件: N4JSUiModule.java
/** Custom IHyperlinkDetector. */
@Override
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return N4JSHyperlinkDetector.class;
}
 
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}
 
源代码7 项目: xtext-eclipse   文件: DefaultUiModule.java
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return DefaultHyperlinkDetector.class;
}
 
源代码8 项目: xtext-eclipse   文件: OpenDeclarationHandler.java
public void setDetector(IHyperlinkDetector detector) {
	this.detector = detector;
}
 
源代码9 项目: xtext-eclipse   文件: OpenDeclarationHandler.java
public IHyperlinkDetector getDetector() {
	return detector;
}
 
@Override 
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { 

	return new IHyperlinkDetector[]{new ImpexTypeHyperlinkDetector()}; 
}
 
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    return new IHyperlinkDetector[] { new URLHyperlinkDetector() };
}
 
源代码12 项目: gama   文件: GamlUiModule.java
@Override
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return GamlHyperlinkDetector.class;
}
 
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}
 
源代码14 项目: Pydev   文件: ScriptConsoleViewerWrapper.java
public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) {
    viewer.setHyperlinkDetectors(hyperlinkDetectors, eventStateMask);
}
 
源代码15 项目: goclipse   文件: SimpleSourceViewerConfiguration.java
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}
 
 类所在包
 同包方法