Search in sources :

Example 6 with IHyperlinkDetector

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]));
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) SafeRunnable(org.eclipse.jface.util.SafeRunnable) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable)

Example 7 with IHyperlinkDetector

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;
}
Also used : HyperlinkDetectorRegistry(org.eclipse.ui.texteditor.HyperlinkDetectorRegistry) IAdaptable(org.eclipse.core.runtime.IAdaptable) Entry(java.util.Map.Entry) IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector)

Aggregations

IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)7 Point (org.eclipse.swt.graphics.Point)3 CoreException (org.eclipse.core.runtime.CoreException)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ITextViewerExtension6 (org.eclipse.jface.text.ITextViewerExtension6)2 HyperlinkDetectorRegistry (org.eclipse.ui.texteditor.HyperlinkDetectorRegistry)2 IColumnSupport (org.eclipse.ui.texteditor.rulers.IColumnSupport)2 RulerColumnDescriptor (org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IAction (org.eclipse.jface.action.IAction)1 ITextViewerExtension8 (org.eclipse.jface.text.ITextViewerExtension8)1 IContentAssistantExtension2 (org.eclipse.jface.text.contentassist.IContentAssistantExtension2)1 IContentAssistantExtension4 (org.eclipse.jface.text.contentassist.IContentAssistantExtension4)1 AbstractHyperlinkDetector (org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector)1