Search in sources :

Example 1 with IHyperlink

use of org.eclipse.ui.console.IHyperlink in project erlide_eclipse by erlang.

the class ErlPatternMatchListenerDelegate method matchFound.

@Override
public void matchFound(final PatternMatchEvent event) {
    if (fConsole == null) {
        return;
    }
    try {
        final String txt = fConsole.getDocument().get(event.getOffset(), event.getLength());
        final String[] v = txt.split(":");
        final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        IResource res = null;
        for (final IProject prj : projects) {
            if (!prj.isOpen()) {
                continue;
            }
            try {
                res = ErlPatternMatchListenerDelegate.recursiveFindNamedResourceWithReferences(prj, v[0]);
                if (res != null) {
                    break;
                }
            } catch (final CoreException e) {
                ErlLogger.warn(e);
            }
        }
        IFile file = null;
        if (res instanceof IFile) {
            file = (IFile) res;
        }
        final IHyperlink link = new FileLink(file, null, -1, -1, Integer.parseInt(v[1]));
        fConsole.addHyperlink(link, event.getOffset(), event.getLength());
    } catch (final BadLocationException e) {
        ErlLogger.warn(e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IHyperlink(org.eclipse.ui.console.IHyperlink) FileLink(org.eclipse.debug.ui.console.FileLink) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 FileLink (org.eclipse.debug.ui.console.FileLink)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IHyperlink (org.eclipse.ui.console.IHyperlink)1