Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
a95e7744
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,发现更多精彩内容 >>
提交
a95e7744
编写于
7月 06, 2021
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#11533 Variable add/remove + assign action
上级
c69f21f6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
173 addition
and
3 deletion
+173
-3
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
+11
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/internal/SQLEditorMessages.java
...ss/dbeaver/ui/editors/sql/internal/SQLEditorMessages.java
+2
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/internal/SQLEditorMessages.properties
...aver/ui/editors/sql/internal/SQLEditorMessages.properties
+2
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/AssignVariableAction.java
...beaver/ui/editors/sql/variables/AssignVariableAction.java
+100
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/RemoveVariableAction.java
...beaver/ui/editors/sql/variables/RemoveVariableAction.java
+47
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/SQLVariablesPanel.java
...s/dbeaver/ui/editors/sql/variables/SQLVariablesPanel.java
+10
-2
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/dialogs/EnterNameDialog.java
....ui/src/org/jkiss/dbeaver/ui/dialogs/EnterNameDialog.java
+1
-1
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
a95e7744
...
...
@@ -102,6 +102,7 @@ import org.jkiss.dbeaver.ui.editors.sql.plan.ExplainPlanViewer;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationDescriptor
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor
;
import
org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationRegistry
;
import
org.jkiss.dbeaver.ui.editors.sql.variables.AssignVariableAction
;
import
org.jkiss.dbeaver.ui.editors.sql.variables.SQLVariablesPanel
;
import
org.jkiss.dbeaver.ui.editors.text.ScriptPositionColumn
;
import
org.jkiss.dbeaver.ui.navigator.INavigatorModelView
;
...
...
@@ -1160,6 +1161,16 @@ public class SQLEditor extends SQLEditorBase implements
}
}
});
if
(
activeTab
.
getData
()
instanceof
QueryResultsContainer
)
{
QueryResultsContainer
rc
=
((
QueryResultsContainer
)
activeTab
.
getData
());
if
(
rc
.
hasData
())
{
manager
.
add
(
new
AssignVariableAction
(
SQLEditor
.
this
,
rc
.
getQuery
().
getText
(),
true
,
false
));
}
}
}
if
(
pinnedTabsCount
>
1
||
resultTabsCount
>
1
||
(
activeTab
!=
null
&&
activeTab
.
getShowClose
()))
{
manager
.
add
(
new
Separator
());
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/internal/SQLEditorMessages.java
浏览文件 @
a95e7744
...
...
@@ -103,6 +103,8 @@ public class SQLEditorMessages extends NLS {
public
static
String
action_result_tabs_unpin_tab
;
public
static
String
action_result_tabs_set_name
;
public
static
String
action_result_tabs_set_name_title
;
public
static
String
action_result_tabs_assign_variable
;
public
static
String
action_result_tabs_assign_variable_sql
;
public
static
String
action_popup_sqleditor_layout_horizontal
;
public
static
String
action_popup_sqleditor_layout_vertical
;
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/internal/SQLEditorMessages.properties
浏览文件 @
a95e7744
...
...
@@ -260,6 +260,8 @@ action_result_tabs_pin_tab = Pin tab
action_result_tabs_unpin_tab
=
Unpin tab
action_result_tabs_set_name
=
Rename tab
action_result_tabs_set_name_title
=
New tab name
action_result_tabs_assign_variable
=
Assign variable
action_result_tabs_assign_variable_sql
=
Assign variable with query text value
action_popup_sqleditor_layout_detached
=
Detached
action_popup_sqleditor_layout_horizontal
=
Horizontal
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/AssignVariableAction.java
0 → 100644
浏览文件 @
a95e7744
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2021 DBeaver Corp and others
*
* 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.variables
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.PartInitException
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.EnterNameDialog
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
import
org.jkiss.dbeaver.ui.editors.SubEditorSite
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditor
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase
;
import
org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
public
class
AssignVariableAction
extends
Action
{
static
protected
final
Log
log
=
Log
.
getLog
(
AssignVariableAction
.
class
);
private
final
SQLEditor
editor
;
private
final
String
queryText
;
private
final
boolean
isQuery
;
private
final
boolean
isEditable
;
private
SQLEditorBase
valueEditor
;
public
AssignVariableAction
(
SQLEditor
editor
,
String
varValue
,
boolean
isQuery
,
boolean
isEditable
)
{
super
(
SQLEditorMessages
.
action_result_tabs_assign_variable
);
this
.
editor
=
editor
;
this
.
queryText
=
varValue
;
this
.
isQuery
=
isQuery
;
this
.
isEditable
=
isEditable
;
}
@Override
public
void
run
()
{
EnterNameDialog
dialog
=
new
EnterNameDialog
(
editor
.
getEditorControlWrapper
().
getShell
(),
isQuery
?
SQLEditorMessages
.
action_result_tabs_assign_variable_sql
:
SQLEditorMessages
.
action_result_tabs_assign_variable
,
""
)
{
@Override
protected
IDialogSettings
getDialogBoundsSettings
()
{
return
UIUtils
.
getDialogSettings
(
"DBeaver.SQLEditor.AssignVariableDialog"
);
//$NON-NLS-1$
}
@Override
protected
Composite
createDialogArea
(
Composite
parent
)
{
final
Composite
area
=
super
.
createDialogArea
(
parent
);
valueEditor
=
new
SQLEditorBase
()
{
@Nullable
@Override
public
DBCExecutionContext
getExecutionContext
()
{
return
editor
.
getExecutionContext
();
}
};
try
{
valueEditor
.
init
(
new
SubEditorSite
(
editor
.
getSite
()),
new
StringEditorInput
(
"Variable value"
,
queryText
,
!
isEditable
,
GeneralUtils
.
getDefaultFileEncoding
()));
}
catch
(
PartInitException
e
)
{
log
.
error
(
e
);
}
Composite
editorPH
=
UIUtils
.
createComposite
(
area
,
1
);
editorPH
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
UIUtils
.
createControlLabel
(
editorPH
,
isQuery
?
"Query"
:
"Value"
);
valueEditor
.
createPartControl
(
editorPH
);
valueEditor
.
getEditorControlWrapper
().
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
valueEditor
.
setWordWrap
(
true
);
valueEditor
.
reloadSyntaxRules
();
UIUtils
.
asyncExec
(()
->
propNameText
.
setFocus
());
return
area
;
}
};
if
(
dialog
.
open
()
==
IDialogConstants
.
OK_ID
)
{
editor
.
getGlobalScriptContext
().
setVariable
(
dialog
.
getResult
(),
queryText
);
}
}
}
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/RemoveVariableAction.java
0 → 100644
浏览文件 @
a95e7744
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2021 DBeaver Corp and others
*
* 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.variables
;
import
org.eclipse.jface.action.Action
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditor
;
import
org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages
;
public
class
RemoveVariableAction
extends
Action
{
static
protected
final
Log
log
=
Log
.
getLog
(
RemoveVariableAction
.
class
);
private
final
SQLEditor
editor
;
private
final
String
varName
;
public
RemoveVariableAction
(
SQLEditor
editor
,
String
varName
)
{
super
(
SQLEditorMessages
.
action_result_tabs_assign_variable
);
this
.
editor
=
editor
;
this
.
varName
=
varName
;
}
@Override
public
void
run
()
{
if
(
UIUtils
.
confirmAction
(
editor
.
getSite
().
getShell
(),
"Delete variable '"
+
varName
+
"'?"
,
"Delete variable '"
+
varName
+
"'?"
))
{
editor
.
getGlobalScriptContext
().
removeVariable
(
varName
);
}
}
}
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/variables/SQLVariablesPanel.java
浏览文件 @
a95e7744
...
...
@@ -123,6 +123,7 @@ public class SQLVariablesPanel extends Composite implements DBCScriptContextList
log
.
error
(
e
);
}
valueEditor
.
createPartControl
(
editorPH
);
valueEditor
.
setWordWrap
(
true
);
valueEditor
.
reloadSyntaxRules
();
//valueEditor.getEditorControl().setEnabled(false);
...
...
@@ -303,14 +304,21 @@ public class SQLVariablesPanel extends Composite implements DBCScriptContextList
addAction
=
new
Action
(
"Add variable"
,
DBeaverIcons
.
getImageDescriptor
(
UIIcon
.
ADD
))
{
@Override
public
void
run
()
{
super
.
run
();
AssignVariableAction
action
=
new
AssignVariableAction
(
mainEditor
,
""
,
false
,
true
);
action
.
run
();
}
};
contributionManager
.
add
(
addAction
);
deleteAction
=
new
Action
(
"Delete variable"
,
DBeaverIcons
.
getImageDescriptor
(
UIIcon
.
DELETE
))
{
@Override
public
void
run
()
{
super
.
run
();
if
(!
varsTable
.
getSelection
().
isEmpty
())
{
Object
varElement
=
((
IStructuredSelection
)
varsTable
.
getSelection
()).
getFirstElement
();
if
(
varElement
instanceof
DBCScriptContext
.
VariableInfo
)
{
RemoveVariableAction
action
=
new
RemoveVariableAction
(
mainEditor
,
((
DBCScriptContext
.
VariableInfo
)
varElement
).
name
);
action
.
run
();
}
}
}
};
deleteAction
.
setEnabled
(
false
);
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/dialogs/EnterNameDialog.java
浏览文件 @
a95e7744
...
...
@@ -31,7 +31,7 @@ public class EnterNameDialog extends Dialog {
private
String
propertyName
;
private
String
propertyValue
;
pr
ivate
Text
propNameText
;
pr
otected
Text
propNameText
;
private
String
result
;
public
EnterNameDialog
(
Shell
parentShell
,
String
propertyName
,
String
propertyValue
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录