return;
}
ITextSelection textSelection = (ITextSelection) selection;
final IRegion region = new Region(textSelection.getOffset(), textSelection.getLength());
IHyperlink hyperlink = null;
synchronized (fHyperlinkDetectors) {
for (int i = 0, length = fHyperlinkDetectors.length; i < length && hyperlink == null; i++) {
final IHyperlinkDetector detector = fHyperlinkDetectors[i];
if (detector == null)
continue;
/* The array is final, but its contents aren't */
final IHyperlink[][] hyperlinks = new IHyperlink[1][];
/*
* Detect from within a SafeRunnable since the list of
* detectors is extensible
*/
SafeRunnable detectorRunnable = new SafeRunnable() {
public void run() throws Exception {
hyperlinks[0] = detector.detectHyperlinks(fTextViewer, region, false);
}
};
SafeRunner.run(detectorRunnable);
if (hyperlinks[0] == null)
continue;
if (hyperlinks.length > 0)
hyperlink = hyperlinks[0][0];
}
}
if (hyperlink != null) {
/**
* Force the highlight range to change when the hyperlink is
* opened by altering the highlighted range beforehand.
*/
getTextEditor().setHighlightRange(Math.max(0, region.getOffset() - 1), 0, false);
hyperlink.open();
}
}