use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project eclipse.platform.text by eclipse.
the class HyperlinkDetectorDescriptor method createHyperlinkDetectorImplementation.
/**
* Creates a new {@link IHyperlinkDetector}.
*
* @return the hyperlink detector or <code>null</code> if the plug-in isn't loaded yet
* @throws CoreException if a failure occurred during creation
* @since 3.9
*/
public IHyperlinkDetector createHyperlinkDetectorImplementation() throws CoreException {
final Throwable[] exception = new Throwable[1];
final IHyperlinkDetector[] result = new IHyperlinkDetector[1];
String message = NLSUtility.format(EditorMessages.Editor_error_HyperlinkDetector_couldNotCreate_message, new String[] { getId(), fElement.getContributor().getName() });
ISafeRunnable code = new SafeRunnable(message) {
@Override
public void run() throws Exception {
String pluginId = fElement.getContributor().getName();
boolean isPlugInActivated = Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
if (isPlugInActivated || canActivatePlugIn())
result[0] = (IHyperlinkDetector) fElement.createExecutableExtension(CLASS_ATTRIBUTE);
}
@Override
public void handleException(Throwable ex) {
super.handleException(ex);
exception[0] = ex;
}
};
SafeRunner.run(code);
if (exception[0] == null)
return result[0];
throw new CoreException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception[0]));
}
use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project eclipse.platform.text by eclipse.
the class TextSourceViewerConfiguration method getRegisteredHyperlinkDetectors.
/**
* Returns the registered hyperlink detectors which are used to detect
* hyperlinks in the given source viewer.
*
* @param sourceViewer the source viewer to be configured by this configuration
* @return an array with hyperlink detectors or <code>null</code> if no hyperlink detectors are registered
* @since 3.3
*/
protected final IHyperlinkDetector[] getRegisteredHyperlinkDetectors(ISourceViewer sourceViewer) {
HyperlinkDetectorRegistry registry = EditorsUI.getHyperlinkDetectorRegistry();
Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
Assert.isNotNull(targets);
IHyperlinkDetector[] result = null;
Iterator<Entry<String, IAdaptable>> iter = targets.entrySet().iterator();
while (iter.hasNext()) {
Entry<String, IAdaptable> target = iter.next();
String targetId = target.getKey();
IAdaptable context = target.getValue();
result = merge(result, registry.createHyperlinkDetectors(targetId, context));
}
return result;
}
Aggregations