Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
9ee376d7
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,发现更多精彩内容 >>
提交
9ee376d7
编写于
9月 25, 2020
作者:
N
Nikita Akilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#9518 fix codestyle
Former-commit-id:
3249d2ab
上级
f2496b1e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
10 addition
and
58 deletion
+10
-58
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/PostgreMessages.java
...src/org/jkiss/dbeaver/ext/postgresql/PostgreMessages.java
+1
-1
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/PostgresResources.properties
...jkiss/dbeaver/ext/postgresql/PostgresResources.properties
+1
-1
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
...kiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
+3
-50
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
...jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
+0
-2
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
...dbeaver/ext/postgresql/model/PostgreExecutionContext.java
+5
-4
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/PostgreMessages.java
浏览文件 @
9ee376d7
...
...
@@ -130,7 +130,7 @@ public class PostgreMessages extends NLS {
public
static
String
dialog_setting_sql_dd_tag_tip
;
public
static
String
dialog_setting_sql_dd_string
;
public
static
String
dialog_setting_sql_dd_code_block
;
public
static
String
dialog_setting_use_role
;
public
static
String
dialog_setting_use
r
_role
;
/* PostgreCreateRoleDialog */
public
static
String
dialog_create_role_title
;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/PostgresResources.properties
浏览文件 @
9ee376d7
...
...
@@ -108,7 +108,7 @@ dialog_setting_sql_dd_tag_label = Show $tagName$ quote as
dialog_setting_sql_dd_tag_tip
=
Show $tagName$ quotes as string quote or as code block quote
dialog_setting_sql_dd_string
=
String
dialog_setting_sql_dd_code_block
=
Code block
dialog_setting_use
_role
=
Use
role
dialog_setting_use
r_role
=
User
role
dialog_setting_connection_password
=
Password
dialog_setting_connection_port
=
Port
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
浏览文件 @
9ee376d7
...
...
@@ -21,7 +21,6 @@ import org.eclipse.swt.SWT;
import
org.eclipse.swt.events.ModifyListener
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Group
;
import
org.eclipse.swt.widgets.Text
;
...
...
@@ -29,35 +28,30 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.ext.postgresql.PostgreConstants
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreMessages
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreExecutionContext
;
import
org.jkiss.dbeaver.ext.postgresql.model.impls.PostgreServerType
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.ICompositeDialogPage
;
import
org.jkiss.dbeaver.ui.IDataSourceConnectionTester
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector
;
import
org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageWithAuth
;
import
org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Locale
;
/**
* PostgreConnectionPage
*/
public
class
PostgreConnectionPage
extends
ConnectionPageWithAuth
implements
ICompositeDialogPage
,
IDataSourceConnectionTester
{
public
class
PostgreConnectionPage
extends
ConnectionPageWithAuth
implements
ICompositeDialogPage
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreConnectionPage
.
class
);
private
Text
hostText
;
private
Text
portText
;
private
Text
dbText
;
private
Combo
roleCombo
;
private
Text
roleCombo
;
//TODO: make it a combo and fill it with appropriate roles
private
ClientHomesSelector
homesSelector
;
private
boolean
activated
=
false
;
...
...
@@ -108,7 +102,7 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
Group
advancedGroup
=
UIUtils
.
createControlGroup
(
mainGroup
,
"Advanced"
,
2
,
GridData
.
HORIZONTAL_ALIGN_BEGINNING
,
0
);
roleCombo
=
UIUtils
.
createLabel
Combo
(
advancedGroup
,
PostgreMessages
.
dialog_setting_use_role
,
SWT
.
DROP_DOWN
);
roleCombo
=
UIUtils
.
createLabel
Text
(
advancedGroup
,
PostgreMessages
.
dialog_setting_user_role
,
null
,
SWT
.
BORDER
);
roleCombo
.
setLayoutData
(
new
GridData
(
GridData
.
HORIZONTAL_ALIGN_BEGINNING
));
homesSelector
=
new
ClientHomesSelector
(
advancedGroup
,
PostgreMessages
.
dialog_setting_connection_localClient
,
false
);
...
...
@@ -203,45 +197,4 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
new
DriverPropertiesDialogPage
(
this
)
};
}
@Override
public
void
testConnection
(
final
DBCSession
session
)
{
try
{
updateRolesCombo
(
session
);
}
catch
(
DBCException
e
)
{
log
.
error
(
e
);
}
}
private
void
updateRolesCombo
(
final
DBCSession
session
)
throws
DBCException
{
final
Collection
<
String
>
result
=
new
ArrayList
<>();
final
String
userName
=
((
PostgreExecutionContext
)
session
.
getExecutionContext
()).
getActiveUser
();
session
.
getProgressMonitor
().
subTask
(
"Exec finding roles query"
);
final
String
query
=
"WITH RECURSIVE cte AS ("
+
" SELECT oid FROM pg_roles WHERE rolname = '"
+
userName
+
"'"
+
" UNION ALL"
+
" SELECT m.roleid"
+
" FROM cte"
+
" JOIN pg_auth_members m ON m.member = cte.oid"
+
" )"
+
"SELECT oid::regrole::text AS rolenames FROM cte;"
;
try
(
DBCStatement
dbStat
=
session
.
prepareStatement
(
DBCStatementType
.
QUERY
,
query
,
false
,
false
,
false
))
{
dbStat
.
executeStatement
();
try
(
DBCResultSet
dbResult
=
dbStat
.
openResultSet
())
{
while
(
dbResult
.
nextRow
())
{
result
.
add
(
CommonUtils
.
toString
(
dbResult
.
getAttributeValue
(
"rolenames"
)));
//$NON-NLS-1$
}
}
}
UIUtils
.
asyncExec
(()
->
{
String
oldText
=
roleCombo
.
getText
();
if
(!
result
.
contains
(
""
))
{
result
.
add
(
""
);
}
roleCombo
.
setItems
(
result
.
toArray
(
new
String
[
0
]));
if
(!
result
.
contains
(
oldText
))
{
roleCombo
.
setText
(
userName
);
}
});
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
浏览文件 @
9ee376d7
...
...
@@ -231,8 +231,6 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
((
PostgreExecutionContext
)
context
).
setDefaultSchema
(
monitor
,
activeSchema
);
}
}
final
String
roleName
=
getContainer
().
getConnectionConfiguration
().
getProviderProperty
(
PostgreConstants
.
PROP_CHOSEN_ROLE
);
((
PostgreExecutionContext
)
context
).
useRoleWithName
(
monitor
,
roleName
);
}
public
DatabaseCache
getDatabaseCache
()
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
浏览文件 @
9ee376d7
...
...
@@ -181,7 +181,7 @@ public class PostgreExecutionContext extends JDBCExecutionContext implements DBC
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
this
);
}
setSessionRole
(
monitor
);
return
true
;
}
...
...
@@ -242,9 +242,10 @@ public class PostgreExecutionContext extends JDBCExecutionContext implements DBC
}
}
void
useRoleWithName
(
final
DBRProgressMonitor
monitor
,
String
roleName
)
throws
DBCException
{
if
(
roleName
==
null
||
roleName
.
isEmpty
())
{
roleName
=
"NONE"
;
void
setSessionRole
(
final
DBRProgressMonitor
monitor
)
throws
DBCException
{
final
String
roleName
=
getDataSource
().
getContainer
().
getConnectionConfiguration
().
getProviderProperty
(
PostgreConstants
.
PROP_CHOSEN_ROLE
);
if
(
CommonUtils
.
isEmpty
(
roleName
))
{
return
;
}
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active role"
))
{
try
(
JDBCStatement
dbStat
=
session
.
createStatement
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录