Search in sources :

Example 1 with EntityHyperlink

use of org.jkiss.dbeaver.ui.editors.entity.EntityHyperlink in project dbeaver by serge-rider.

the class SQLHyperlinkDetector method detectHyperlinks.

@Nullable
@Override
public synchronized IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    this.contextInformer.searchInformation(region);
    if (!this.contextInformer.hasObjects()) {
        // Long task - just return no links for now
        return null;
    } else {
        // Create hyperlinks based on references
        final SQLIdentifierDetector.WordRegion wordRegion = this.contextInformer.getWordRegion();
        final IRegion hlRegion = new Region(wordRegion.identStart, wordRegion.identEnd - wordRegion.identStart);
        final List<DBSObjectReference> references = this.contextInformer.getObjectReferences();
        IHyperlink[] links = new IHyperlink[references.size()];
        for (int i = 0, objectsSize = references.size(); i < objectsSize; i++) {
            links[i] = new EntityHyperlink(contextInformer.getEditor().getSite(), references.get(i), hlRegion);
        }
        return links;
    }
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) DBSObjectReference(org.jkiss.dbeaver.model.struct.DBSObjectReference) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) EntityHyperlink(org.jkiss.dbeaver.ui.editors.entity.EntityHyperlink) Nullable(org.jkiss.code.Nullable)

Aggregations

IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 Nullable (org.jkiss.code.Nullable)1 DBSObjectReference (org.jkiss.dbeaver.model.struct.DBSObjectReference)1 EntityHyperlink (org.jkiss.dbeaver.ui.editors.entity.EntityHyperlink)1