Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
7dc33f35
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,发现更多精彩内容 >>
提交
7dc33f35
编写于
8月 06, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3640 SQL parameters binding dialog enhancement (hide variables)
Former-commit-id:
2c8cbdbf
上级
8f352cf3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
42 deletion
+89
-42
nls/bundles/org.jkiss.dbeaver.core.nls/src/org/jkiss/dbeaver/core/CoreResources_ru.properties
...ls/src/org/jkiss/dbeaver/core/CoreResources_ru.properties
+6
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
...dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
+7
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreResources.properties
....core/src/org/jkiss/dbeaver/core/CoreResources.properties
+6
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryJob.java
...r.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryJob.java
+17
-16
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
...kiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
+44
-26
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLQueryParameter.java
...el/src/org/jkiss/dbeaver/model/sql/SQLQueryParameter.java
+9
-0
未找到文件。
nls/bundles/org.jkiss.dbeaver.core.nls/src/org/jkiss/dbeaver/core/CoreResources_ru.properties
浏览文件 @
7dc33f35
...
...
@@ -443,3 +443,9 @@ editor_binary_hex_status_line_value=\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u
dialog_connection_driver=
\u0414\u0440\u0430\u0439\u0432\u0435\u0440
:
dialog_connection_edit_driver_button
=
\u
041D
\u0430\u0441\u0442\u0440\u
043E
\u0439\u
043A
\u0438
\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430
dialog_sql_param_title
=
\u
041F
\u0440\u0438\u0432\u
044F
\u0437\u
043A
\u0430
\u
043F
\u0430\u0440\u0430\u
043C
\u0435\u0442\u0440\u
043E
\u0432
dialog_sql_param_column_name
=
\u0418\u
043C
\u
044F
dialog_sql_param_column_value
=
\u0417\u
043D
\u0430\u0447\u0435\u
043D
\u0438\u0435
dialog_sql_param_hide_checkbox
=
\u0421\u
043A
\u0440\u
044B
\u0442\u
044C
\u
043F
\u0430\u0440\u0430\u
043C
\u0435\u0442\u0440\u
044B
\u0443\u0441\u0442\u0430\u
043D
\u
043E
\u0432\u
043B
\u0435\u
043D
\u
043D
\u
044B
\u0435
\u0441\u
043A
\u0440\u0438\u
043F
\u0442\u
043E
\u
043C
dialog_sql_param_hide_checkbox_tip
=
\u
041D
\u0435
\u
043F
\u
043E
\u
043A
\u0430\u0437\u
044B
\u0432\u0430\u0442\u
044C
\u
043F
\u0430\u0440\u0430\u
043C
\u0435\u0442\u0440\u
044B,
\u
043A
\u
043E
\u0442\u
043E
\u0440\u
044B
\u0435
\u0431\u
044B
\u
043B
\u0438
\u0443\u0441\u0442\u
043D
\u
043E
\u0432\u
043B
\u0435\u
043D
\u
044B
\u
043A
\u
043E
\u
043C
\u0430\u
043D
\u0434\u
043E
\u0439
@set
\u0432
\u0441\u
043A
\u0440\u0438\u
043F
\u0442\u0435
dialog_sql_param_hint
=
\u0418\u0441\u
043F
\u
043E
\u
043B
\u
044C
\u0437\u0443\u0439\u0442\u0435
Tab
\u0434\u
043B
\u
044F
\u
043F
\u0435\u0440\u0435\u
043A
\u
043B
\u
044E
\u0447\u0435\u
043D
\u0438\u
044F.
\u0421\u0442\u0440\u
043E
\u
043A
\u
043E
\u0432\u
044B
\u0435
\u0437\u
043D
\u0430\u0447\u0435\u
043D
\u0438\u
044F
\u0434\u
043E
\u
043B
\u0436\u
043D
\u0430
\u0431\u
044B
\u0442\u
044C
\u0432
\u
043A
\u0430\u0432\u
044B
\u0447\u
043A
\u0430\u0445
.
\u
041C
\u
043E
\u0436\u
043D
\u
043E
\u0438\u0441\u
043F
\u
043E
\u
043B
\u
044C
\u0437\u
043E
\u0432\u0430\u0442\u
044C SQL
\u0432\u
044B
\u0440\u0430\u0436\u0435\u
043D
\u0438\u
044F.
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
浏览文件 @
7dc33f35
...
...
@@ -692,6 +692,13 @@ public class CoreMessages extends NLS {
public
static
String
dialog_view_sql_button_copy
;
public
static
String
dialog_view_sql_button_persist
;
public
static
String
dialog_sql_param_title
;
public
static
String
dialog_sql_param_column_name
;
public
static
String
dialog_sql_param_column_value
;
public
static
String
dialog_sql_param_hide_checkbox
;
public
static
String
dialog_sql_param_hide_checkbox_tip
;
public
static
String
dialog_sql_param_hint
;
public
static
String
editor_binary_hex_default_font
;
public
static
String
editor_binary_hex_font_style_bold
;
public
static
String
editor_binary_hex_font_style_bold_italic
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreResources.properties
浏览文件 @
7dc33f35
...
...
@@ -684,6 +684,12 @@ dialog_view_classpath_title = System Classpath
dialog_view_sql_button_copy
=
Copy
dialog_view_sql_button_persist
=
Persist
dialog_sql_param_title
=
Bind parameter(s)
dialog_sql_param_column_name
=
Name
dialog_sql_param_column_value
=
Value
dialog_sql_param_hide_checkbox
=
Hide parameters set in script
dialog_sql_param_hide_checkbox_tip
=
Do not show parameters which were set in script by @set command
dialog_sql_param_hint
=
Use Tab to switch. String values must be quoted. You can use expressions in values
editor_binary_hex_default_font
=
default font
editor_binary_hex_font_style_bold
=
Bold
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryJob.java
浏览文件 @
7dc33f35
...
...
@@ -609,36 +609,37 @@ public class SQLQueryJob extends DataSourceJob
private
boolean
fillStatementParameters
(
final
List
<
SQLQueryParameter
>
parameters
)
{
boolean
allSet
=
true
;
for
(
SQLQueryParameter
param
:
parameters
)
{
if
(
param
.
getValue
()
==
null
)
{
allSet
=
false
;
}
String
paramName
=
param
.
getTitle
();
if
(
scriptContext
.
hasVariable
(
paramName
))
{
Object
varValue
=
scriptContext
.
getVariable
(
paramName
);
String
strValue
;
/*if (varValue instanceof String) {
strValue = SQLUtils.quoteString(getExecutionContext().getDataSource(), (String) varValue);
} else */
{
strValue
=
varValue
==
null
?
null
:
varValue
.
toString
();
}
String
strValue
=
varValue
==
null
?
null
:
varValue
.
toString
();
param
.
setValue
(
strValue
);
param
.
setVariableSet
(
true
);
}
else
{
param
.
setVariableSet
(
false
);
}
}
boolean
allSet
=
true
;
for
(
SQLQueryParameter
param
:
parameters
)
{
if
(!
param
.
isVariableSet
())
{
allSet
=
false
;
}
}
if
(
allSet
)
{
return
true
;
}
boolean
okPressed
=
true
;
okPressed
=
new
UIConfirmation
()
{
@Override
public
Boolean
runTask
()
{
boolean
okPressed
=
new
UIConfirmation
()
{
@Override
public
Boolean
runTask
()
{
SQLQueryParameterBindDialog
dialog
=
new
SQLQueryParameterBindDialog
(
partSite
.
getShell
(),
parameters
);
partSite
.
getShell
(),
parameters
);
return
(
dialog
.
open
()
==
IDialogConstants
.
OK_ID
);
}
}.
execute
();
if
(
okPressed
)
{
// Save values back to script context
for
(
SQLQueryParameter
param
:
parameters
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/sql/SQLQueryParameterBindDialog.java
浏览文件 @
7dc33f35
...
...
@@ -19,8 +19,11 @@ package org.jkiss.dbeaver.runtime.sql;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.dialogs.StatusDialog
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.sql.SQLQueryParameter
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
...
...
@@ -46,6 +49,7 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
private
static
Map
<
String
,
SQLQueryParameterRegistry
.
ParameterInfo
>
savedParamValues
=
new
HashMap
<>();
private
Button
hideIfSetCheck
;
private
Table
paramTable
;
public
SQLQueryParameterBindDialog
(
Shell
shell
,
List
<
SQLQueryParameter
>
parameters
)
{
...
...
@@ -84,10 +88,10 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
getShell
().
setText
(
"Bind parameter(s)"
);
getShell
().
setText
(
CoreMessages
.
dialog_sql_param_title
);
final
Composite
composite
=
(
Composite
)
super
.
createDialogArea
(
parent
);
final
Table
paramTable
=
new
Table
(
composite
,
SWT
.
SINGLE
|
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
paramTable
=
new
Table
(
composite
,
SWT
.
SINGLE
|
SWT
.
FULL_SELECTION
|
SWT
.
BORDER
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
final
GridData
gd
=
new
GridData
(
GridData
.
FILL_BOTH
);
gd
.
widthHint
=
400
;
gd
.
heightHint
=
200
;
...
...
@@ -97,25 +101,12 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
final
TableColumn
indexColumn
=
UIUtils
.
createTableColumn
(
paramTable
,
SWT
.
LEFT
,
"#"
);
indexColumn
.
setWidth
(
40
);
final
TableColumn
nameColumn
=
UIUtils
.
createTableColumn
(
paramTable
,
SWT
.
LEFT
,
"Name"
);
final
TableColumn
nameColumn
=
UIUtils
.
createTableColumn
(
paramTable
,
SWT
.
LEFT
,
CoreMessages
.
dialog_sql_param_column_name
);
nameColumn
.
setWidth
(
100
);
final
TableColumn
valueColumn
=
UIUtils
.
createTableColumn
(
paramTable
,
SWT
.
LEFT
,
"Value"
);
final
TableColumn
valueColumn
=
UIUtils
.
createTableColumn
(
paramTable
,
SWT
.
LEFT
,
CoreMessages
.
dialog_sql_param_column_value
);
valueColumn
.
setWidth
(
200
);
for
(
SQLQueryParameter
param
:
parameters
)
{
if
(
param
.
getPrevious
()
!=
null
)
{
// Skip duplicates
List
<
SQLQueryParameter
>
dups
=
dupParameters
.
computeIfAbsent
(
param
.
getName
(),
k
->
new
ArrayList
<>());
dups
.
add
(
param
);
continue
;
}
TableItem
item
=
new
TableItem
(
paramTable
,
SWT
.
NONE
);
item
.
setData
(
param
);
item
.
setImage
(
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_ATTRIBUTE
));
item
.
setText
(
0
,
String
.
valueOf
(
param
.
getOrdinalPosition
()
+
1
));
item
.
setText
(
1
,
param
.
getTitle
());
item
.
setText
(
2
,
CommonUtils
.
notEmpty
(
param
.
getValue
()));
}
fillParameterList
(
isHideIfSet
());
final
CustomTableEditor
tableEditor
=
new
CustomTableEditor
(
paramTable
)
{
{
...
...
@@ -156,13 +147,6 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
}
};
/*
hideIfSetCheck = UIUtils.createCheckbox(composite,
"Do not show is all parameters are set",
"Do not show this dialog if all parameters were set as script variable",
getDialogBoundsSettings().getBoolean(PARAM_HIDE_IF_SET), 1);
*/
if
(!
parameters
.
isEmpty
())
{
UIUtils
.
asyncExec
(()
->
{
paramTable
.
select
(
0
);
...
...
@@ -170,10 +154,43 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
});
}
updateStatus
(
GeneralUtils
.
makeInfoStatus
(
"Use Tab to switch. String values must be quoted. You can use expressions in values"
));
hideIfSetCheck
=
UIUtils
.
createCheckbox
(
composite
,
CoreMessages
.
dialog_sql_param_hide_checkbox
,
CoreMessages
.
dialog_sql_param_hide_checkbox_tip
,
isHideIfSet
(),
1
);
hideIfSetCheck
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
fillParameterList
(
hideIfSetCheck
.
getSelection
());
}
});
updateStatus
(
GeneralUtils
.
makeInfoStatus
(
CoreMessages
.
dialog_sql_param_hint
));
return
composite
;
}
private
void
fillParameterList
(
boolean
hideVariables
)
{
paramTable
.
removeAll
();
for
(
SQLQueryParameter
param
:
parameters
)
{
if
(
hideVariables
&&
param
.
isVariableSet
())
{
continue
;
}
if
(
param
.
getPrevious
()
!=
null
)
{
// Skip duplicates
List
<
SQLQueryParameter
>
dups
=
dupParameters
.
computeIfAbsent
(
param
.
getName
(),
k
->
new
ArrayList
<>());
dups
.
add
(
param
);
continue
;
}
TableItem
item
=
new
TableItem
(
paramTable
,
SWT
.
NONE
);
item
.
setData
(
param
);
item
.
setImage
(
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_ATTRIBUTE
));
item
.
setText
(
0
,
String
.
valueOf
(
param
.
getOrdinalPosition
()
+
1
));
item
.
setText
(
1
,
param
.
getTitle
());
item
.
setText
(
2
,
CommonUtils
.
notEmpty
(
param
.
getValue
()));
}
}
@Override
protected
void
okPressed
()
{
...
...
@@ -191,4 +208,5 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
public
static
boolean
isHideIfSet
()
{
return
UIUtils
.
getDialogSettings
(
DIALOG_ID
).
getBoolean
(
PARAM_HIDE_IF_SET
);
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLQueryParameter.java
浏览文件 @
7dc33f35
...
...
@@ -25,6 +25,7 @@ public class SQLQueryParameter {
private
int
ordinalPosition
;
private
String
name
;
private
String
value
;
private
boolean
variableSet
;
private
final
int
tokenOffset
;
private
final
int
tokenLength
;
private
SQLQueryParameter
previous
;
...
...
@@ -88,6 +89,14 @@ public class SQLQueryParameter {
this
.
value
=
value
;
}
public
boolean
isVariableSet
()
{
return
variableSet
;
}
public
void
setVariableSet
(
boolean
variableSet
)
{
this
.
variableSet
=
variableSet
;
}
public
String
getTitle
()
{
if
(
GeneralUtils
.
isVariablePattern
(
name
))
{
return
GeneralUtils
.
stripVariablePattern
(
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录