Search in sources :

Example 1 with ICommentsSupport

use of org.jkiss.dbeaver.ui.ICommentsSupport in project dbeaver by serge-rider.

the class AbstractCommentHandler method execute.

public final Object execute(ExecutionEvent event) throws ExecutionException {
    BaseTextEditor textEditor = BaseTextEditor.getTextEditor(HandlerUtil.getActiveEditor(event));
    if (textEditor != null) {
        ICommentsSupport commentsSupport = textEditor.getCommentsSupport();
        IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
        if (document != null && commentsSupport != null) {
            // get current text selection
            ISelectionProvider provider = textEditor.getSelectionProvider();
            if (provider != null) {
                ISelection selection = provider.getSelection();
                if (selection instanceof ITextSelection) {
                    ITextSelection textSelection = (ITextSelection) selection;
                    if (!textSelection.isEmpty()) {
                        try {
                            processAction(textEditor.getSelectionProvider(), commentsSupport, document, textSelection);
                        } catch (BadLocationException e) {
                            log.warn(e);
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ICommentsSupport(org.jkiss.dbeaver.ui.ICommentsSupport) ISelection(org.eclipse.jface.viewers.ISelection) BaseTextEditor(org.jkiss.dbeaver.ui.editors.text.BaseTextEditor) IDocument(org.eclipse.jface.text.IDocument) ITextSelection(org.eclipse.jface.text.ITextSelection) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 2 with ICommentsSupport

use of org.jkiss.dbeaver.ui.ICommentsSupport in project dbeaver by dbeaver.

the class AbstractCommentHandler method execute.

public final Object execute(ExecutionEvent event) throws ExecutionException {
    BaseTextEditor textEditor = BaseTextEditor.getTextEditor(HandlerUtil.getActiveEditor(event));
    if (textEditor != null) {
        ICommentsSupport commentsSupport = textEditor.getCommentsSupport();
        IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
        if (document != null && commentsSupport != null) {
            // get current text selection
            ISelectionProvider provider = textEditor.getSelectionProvider();
            if (provider != null) {
                ISelection selection = provider.getSelection();
                if (selection instanceof ITextSelection) {
                    ITextSelection textSelection = (ITextSelection) selection;
                    if (!textSelection.isEmpty()) {
                        try {
                            processAction(textEditor.getSelectionProvider(), commentsSupport, document, textSelection);
                        } catch (BadLocationException e) {
                            log.warn(e);
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ICommentsSupport(org.jkiss.dbeaver.ui.ICommentsSupport) ISelection(org.eclipse.jface.viewers.ISelection) BaseTextEditor(org.jkiss.dbeaver.ui.editors.text.BaseTextEditor) IDocument(org.eclipse.jface.text.IDocument) ITextSelection(org.eclipse.jface.text.ITextSelection) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

BadLocationException (org.eclipse.jface.text.BadLocationException)2 IDocument (org.eclipse.jface.text.IDocument)2 ITextSelection (org.eclipse.jface.text.ITextSelection)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 ICommentsSupport (org.jkiss.dbeaver.ui.ICommentsSupport)2 BaseTextEditor (org.jkiss.dbeaver.ui.editors.text.BaseTextEditor)2