Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
6fed5501
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6fed5501
编写于
2月 10, 2020
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#7822 Add "Open separate connection" option to the main menu. Extra logging.
上级
7977190d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
135 addition
and
14 deletion
+135
-14
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/WorkbenchContextListener.java
.../src/org/jkiss/dbeaver/core/WorkbenchContextListener.java
+3
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/AbstractExecutionContext.java
...rg/jkiss/dbeaver/model/impl/AbstractExecutionContext.java
+4
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/OSGI-INF/l10n/bundle.properties
...ss.dbeaver.ui.editors.sql/OSGI-INF/l10n/bundle.properties
+2
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/plugin.xml
plugins/org.jkiss.dbeaver.ui.editors.sql/plugin.xml
+16
-2
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
...s.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
+13
-1
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditorCommands.java
...c/org/jkiss/dbeaver/ui/editors/sql/SQLEditorCommands.java
+1
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/handlers/SQLEditorHandlerSeparateConnectionOption.java
...ql/handlers/SQLEditorHandlerSeparateConnectionOption.java
+82
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/handlers/SQLEditorHandlerSyncConnectionAuto.java
...tors/sql/handlers/SQLEditorHandlerSyncConnectionAuto.java
+8
-0
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/AbstractDataSourceHandler.java
...g/jkiss/dbeaver/ui/actions/AbstractDataSourceHandler.java
+6
-11
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/WorkbenchContextListener.java
浏览文件 @
6fed5501
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer;
import
org.jkiss.dbeaver.ui.editors.entity.EntityEditor
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditor
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorCommands
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributions
;
import
org.jkiss.dbeaver.ui.navigator.INavigatorModelView
;
import
org.jkiss.dbeaver.ui.perspective.DBeaverPerspective
;
...
...
@@ -222,6 +223,8 @@ class WorkbenchContextListener implements IWindowListener, IPageListener, IPartL
}
// Refresh auto-commit element state (#3315)
ActionUtils
.
fireCommandRefresh
(
CoreCommands
.
CMD_TOGGLE_AUTOCOMMIT
);
// Refresh OpenSeparateConnection
ActionUtils
.
fireCommandRefresh
(
SQLEditorCommands
.
CMD_TOGGLE_SEPARATE_CONNECTION
);
}
finally
{
contextService
.
deferUpdates
(
false
);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/AbstractExecutionContext.java
浏览文件 @
6fed5501
...
...
@@ -49,6 +49,8 @@ public abstract class AbstractExecutionContext<DATASOURCE extends DBPDataSource>
this
.
dataSource
=
dataSource
;
this
.
purpose
=
purpose
;
this
.
id
=
generateContextId
();
log
.
debug
(
"Execution context opened ("
+
dataSource
.
getName
()
+
", "
+
this
.
id
+
")"
);
}
public
static
synchronized
long
generateContextId
()
{
...
...
@@ -122,6 +124,8 @@ public abstract class AbstractExecutionContext<DATASOURCE extends DBPDataSource>
protected
void
closeContext
()
{
QMUtils
.
getDefaultHandler
().
handleContextClose
(
this
);
log
.
debug
(
"Execution context closed ("
+
dataSource
.
getName
()
+
", "
+
this
.
id
+
")"
);
}
@Override
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/OSGI-INF/l10n/bundle.properties
浏览文件 @
6fed5501
...
...
@@ -108,6 +108,8 @@ command.org.jkiss.dbeaver.ui.editors.sql.sync.connection.name=Set connection fro
command.org.jkiss.dbeaver.ui.editors.sql.sync.connection.description
=
Set active connection from database navigator selection
command.org.jkiss.dbeaver.ui.editors.sql.sync.auto.name
=
Auto-sync connection with navigator
command.org.jkiss.dbeaver.ui.editors.sql.sync.auto.description
=
Auto-sync active connection with database navigator selection
command.org.jkiss.dbeaver.ui.editors.sql.connection.separate.name
=
Open separate connection
command.org.jkiss.dbeaver.ui.editors.sql.connection.separate.description
=
Open separate connection
command.org.jkiss.dbeaver.ui.editors.sql.rename.name
=
Rename SQL Script
command.org.jkiss.dbeaver.ui.editors.sql.rename.description
=
Rename current SQL script
command.org.jkiss.dbeaver.ui.editors.sql.deleteThisScript.name
=
Delete this script
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/plugin.xml
浏览文件 @
6fed5501
...
...
@@ -246,6 +246,7 @@
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.assist.templates"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.assist.templates.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.assist.templates.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.sync.connection"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.sync.connection.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.sync.connection.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.sync.auto"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.sync.auto.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.sync.auto.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.connection.separate"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.connection.separate.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.connection.separate.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.rename"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.rename.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.rename.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.deleteThisScript"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.deleteThisScript.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.deleteThisScript.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
<command
id=
"org.jkiss.dbeaver.ui.editors.sql.close.tab"
name=
"%command.org.jkiss.dbeaver.ui.editors.sql.close.tab.name"
description=
"%command.org.jkiss.dbeaver.ui.editors.sql.close.tab.description"
categoryId=
"org.jkiss.dbeaver.core.sql"
/>
...
...
@@ -485,6 +486,7 @@
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.ui.editors.sql.sync.auto"
class=
"org.jkiss.dbeaver.ui.editors.sql.handlers.SQLEditorHandlerSyncConnectionAuto"
/>
<handler
commandId=
"org.jkiss.dbeaver.ui.editors.sql.connection.separate"
class=
"org.jkiss.dbeaver.ui.editors.sql.handlers.SQLEditorHandlerSeparateConnectionOption"
/>
<handler
commandId=
"org.jkiss.dbeaver.ui.editors.sql.export.data"
class=
"org.jkiss.dbeaver.ui.editors.sql.handlers.SQLEditorHandlerExportData"
>
<enabledWhen>
<with
variable=
"activeEditor"
>
...
...
@@ -598,7 +600,9 @@
<command
commandId=
"org.jkiss.dbeaver.core.sql.editor.open"
/>
<command
commandId=
"org.jkiss.dbeaver.core.sql.editor.recent"
/>
<command
commandId=
"org.jkiss.dbeaver.core.sql.editor.create"
/>
<separator
name=
"execute"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.run.statement"
>
<visibleWhen>
<with
variable=
"activeEditor"
>
...
...
@@ -648,8 +652,11 @@
</with>
</visibleWhen>
</command>
<separator
name=
"query"
visible=
"true"
/>
<separator
name=
"plan"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.run.explain"
>
<visibleWhen>
<with
variable=
"activeEditor"
>
...
...
@@ -664,7 +671,9 @@
</with>
</visibleWhen>
</command>
<separator
name=
"files"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.open.file"
>
<visibleWhen>
<with
variable=
"activeEditor"
>
...
...
@@ -679,17 +688,22 @@
</with>
</visibleWhen>
</command>
<separator
name=
"misc"
visible=
"true"
/>
<separator
name=
"layout"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.toggle.result.panel"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.maximize.result.panel"
style=
"push"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.switch.panel"
/>
<separator
name=
"
sync
"
visible=
"true"
/>
<separator
name=
"
context
"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.tools.select.connection"
><parameter
name=
"noCustomLabel"
value=
"true"
/></command>
<command
commandId=
"org.jkiss.dbeaver.ui.tools.select.schema"
><parameter
name=
"noCustomLabel"
value=
"true"
/></command>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.sync.connection"
/>
<separator
name=
"options"
visible=
"true"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.sync.auto"
style=
"toggle"
/>
<command
commandId=
"org.jkiss.dbeaver.ui.editors.sql.connection.separate"
style=
"toggle"
/>
</menu>
</menuContribution>
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
6fed5501
...
...
@@ -391,7 +391,7 @@ public class SQLEditor extends SQLEditorBase implements
}
}
private
void
initSeparateConnection
(
DBPDataSource
dataSource
,
Runnable
onSuccess
)
{
private
void
initSeparateConnection
(
@NotNull
DBPDataSource
dataSource
,
Runnable
onSuccess
)
{
DBSInstance
dsInstance
=
dataSource
.
getDefaultInstance
();
String
[]
contextDefaults
=
EditorUtils
.
getInputContextDefaults
(
getEditorInput
());
if
(
contextDefaults
.
length
>
0
&&
contextDefaults
[
0
]
!=
null
)
{
...
...
@@ -1985,6 +1985,18 @@ public class SQLEditor extends SQLEditorBase implements
return
createScriptContext
().
fillQueryParameters
(
query
,
false
);
}
// Called on OPEN_SEPARATE_CONNECTION optio nchange
public
void
updateExecutionContextState
()
{
// Save current datasource (we want to keep it here)
DBPDataSource
dataSource
=
curDataSource
;
releaseExecutionContext
();
// Restore cur data source (as it is reset in releaseExecutionContext)
curDataSource
=
dataSource
;
if
(
dataSource
!=
null
&&
SQLEditorUtils
.
isOpenSeparateConnection
(
dataSource
.
getContainer
()))
{
initSeparateConnection
(
dataSource
,
null
);
}
}
private
boolean
checkSession
(
DBRProgressListener
onFinish
)
throws
DBException
{
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditorCommands.java
浏览文件 @
6fed5501
...
...
@@ -50,5 +50,6 @@ public interface SQLEditorCommands
String
CMD_NAVIGATE_OBJECT
=
"org.jkiss.dbeaver.ui.editors.sql.navigate.object"
;
String
CMD_TOGGLE_LAYOUT
=
"org.jkiss.dbeaver.ui.editors.sql.toggleLayout"
;
String
CMD_TOGGLE_SEPARATE_CONNECTION
=
"org.jkiss.dbeaver.ui.editors.sql.connection.separate"
;
}
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/handlers/SQLEditorHandlerSeparateConnectionOption.java
0 → 100644
浏览文件 @
6fed5501
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.editors.sql.handlers
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.ui.IEditorPart
;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditor
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLPreferenceConstants
;
import
org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages
;
import
java.io.IOException
;
import
java.util.Map
;
public
class
SQLEditorHandlerSeparateConnectionOption
extends
AbstractDataSourceHandler
implements
IElementUpdater
{
public
SQLEditorHandlerSeparateConnectionOption
()
{
}
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
final
DBPPreferenceStore
prefs
=
getPreferenceStore
(
event
);
prefs
.
setValue
(
SQLPreferenceConstants
.
EDITOR_SEPARATE_CONNECTION
,
!
prefs
.
getBoolean
(
SQLPreferenceConstants
.
EDITOR_SEPARATE_CONNECTION
));
try
{
prefs
.
save
();
}
catch
(
IOException
e
)
{
throw
new
ExecutionException
(
"Error saving configuration"
,
e
);
}
IEditorPart
editor
=
HandlerUtil
.
getActiveEditor
(
event
);
if
(
editor
instanceof
SQLEditor
)
{
((
SQLEditor
)
editor
).
updateExecutionContextState
();
}
return
null
;
}
@NotNull
private
DBPPreferenceStore
getPreferenceStore
(
ExecutionEvent
event
)
{
DBPDataSourceContainer
dsContainer
=
getActiveDataSourceContainer
(
event
,
false
);
return
dsContainer
==
null
?
DBWorkbench
.
getPlatform
().
getPreferenceStore
()
:
dsContainer
.
getPreferenceStore
();
}
@Override
public
void
updateElement
(
UIElement
element
,
Map
parameters
)
{
element
.
setText
(
SQLEditorMessages
.
pref_page_sql_editor_label_separate_connection_each_editor
);
element
.
setTooltip
(
SQLEditorMessages
.
pref_page_sql_editor_label_separate_connection_each_editor
);
IEditorPart
activeEditor
=
UIUtils
.
getActiveWorkbenchWindow
().
getActivePage
().
getActiveEditor
();
DBPDataSourceContainer
dsContainer
=
activeEditor
==
null
?
null
:
getDataSourceContainerFromPart
(
activeEditor
);
DBPPreferenceStore
prefStore
=
dsContainer
==
null
?
DBWorkbench
.
getPlatform
().
getPreferenceStore
()
:
dsContainer
.
getPreferenceStore
();
element
.
setChecked
(
prefStore
.
getBoolean
(
SQLPreferenceConstants
.
EDITOR_SEPARATE_CONNECTION
));
}
}
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/handlers/SQLEditorHandlerSyncConnectionAuto.java
浏览文件 @
6fed5501
...
...
@@ -25,6 +25,7 @@ import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorPreferences
;
import
java.io.IOException
;
import
java.util.Map
;
public
class
SQLEditorHandlerSyncConnectionAuto
extends
AbstractHandler
implements
IElementUpdater
{
...
...
@@ -39,6 +40,13 @@ public class SQLEditorHandlerSyncConnectionAuto extends AbstractHandler implemen
final
DBPPreferenceStore
prefs
=
DBWorkbench
.
getPlatform
().
getPreferenceStore
();
prefs
.
setValue
(
NavigatorPreferences
.
NAVIGATOR_SYNC_EDITOR_DATASOURCE
,
!
prefs
.
getBoolean
(
NavigatorPreferences
.
NAVIGATOR_SYNC_EDITOR_DATASOURCE
));
try
{
prefs
.
save
();
}
catch
(
IOException
e
)
{
throw
new
ExecutionException
(
"Error saving configuration"
,
e
);
}
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/AbstractDataSourceHandler.java
浏览文件 @
6fed5501
...
...
@@ -39,8 +39,7 @@ public abstract class AbstractDataSourceHandler extends AbstractHandler {
/**
* Get execution context from active editor or active selection
*/
public
static
DBCExecutionContext
getActiveExecutionContext
(
ExecutionEvent
event
,
boolean
useEditor
)
{
public
static
DBCExecutionContext
getActiveExecutionContext
(
ExecutionEvent
event
,
boolean
useEditor
)
{
if
(
useEditor
)
{
IEditorPart
editor
=
HandlerUtil
.
getActiveEditor
(
event
);
if
(
editor
instanceof
DBPContextProvider
)
{
...
...
@@ -63,8 +62,7 @@ public abstract class AbstractDataSourceHandler extends AbstractHandler {
return
null
;
}
public
static
DBSObject
getActiveObject
(
ExecutionEvent
event
)
{
public
static
DBSObject
getActiveObject
(
ExecutionEvent
event
)
{
IWorkbenchPart
activePart
=
HandlerUtil
.
getActivePart
(
event
);
IStructuredSelection
navSelection
=
NavigatorUtils
.
getSelectionFromPart
(
activePart
);
...
...
@@ -78,16 +76,14 @@ public abstract class AbstractDataSourceHandler extends AbstractHandler {
return
null
;
}
public
static
DBCExecutionContext
getExecutionContextFromPart
(
IWorkbenchPart
activePart
)
{
public
static
DBCExecutionContext
getExecutionContextFromPart
(
IWorkbenchPart
activePart
)
{
if
(
activePart
instanceof
DBPContextProvider
)
{
return
((
DBPContextProvider
)
activePart
).
getExecutionContext
();
}
return
null
;
}
public
static
DBPDataSourceContainer
getActiveDataSourceContainer
(
ExecutionEvent
event
,
boolean
useEditor
)
{
public
static
DBPDataSourceContainer
getActiveDataSourceContainer
(
ExecutionEvent
event
,
boolean
useEditor
)
{
if
(
useEditor
)
{
IEditorPart
editor
=
HandlerUtil
.
getActiveEditor
(
event
);
if
(
editor
!=
null
)
{
...
...
@@ -107,7 +103,7 @@ public abstract class AbstractDataSourceHandler extends AbstractHandler {
DBSObject
selectedObject
=
NavigatorUtils
.
getSelectedObject
(
selection
);
if
(
selectedObject
instanceof
DBPDataSourceContainer
)
{
return
(
DBPDataSourceContainer
)
selectedObject
;
return
(
DBPDataSourceContainer
)
selectedObject
;
}
else
if
(
selectedObject
!=
null
)
{
DBPDataSource
dataSource
=
selectedObject
.
getDataSource
();
return
dataSource
==
null
?
null
:
dataSource
.
getContainer
();
...
...
@@ -116,8 +112,7 @@ public abstract class AbstractDataSourceHandler extends AbstractHandler {
return
null
;
}
public
static
DBPDataSourceContainer
getDataSourceContainerFromPart
(
IWorkbenchPart
activePart
)
{
public
static
DBPDataSourceContainer
getDataSourceContainerFromPart
(
IWorkbenchPart
activePart
)
{
if
(
activePart
instanceof
IDataSourceContainerProvider
)
{
return
((
IDataSourceContainerProvider
)
activePart
).
getDataSourceContainer
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录