org.eclipse.jface.text.hyperlink.IHyperlinkDetector Java Examples

The following examples show how to use org.eclipse.jface.text.hyperlink.IHyperlinkDetector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextSourceViewerConfiguration.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@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()]);
}
 
Example #2
Source File: TLAEditor.java    From tlaplus with MIT License 5 votes vote down vote up
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;
}
 
Example #3
Source File: SwaggerSourceViewerConfiguration.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
       return new IHyperlinkDetector[] { new URLHyperlinkDetector(), //
               new SwaggerReferenceHyperlinkDetector(), //
               new PathParamHyperlinkDetector(), //
               new DefinitionHyperlinkDetector() };
}
 
Example #4
Source File: OpenApi3Editor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    return new IHyperlinkDetector[] { new URLHyperlinkDetector(), //
            new PathParamHyperlinkDetector(), //
            new DefinitionHyperlinkDetector(), //
            new OpenApi3ReferenceHyperlinkDetector(), //
            new SecuritySchemeHyperlinkDetector(), //
            new LinkOperationHyperlinkDetector(), //
            new LinkOperationRefHyperlinkDetector() };
}
 
Example #5
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/** Custom IHyperlinkDetector. */
@Override
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return N4JSHyperlinkDetector.class;
}
 
Example #6
Source File: ReadOnlySourceViewerConfiguration.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}
 
Example #7
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return DefaultHyperlinkDetector.class;
}
 
Example #8
Source File: OpenDeclarationHandler.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void setDetector(IHyperlinkDetector detector) {
	this.detector = detector;
}
 
Example #9
Source File: OpenDeclarationHandler.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public IHyperlinkDetector getDetector() {
	return detector;
}
 
Example #10
Source File: ImpexSourceViewerConfig.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 4 votes vote down vote up
@Override 
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { 

	return new IHyperlinkDetector[]{new ImpexTypeHyperlinkDetector()}; 
}
 
Example #11
Source File: JsonSourceViewerConfiguration.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    return new IHyperlinkDetector[] { new URLHyperlinkDetector() };
}
 
Example #12
Source File: GamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector() {
	return GamlHyperlinkDetector.class;
}
 
Example #13
Source File: SimpleJavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}
 
Example #14
Source File: ScriptConsoleViewerWrapper.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) {
    viewer.setHyperlinkDetectors(hyperlinkDetectors, eventStateMask);
}
 
Example #15
Source File: SimpleSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	return null;
}