Search in sources :

Example 1 with IEditorStatusLine

use of org.eclipse.ui.texteditor.IEditorStatusLine in project webtools.sourceediting by eclipse.

the class GotoAnnotationAction method gotoAnnotation.

/**
 * Jumps to the error next according to the given direction based off
 * JavaEditor#gotoAnnotation()
 *
 * @param forward
 *            is the direction
 */
public void gotoAnnotation(boolean forward) {
    ITextSelection selection = (ITextSelection) getTextEditor().getSelectionProvider().getSelection();
    Position position = new Position(0, 0);
    if (false) /* delayed - see bug 18316 */
    {
        getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
        getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
    } else /* no delay - see bug 18316 */
    {
        Annotation annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
        IEditorStatusLine editorStatusLine = getTextEditor().getAdapter(IEditorStatusLine.class);
        if (editorStatusLine != null) {
            editorStatusLine.setMessage(true, null, null);
            editorStatusLine.setMessage(false, null, null);
        } else {
            IStatusLineManager mgr = getStatusLineManager();
            if (mgr != null) {
                mgr.setErrorMessage(null);
                mgr.setMessage(null, null);
            }
        }
        if (annotation != null) {
            updateAnnotationViews(annotation);
            if (_debug) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                System.out.println("select and reveal " + annotation.getType() + "@" + position.getOffset() + ":" + position.getLength());
            }
            getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
            if (editorStatusLine != null) {
                editorStatusLine.setMessage(true, null, null);
                editorStatusLine.setMessage(false, annotation.getText(), null);
            } else {
                IStatusLineManager mgr = getStatusLineManager();
                if (mgr != null) {
                    mgr.setErrorMessage(null);
                    mgr.setMessage(null, annotation.getText());
                }
                getTextEditor().getSelectionProvider().addSelectionChangedListener(new StatusLineClearer(mgr));
            }
        }
    }
}
Also used : Position(org.eclipse.jface.text.Position) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) ITextSelection(org.eclipse.jface.text.ITextSelection) Annotation(org.eclipse.jface.text.source.Annotation) SimpleMarkerAnnotation(org.eclipse.ui.texteditor.SimpleMarkerAnnotation) IEditorStatusLine(org.eclipse.ui.texteditor.IEditorStatusLine)

Example 2 with IEditorStatusLine

use of org.eclipse.ui.texteditor.IEditorStatusLine 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 3 with IEditorStatusLine

use of org.eclipse.ui.texteditor.IEditorStatusLine 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

ITextSelection (org.eclipse.jface.text.ITextSelection)3 IEditorStatusLine (org.eclipse.ui.texteditor.IEditorStatusLine)3 IRegion (org.eclipse.jface.text.IRegion)2 Region (org.eclipse.jface.text.Region)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)2 SQLHyperlinkDetector (org.jkiss.dbeaver.ui.editors.sql.syntax.SQLHyperlinkDetector)2 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)1 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 SimpleMarkerAnnotation (org.eclipse.ui.texteditor.SimpleMarkerAnnotation)1