提交 4895e63c 编写于 作者: R RiedNyko

Added_option_to_open_selected_part#4978 fix1

上级 bc9b436e
...@@ -41,27 +41,26 @@ import java.util.Map; ...@@ -41,27 +41,26 @@ import java.util.Map;
*/ */
public class SQLSourceViewer<T extends DBPScriptObject & DBSObject> extends SQLEditorNested<T> { public class SQLSourceViewer<T extends DBPScriptObject & DBSObject> extends SQLEditorNested<T> {
private IAction OPEN_CONSOLE_ACTION = new Action("Open in SQL console", DBeaverIcons.getImageDescriptor(UIIcon.SQL_CONSOLE)) { private IAction OPEN_CONSOLE_ACTION = new Action("Open in SQL console",
@Override DBeaverIcons.getImageDescriptor(UIIcon.SQL_CONSOLE)) {
public void run() @Override
{ public void run() {
String sqlText = getDocument().get(); String sqlText = getDocument().get();
ISelection selection = getSelectionProvider().getSelection(); ISelection selection = getSelectionProvider().getSelection();
if (selection instanceof TextSelection) { if (selection instanceof TextSelection) {
sqlText = ((TextSelection) selection).getText(); if (((TextSelection) selection).getLength() > 0) {
if (sqlText.isEmpty()) { sqlText = ((TextSelection) selection).getText();
sqlText = getDocument().get(); }
} }
} final DBPDataSource dataSource = getDataSource();
final DBPDataSource dataSource = getDataSource(); OpenHandler.openSQLConsole(
OpenHandler.openSQLConsole( UIUtils.getActiveWorkbenchWindow(),
UIUtils.getActiveWorkbenchWindow(), dataSource == null ? null : dataSource.getContainer(),
dataSource == null ? null : dataSource.getContainer(), "Source",
"Source", sqlText
sqlText );
); }
} };
};
@Override @Override
protected String getSourceText(DBRProgressMonitor monitor) throws DBException protected String getSourceText(DBRProgressMonitor monitor) throws DBException
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册