use of org.jkiss.dbeaver.ui.editors.sql.SQLEditor in project dbeaver by serge-rider.
the class SQLEditorHandlerSwitchPanel method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SQLEditor editor = RuntimeUtils.getObjectAdapter(HandlerUtil.getActiveEditor(event), SQLEditor.class);
if (editor == null) {
return null;
}
String actionId = event.getCommand().getId();
switch(actionId) {
case SQLEditorCommands.CMD_SQL_SWITCH_PANEL:
editor.toggleActivePanel();
break;
case SQLEditorCommands.CMD_SQL_SHOW_OUTPUT:
editor.showOutputPanel();
break;
case SQLEditorCommands.CMD_SQL_SHOW_LOG:
editor.showExecutionLogPanel();
break;
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditor in project dbeaver by serge-rider.
the class CopySourceCodeHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SQLEditor editor = RuntimeUtils.getObjectAdapter(HandlerUtil.getActiveEditor(event), SQLEditor.class);
if (editor == null) {
return null;
}
ISelection selection = editor.getSelectionProvider().getSelection();
if (selection.isEmpty() || !(selection instanceof TextSelection)) {
return null;
}
TextSelection textSelection = (TextSelection) selection;
if (textSelection.getLength() < 2) {
// Use active query
SQLScriptElement activeQuery = editor.extractActiveQuery();
if (activeQuery != null && activeQuery.getLength() > 1) {
textSelection = new TextSelection(editor.getDocument(), activeQuery.getOffset(), activeQuery.getLength());
}
}
TargetFormatDialog dialog = new TargetFormatDialog(editor, textSelection);
if (dialog.open() != IDialogConstants.OK_ID) {
return null;
}
UIUtils.setClipboardContents(Display.getCurrent(), TextTransfer.getInstance(), dialog.getConvertedText());
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditor in project dbeaver by serge-rider.
the class SQLEditorHandlerExecute method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SQLEditor editor = RuntimeUtils.getObjectAdapter(HandlerUtil.getActiveEditor(event), SQLEditor.class);
if (editor == null) {
log.error("No active SQL editor found");
return null;
}
String actionId = event.getCommand().getId();
switch(actionId) {
case SQLEditorCommands.CMD_EXECUTE_STATEMENT:
editor.processSQL(false, false);
break;
case SQLEditorCommands.CMD_EXECUTE_STATEMENT_NEW:
editor.processSQL(true, false);
break;
case SQLEditorCommands.CMD_EXECUTE_SCRIPT:
editor.processSQL(false, true);
break;
case SQLEditorCommands.CMD_EXECUTE_SCRIPT_NEW:
editor.processSQL(true, true);
break;
case SQLEditorCommands.CMD_EXECUTE_ROW_COUNT:
editor.processSQL(false, false, new SQLQueryTransformerCount(), null);
break;
case SQLEditorCommands.CMD_EXECUTE_EXPRESSION:
editor.processSQL(false, false, new SQLQueryTransformerExpression(), null);
break;
case SQLEditorCommands.CMD_EXECUTE_ALL_ROWS:
editor.processSQL(false, false, new SQLQueryTransformerAllRows(), null);
break;
case SQLEditorCommands.CMD_EXPLAIN_PLAN:
editor.explainQueryPlan();
break;
case SQLEditorCommands.CMD_LOAD_PLAN:
editor.loadQueryPlan();
break;
default:
log.error("Unsupported SQL editor command: " + actionId);
break;
}
editor.refreshActions();
return null;
}
Aggregations