use of org.jkiss.dbeaver.ui.editors.text.BaseTextEditor in project dbeaver by serge-rider.
the class UIUtils method enableHostEditorKeyBindings.
/**
* Eclipse hack. Disables/enabled all key bindings in specified site's part. Works only if host editor is extender of
* AbstractTextEditor Uses reflection because setActionActivation is private method
* TODO: find better way to disable key bindings or prioritize event handling to widgets
*
* @param partSite workbench part site
* @param enable enable or disable
*/
@Deprecated
public static void enableHostEditorKeyBindings(IWorkbenchPartSite partSite, boolean enable) {
IWorkbenchPart part = partSite.getPart();
if (part instanceof AbstractTextEditor) {
AbstractTextEditor hostEditor = (AbstractTextEditor) part;
if (hostEditor instanceof BaseTextEditor) {
StyledText textWidget = ((BaseTextEditor) hostEditor).getTextViewer().getTextWidget();
if (textWidget == null || textWidget.isDisposed()) {
return;
}
}
try {
Method activatorMethod = AbstractTextEditor.class.getDeclaredMethod("setActionActivation", Boolean.TYPE);
activatorMethod.setAccessible(true);
activatorMethod.invoke(hostEditor, enable);
} catch (Throwable e) {
if (e instanceof InvocationTargetException) {
e = ((InvocationTargetException) e).getTargetException();
}
log.warn("Can't disable text editor action activations", e);
}
//hostEditor.getEditorSite().getActionBarContributor().setActiveEditor(hostEditor);
}
}
use of org.jkiss.dbeaver.ui.editors.text.BaseTextEditor 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;
}
use of org.jkiss.dbeaver.ui.editors.text.BaseTextEditor in project dbeaver by serge-rider.
the class LoadTextFileHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
BaseTextEditor editor = BaseTextEditor.getTextEditor(HandlerUtil.getActiveEditor(event));
if (editor == null) {
return null;
}
editor.loadFromExternalFile();
return null;
}
use of org.jkiss.dbeaver.ui.editors.text.BaseTextEditor in project dbeaver by dbeaver.
the class ToggleWordWrapHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// get active editor where word wrap will be toggled
BaseTextEditor textEditor = BaseTextEditor.getTextEditor(HandlerUtil.getActiveEditor(event));
if (textEditor != null) {
// editor (ITextEditor) adapter returns StyledText
Object text = textEditor.getAdapter(Control.class);
if (text instanceof StyledText) {
StyledText styledText = (StyledText) text;
// toggle wrapping
styledText.setWordWrap(!styledText.getWordWrap());
}
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.text.BaseTextEditor in project dbeaver by dbeaver.
the class SaveTextFileHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
BaseTextEditor editor = BaseTextEditor.getTextEditor(HandlerUtil.getActiveEditor(event));
if (editor == null) {
return null;
}
editor.saveToExternalFile();
return null;
}
Aggregations