Search in sources :

Example 1 with HyperlinkDetectorDelegate

use of org.eclipse.mylyn.internal.wikitext.ui.util.HyperlinkDetectorDelegate in project mylyn.docs by eclipse.

the class AbstractTextSourceViewerConfiguration method getHyperlinkDetectors.

@SuppressWarnings("unchecked")
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    List<IHyperlinkDetector> customDetectors = createCustomHyperlinkDetectors(sourceViewer);
    if (sourceViewer == null || fPreferenceStore == null) {
        return customDetectors.toArray(new IHyperlinkDetector[customDetectors.size()]);
    }
    HyperlinkDetectorRegistry registry = EditorsUI.getHyperlinkDetectorRegistry();
    HyperlinkDetectorDescriptor[] descriptors = registry.getHyperlinkDetectorDescriptors();
    Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
    List<IHyperlinkDetector> detectors = new ArrayList<>(8);
    if (markupHyperlinksFirst) {
        detectors.addAll(customDetectors);
    }
    if (hyperlinkDetectors != null) {
        detectors.addAll(hyperlinkDetectors);
    }
    for (Map.Entry<String, IAdaptable> target : targets.entrySet()) {
        String targetId = target.getKey();
        IAdaptable context = target.getValue();
        for (HyperlinkDetectorDescriptor descriptor : descriptors) {
            if (targetId.equals(descriptor.getTargetId())) {
                if (filterHyperlinkDescriptor(descriptor)) {
                    continue;
                }
                HyperlinkDetectorDelegate delegate = new HyperlinkDetectorDelegate(descriptor, fPreferenceStore);
                delegate.setContext(context);
                detectors.add(delegate);
            }
        }
    }
    if (!markupHyperlinksFirst) {
        detectors.addAll(customDetectors);
    }
    return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
Also used : HyperlinkDetectorRegistry(org.eclipse.ui.texteditor.HyperlinkDetectorRegistry) IAdaptable(org.eclipse.core.runtime.IAdaptable) HyperlinkDetectorDescriptor(org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor) HyperlinkDetectorDelegate(org.eclipse.mylyn.internal.wikitext.ui.util.HyperlinkDetectorDelegate) IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)1 HyperlinkDetectorDelegate (org.eclipse.mylyn.internal.wikitext.ui.util.HyperlinkDetectorDelegate)1 HyperlinkDetectorDescriptor (org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor)1 HyperlinkDetectorRegistry (org.eclipse.ui.texteditor.HyperlinkDetectorRegistry)1