Search in sources :

Example 1 with SQLHyperlinkDetector

use of org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector in project dbeaver by serge-rider.

the class NavigateObjectHandler method getCurrentHyperlink.

private IHyperlink getCurrentHyperlink(SQLEditorBase editor) {
    SQLHyperlinkDetector hyperlinkDetector = new SQLHyperlinkDetector(editor, editor.getSyntaxManager());
    ITextSelection selection = (ITextSelection) editor.getTextViewer().getSelection();
    IRegion curRegion = new Region(selection.getOffset(), 0);
    IHyperlink[] hyperLinks = hyperlinkDetector.detectHyperlinks(editor.getTextViewer(), curRegion, false);
    return ArrayUtils.isEmpty(hyperLinks) ? null : hyperLinks[0];
}
Also used : SQLHyperlinkDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) ITextSelection(org.eclipse.jface.text.ITextSelection) IRegion(org.eclipse.jface.text.IRegion)

Example 2 with SQLHyperlinkDetector

use of org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector in project dbeaver by dbeaver.

the class SQLEditorHandlerNavigateObject method getCurrentHyperlink.

private IHyperlink getCurrentHyperlink(SQLEditorBase editor) {
    SQLHyperlinkDetector hyperlinkDetector = editor.getViewerConfiguration().getHyperlinkDetector();
    ITextSelection selection = (ITextSelection) editor.getTextViewer().getSelection();
    IRegion curRegion = new Region(selection.getOffset(), 0);
    IHyperlink[] hyperLinks = hyperlinkDetector.detectHyperlinks(editor.getTextViewer(), curRegion, false);
    if (!ArrayUtils.isEmpty(hyperLinks)) {
        return hyperLinks[0];
    }
    String lastKeyword = hyperlinkDetector.getLastKeyword();
    if (!CommonUtils.isEmpty(lastKeyword)) {
        IEditorStatusLine statusLine = editor.getAdapter(IEditorStatusLine.class);
        if (statusLine != null) {
            statusLine.setMessage(true, "Can't find metadata object for name '" + lastKeyword + "'", (Image) null);
        }
        editor.getEditorControl().getDisplay().beep();
    }
    return null;
}
Also used : SQLHyperlinkDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) ITextSelection(org.eclipse.jface.text.ITextSelection) IRegion(org.eclipse.jface.text.IRegion) IEditorStatusLine(org.eclipse.ui.texteditor.IEditorStatusLine)

Example 3 with SQLHyperlinkDetector

use of org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector in project dbeaver by dbeaver.

the class NavigateObjectHandler method getCurrentHyperlink.

private IHyperlink getCurrentHyperlink(SQLEditorBase editor) {
    SQLHyperlinkDetector hyperlinkDetector = new SQLHyperlinkDetector(editor, editor.getSyntaxManager());
    ITextSelection selection = (ITextSelection) editor.getTextViewer().getSelection();
    IRegion curRegion = new Region(selection.getOffset(), 0);
    IHyperlink[] hyperLinks = hyperlinkDetector.detectHyperlinks(editor.getTextViewer(), curRegion, false);
    if (!ArrayUtils.isEmpty(hyperLinks)) {
        return hyperLinks[0];
    }
    String lastKeyword = hyperlinkDetector.getLastKeyword();
    if (!CommonUtils.isEmpty(lastKeyword)) {
        IEditorStatusLine statusLine = (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
        if (statusLine != null) {
            statusLine.setMessage(true, "Can't find metadata object for name '" + lastKeyword + "'", (Image) null);
        }
        editor.getEditorControl().getDisplay().beep();
    }
    return null;
}
Also used : SQLHyperlinkDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) ITextSelection(org.eclipse.jface.text.ITextSelection) IRegion(org.eclipse.jface.text.IRegion) IEditorStatusLine(org.eclipse.ui.texteditor.IEditorStatusLine)

Example 4 with SQLHyperlinkDetector

use of org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector in project dbeaver by serge-rider.

the class SQLEditorHandlerNavigateObject method getCurrentHyperlink.

private IHyperlink getCurrentHyperlink(SQLEditorBase editor) {
    SQLHyperlinkDetector hyperlinkDetector = editor.getViewerConfiguration().getHyperlinkDetector();
    ITextSelection selection = (ITextSelection) editor.getTextViewer().getSelection();
    IRegion curRegion = new Region(selection.getOffset(), 0);
    IHyperlink[] hyperLinks = hyperlinkDetector.detectHyperlinks(editor.getTextViewer(), curRegion, false);
    if (!ArrayUtils.isEmpty(hyperLinks)) {
        return hyperLinks[0];
    }
    String lastKeyword = hyperlinkDetector.getLastKeyword();
    if (!CommonUtils.isEmpty(lastKeyword)) {
        IEditorStatusLine statusLine = editor.getAdapter(IEditorStatusLine.class);
        if (statusLine != null) {
            statusLine.setMessage(true, "Can't find metadata object for name '" + lastKeyword + "'", (Image) null);
        }
        editor.getEditorControl().getDisplay().beep();
    }
    return null;
}
Also used : SQLHyperlinkDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) ITextSelection(org.eclipse.jface.text.ITextSelection) IRegion(org.eclipse.jface.text.IRegion) IEditorStatusLine(org.eclipse.ui.texteditor.IEditorStatusLine)

Aggregations

IRegion (org.eclipse.jface.text.IRegion)4 ITextSelection (org.eclipse.jface.text.ITextSelection)4 Region (org.eclipse.jface.text.Region)4 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)4 SQLHyperlinkDetector (org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector)4 IEditorStatusLine (org.eclipse.ui.texteditor.IEditorStatusLine)3