Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
475875c1
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,发现更多精彩内容 >>
提交
475875c1
编写于
4月 20, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3324 PG: create function dialog redesign. Language selector
上级
0e04ee30
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
30 deletion
+89
-30
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateProcedurePage.java
...dbeaver/ui/editors/object/struct/CreateProcedurePage.java
+27
-21
plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties
...ss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties
+3
-3
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreProcedureManager.java
.../dbeaver/ext/postgresql/edit/PostgreProcedureManager.java
+54
-5
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
.../jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
+5
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateProcedurePage.java
浏览文件 @
475875c1
...
...
@@ -32,6 +32,7 @@ import org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer;
import
org.jkiss.dbeaver.model.struct.DBSObjectContainer
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSProcedureType
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.utils.ArrayUtils
;
public
class
CreateProcedurePage
extends
BaseObjectEditPage
{
...
...
@@ -52,34 +53,39 @@ public class CreateProcedurePage extends BaseObjectEditPage {
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
propsGroup
.
setLayoutData
(
gd
);
UIUtils
.
createLabelText
(
propsGroup
,
"Container"
,
DBUtils
.
getObjectFullName
(
container
,
DBPEvaluationContext
.
UI
)).
setEditable
(
false
);
final
Text
containerText
=
UIUtils
.
createLabelText
(
propsGroup
,
"Container"
,
DBUtils
.
getObjectFullName
(
this
.
container
,
DBPEvaluationContext
.
UI
));
containerText
.
setEditable
(
false
);
final
Text
nameText
=
UIUtils
.
createLabelText
(
propsGroup
,
CoreMessages
.
dialog_struct_create_procedure_label_name
,
null
);
nameText
.
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
name
=
nameText
.
getText
();
}
});
final
Combo
typeCombo
=
UIUtils
.
createLabelCombo
(
propsGroup
,
CoreMessages
.
dialog_struct_create_procedure_combo_type
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
typeCombo
.
add
(
DBSProcedureType
.
PROCEDURE
.
name
());
typeCombo
.
add
(
DBSProcedureType
.
FUNCTION
.
name
());
typeCombo
.
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
nameText
.
addModifyListener
(
e
->
name
=
nameText
.
getText
());
if
(
getPredefinedProcedureType
()
==
null
)
{
final
Combo
typeCombo
=
UIUtils
.
createLabelCombo
(
propsGroup
,
CoreMessages
.
dialog_struct_create_procedure_combo_type
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
typeCombo
.
add
(
DBSProcedureType
.
PROCEDURE
.
name
());
typeCombo
.
add
(
DBSProcedureType
.
FUNCTION
.
name
());
typeCombo
.
addModifyListener
(
e
->
{
type
=
typeCombo
.
getSelectionIndex
()
==
0
?
DBSProcedureType
.
PROCEDURE
:
DBSProcedureType
.
FUNCTION
;
nameText
.
setText
(
type
==
DBSProcedureType
.
PROCEDURE
?
"NewProcedure"
:
"NewFunction"
);
//$NON-NLS-1$ //$NON-NLS-2$
}
});
typeCombo
.
select
(
0
);
propsGroup
.
setTabList
(
new
Control
[]
{
nameText
,
typeCombo
}
);
});
typeCombo
.
select
(
0
);
}
propsGroup
.
setTabList
(
ArrayUtils
.
remove
(
Control
.
class
,
propsGroup
.
getTabList
(),
containerText
));
createExtraControls
(
propsGroup
);
return
propsGroup
;
}
protected
void
createExtraControls
(
Composite
group
)
{
}
public
DBSProcedureType
getProcedureType
()
{
return
type
;
DBSProcedureType
procedureType
=
getPredefinedProcedureType
();
return
procedureType
==
null
?
type
:
procedureType
;
}
public
DBSProcedureType
getPredefinedProcedureType
()
{
return
null
;
}
public
String
getProcedureName
()
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties
浏览文件 @
475875c1
...
...
@@ -498,9 +498,9 @@ tree.mview.node.name=Materialized View
tree.mviews.node.name
=
Materialized Views
tree.package.node.name
=
Package
tree.packages.node.name
=
Packages
tree.procedure.node.name
=
Procedure
tree.procedure_columns.node.name
=
Procedure Column
s
tree.procedures.node.name
=
Procedure
s
tree.procedure.node.name
=
Function
tree.procedure_columns.node.name
=
Function parameter
s
tree.procedures.node.name
=
Function
s
tree.reference.node.name
=
Reference
tree.reference_columns.node.name
=
Reference columns
tree.references.node.name
=
References
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreProcedureManager.java
浏览文件 @
475875c1
...
...
@@ -16,9 +16,14 @@
*/
package
org.jkiss.dbeaver.ext.postgresql.edit
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreLanguage
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
...
...
@@ -31,10 +36,14 @@ import org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSProcedureType
;
import
org.jkiss.dbeaver.ui.UITask
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.object.struct.CreateProcedurePage
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -61,7 +70,7 @@ public class PostgreProcedureManager extends SQLObjectEditor<PostgreProcedure, P
throws
DBException
{
if
(
CommonUtils
.
isEmpty
(
command
.
getObject
().
getName
()))
{
throw
new
DBException
(
"
Procedure
name cannot be empty"
);
throw
new
DBException
(
"
Function
name cannot be empty"
);
}
}
...
...
@@ -71,12 +80,13 @@ public class PostgreProcedureManager extends SQLObjectEditor<PostgreProcedure, P
return
new
UITask
<
PostgreProcedure
>()
{
@Override
protected
PostgreProcedure
runTask
()
{
Create
ProcedurePage
editPage
=
new
CreateProcedurePage
(
parent
);
Create
FunctionPage
editPage
=
new
CreateFunctionPage
(
parent
,
monitor
);
if
(!
editPage
.
edit
())
{
return
null
;
}
PostgreProcedure
newProcedure
=
new
PostgreProcedure
(
parent
);
newProcedure
.
setName
(
editPage
.
getProcedureName
());
newProcedure
.
setLanguage
(
editPage
.
getLanguage
());
return
newProcedure
;
}
}.
execute
();
...
...
@@ -101,21 +111,21 @@ public class PostgreProcedureManager extends SQLObjectEditor<PostgreProcedure, P
{
String
objectType
=
command
.
getObject
().
getProcedureTypeName
();
actions
.
add
(
new
SQLDatabasePersistAction
(
"Drop
procedure
"
,
"DROP "
+
objectType
+
" "
+
command
.
getObject
().
getFullQualifiedSignature
())
//$NON-NLS-2$
new
SQLDatabasePersistAction
(
"Drop
function
"
,
"DROP "
+
objectType
+
" "
+
command
.
getObject
().
getFullQualifiedSignature
())
//$NON-NLS-2$
);
}
private
void
createOrReplaceProcedureQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreProcedure
procedure
)
{
actions
.
add
(
new
SQLDatabasePersistAction
(
"Create
procedure
"
,
procedure
.
getBody
(),
true
));
new
SQLDatabasePersistAction
(
"Create
function
"
,
procedure
.
getBody
(),
true
));
}
@Override
protected
void
addObjectExtraActions
(
List
<
DBEPersistAction
>
actions
,
NestedObjectCommand
<
PostgreProcedure
,
PropertyHandler
>
command
,
Map
<
String
,
Object
>
options
)
{
if
(
command
.
getProperty
(
"description"
)
!=
null
)
{
actions
.
add
(
new
SQLDatabasePersistAction
(
"Comment
procedure
"
,
"Comment
function
"
,
"COMMENT ON "
+
command
.
getObject
().
getProcedureTypeName
()
+
" "
+
command
.
getObject
().
getFullQualifiedSignature
()
+
" IS "
+
SQLUtils
.
quoteString
(
command
.
getObject
(),
command
.
getObject
().
getDescription
())));
}
...
...
@@ -131,5 +141,44 @@ public class PostgreProcedureManager extends SQLObjectEditor<PostgreProcedure, P
}
private
static
class
CreateFunctionPage
extends
CreateProcedurePage
{
private
final
PostgreSchema
parent
;
private
final
DBRProgressMonitor
monitor
;
PostgreLanguage
language
;
public
CreateFunctionPage
(
PostgreSchema
parent
,
DBRProgressMonitor
monitor
)
{
super
(
parent
);
this
.
parent
=
parent
;
this
.
monitor
=
monitor
;
}
@Override
public
DBSProcedureType
getPredefinedProcedureType
()
{
return
DBSProcedureType
.
FUNCTION
;
}
@Override
protected
void
createExtraControls
(
Composite
group
)
{
List
<
PostgreLanguage
>
languages
=
new
ArrayList
<>();
try
{
languages
.
addAll
(
parent
.
getDatabase
().
getLanguages
(
monitor
));
}
catch
(
DBException
e
)
{
log
.
error
(
e
);
}
final
Combo
languageCombo
=
UIUtils
.
createLabelCombo
(
group
,
"Language"
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
for
(
PostgreLanguage
lang
:
languages
)
{
languageCombo
.
add
(
lang
.
getName
());
}
languageCombo
.
addModifyListener
(
e
->
{
language
=
languages
.
get
(
languageCombo
.
getSelectionIndex
());
});
languageCombo
.
setText
(
"sql"
);
}
public
PostgreLanguage
getLanguage
()
{
return
language
;
}
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
浏览文件 @
475875c1
...
...
@@ -278,7 +278,7 @@ public class PostgreProcedure extends AbstractProcedure<PostgreDataSource, Postg
if
(!
isPersisted
())
{
body
=
"CREATE OR REPLACE FUNCTION "
+
getFullQualifiedSignature
()
+
GeneralUtils
.
getDefaultLineSeparator
()
+
"RETURNS INT"
+
GeneralUtils
.
getDefaultLineSeparator
()
+
"LANGUAGE
sql "
+
GeneralUtils
.
getDefaultLineSeparator
()
+
"LANGUAGE
"
+
getLanguage
(
monitor
).
getName
()
+
GeneralUtils
.
getDefaultLineSeparator
()
+
"AS $function$ "
+
GeneralUtils
.
getDefaultLineSeparator
()
+
" $function$"
;
}
else
if
(
oid
==
0
||
isAggregate
)
{
// No OID so let's use old (bad) way
...
...
@@ -327,6 +327,10 @@ public class PostgreProcedure extends AbstractProcedure<PostgreDataSource, Postg
return
PostgreUtils
.
getObjectById
(
monitor
,
container
.
getDatabase
().
languageCache
,
container
.
getDatabase
(),
languageId
);
}
public
void
setLanguage
(
PostgreLanguage
language
)
{
this
.
languageId
=
language
.
getObjectId
();
}
@Property
(
category
=
CAT_PROPS
,
viewable
=
true
,
order
=
12
)
public
PostgreDataType
getReturnType
()
{
return
returnType
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录