Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
2093271c
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,发现更多精彩内容 >>
提交
2093271c
编写于
12月 03, 2016
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Secure storage. Saved editors opening error handler.
上级
952299c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
111 addition
and
80 deletion
+111
-80
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
...re/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
+14
-10
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInputFactory.java
.../jkiss/dbeaver/ui/editors/DatabaseEditorInputFactory.java
+97
-70
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
浏览文件 @
2093271c
...
...
@@ -690,20 +690,24 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private
void
saveSecuredPassword
(
XMLBuilder
xml
,
DataSourceDescriptor
dataSource
,
String
subNode
,
String
password
)
throws
IOException
{
boolean
saved
=
false
;
final
DBASecureStorage
secureStorage
=
getPlatform
().
getSecureStorage
();
if
(
secureStorage
.
useSecurePreferences
())
{
{
try
{
ISecurePreferences
prefNode
=
dataSource
.
getSecurePreferences
();
if
(
subNode
!=
null
)
{
for
(
String
nodeName
:
subNode
.
split
(
"/"
))
{
prefNode
=
prefNode
.
node
(
nodeName
);
}
}
if
(!
CommonUtils
.
isEmpty
(
password
))
{
prefNode
.
put
(
RegistryConstants
.
ATTR_PASSWORD
,
password
,
true
);
if
(!
secureStorage
.
useSecurePreferences
())
{
prefNode
.
removeNode
();
}
else
{
prefNode
.
remove
(
RegistryConstants
.
ATTR_PASSWORD
);
if
(
subNode
!=
null
)
{
for
(
String
nodeName
:
subNode
.
split
(
"/"
))
{
prefNode
=
prefNode
.
node
(
nodeName
);
}
}
if
(!
CommonUtils
.
isEmpty
(
password
))
{
prefNode
.
put
(
RegistryConstants
.
ATTR_PASSWORD
,
password
,
true
);
saved
=
true
;
}
else
{
prefNode
.
remove
(
RegistryConstants
.
ATTR_PASSWORD
);
}
}
saved
=
true
;
}
catch
(
StorageException
e
)
{
log
.
error
(
"Can't save password in secure storage"
,
e
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInputFactory.java
浏览文件 @
2093271c
...
...
@@ -39,6 +39,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressListener;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult
;
import
org.jkiss.dbeaver.registry.DataSourceRegistry
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.entity.EntityEditorInput
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -81,87 +82,21 @@ public class DatabaseEditorInputFactory implements IElementFactory
final
String
activePageId
=
memento
.
getString
(
TAG_ACTIVE_PAGE
);
final
String
activeFolderId
=
memento
.
getString
(
TAG_ACTIVE_FOLDER
);
DBPDataSourceContainer
dataSourceContainer
=
DataSourceRegistry
.
findDataSource
(
dataSourceId
);
final
DBPDataSourceContainer
dataSourceContainer
=
DataSourceRegistry
.
findDataSource
(
dataSourceId
);
if
(
dataSourceContainer
==
null
)
{
log
.
error
(
"Can't find data source '"
+
dataSourceId
+
"'"
);
//$NON-NLS-2$
return
null
;
}
final
DBPDataSourceContainer
dsObject
=
dataSourceContainer
;
if
(
lookupEditor
&&
!
dsObject
.
isConnected
())
{
if
(
lookupEditor
&&
!
dataSourceContainer
.
isConnected
())
{
// Do not instantiate editor input if we are just looking for opened editor
//. for some object. Connection must be instantiated.
return
null
;
}
final
IProject
project
=
d
sObject
.
getRegistry
().
getProject
();
final
IProject
project
=
d
ataSourceContainer
.
getRegistry
().
getProject
();
final
DBNModel
navigatorModel
=
DBeaverCore
.
getInstance
().
getNavigatorModel
();
navigatorModel
.
ensureProjectLoaded
(
project
);
DBRRunnableWithResult
<
IEditorInput
>
opener
=
new
DBRRunnableWithResult
<
IEditorInput
>()
{
private
IStatus
errorStatus
;
@Override
public
void
run
(
final
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
DBNDataSource
dsNode
=
null
;
try
{
if
(!
dsObject
.
isConnected
())
{
dsObject
.
connect
(
monitor
,
true
,
true
);
}
dsNode
=
(
DBNDataSource
)
navigatorModel
.
getNodeByObject
(
monitor
,
dsObject
,
true
);
if
(
dsNode
!=
null
)
{
dsNode
.
initializeNode
(
monitor
,
new
DBRProgressListener
()
{
@Override
public
void
onTaskFinished
(
IStatus
status
)
{
if
(!
status
.
isOK
())
{
errorStatus
=
status
;
return
;
}
try
{
final
DBNNode
node
=
navigatorModel
.
getNodeByPath
(
monitor
,
project
,
nodePath
);
if
(
node
==
null
)
{
throw
new
DBException
(
"Node '"
+
nodePath
+
"' not found"
);
}
Class
<?>
aClass
=
Class
.
forName
(
inputClass
);
if
(
aClass
==
ErrorEditorInput
.
class
)
{
aClass
=
EntityEditorInput
.
class
;
}
Constructor
<?>
constructor
=
null
;
for
(
Class
nodeType
=
node
.
getClass
();
nodeType
!=
null
;
nodeType
=
nodeType
.
getSuperclass
())
{
try
{
constructor
=
aClass
.
getConstructor
(
nodeType
);
break
;
}
catch
(
NoSuchMethodException
e
)
{
// No such constructor
}
}
if
(
constructor
!=
null
)
{
final
DatabaseEditorInput
input
=
DatabaseEditorInput
.
class
.
cast
(
constructor
.
newInstance
(
node
));
input
.
setDefaultPageId
(
activePageId
);
input
.
setDefaultFolderId
(
activeFolderId
);
result
=
input
;
}
else
{
throw
new
DBException
(
"Can't create object instance ["
+
inputClass
+
"]"
);
}
}
catch
(
Exception
e
)
{
errorStatus
=
new
Status
(
IStatus
.
ERROR
,
DBeaverCore
.
getCorePluginID
(),
e
.
getMessage
(),
e
);
log
.
error
(
e
);
}
}
});
}
}
catch
(
Exception
e
)
{
errorStatus
=
new
Status
(
IStatus
.
ERROR
,
DBeaverCore
.
getCorePluginID
(),
e
.
getMessage
(),
e
);
}
if
(
result
==
null
&&
errorStatus
!=
null
)
{
if
(
dsNode
==
null
)
{
log
.
error
(
"Can't find navigator node for datasource '"
+
dsObject
.
getName
()
+
"'"
);
}
else
{
result
=
new
ErrorEditorInput
(
errorStatus
,
dsNode
);
}
}
}
};
final
EditorOpener
opener
=
new
EditorOpener
(
dataSourceContainer
,
navigatorModel
,
project
,
nodePath
,
inputClass
,
activePageId
,
activeFolderId
);
try
{
DBeaverUI
.
runInProgressService
(
opener
);
}
catch
(
InvocationTargetException
e
)
{
...
...
@@ -169,6 +104,14 @@ public class DatabaseEditorInputFactory implements IElementFactory
}
catch
(
InterruptedException
e
)
{
// ignore
}
if
(
opener
.
errorStatus
!=
null
)
{
DBeaverUI
.
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
UIUtils
.
showErrorDialog
(
null
,
"Editor open"
,
"Can't open saved editor of '"
+
dataSourceContainer
.
getName
()
+
"'\nNode path="
+
nodePath
,
opener
.
errorStatus
);
}
});
}
return
opener
.
getResult
();
}
...
...
@@ -198,4 +141,88 @@ public class DatabaseEditorInputFactory implements IElementFactory
}
}
private
static
class
EditorOpener
extends
DBRRunnableWithResult
<
IEditorInput
>
{
private
final
DBPDataSourceContainer
dataSource
;
private
final
DBNModel
navigatorModel
;
private
final
IProject
project
;
private
final
String
nodePath
;
private
final
String
inputClass
;
private
final
String
activePageId
;
private
final
String
activeFolderId
;
private
IStatus
errorStatus
;
public
EditorOpener
(
DBPDataSourceContainer
dataSource
,
DBNModel
navigatorModel
,
IProject
project
,
String
nodePath
,
String
inputClass
,
String
activePageId
,
String
activeFolderId
)
{
this
.
dataSource
=
dataSource
;
this
.
navigatorModel
=
navigatorModel
;
this
.
project
=
project
;
this
.
nodePath
=
nodePath
;
this
.
inputClass
=
inputClass
;
this
.
activePageId
=
activePageId
;
this
.
activeFolderId
=
activeFolderId
;
}
@Override
public
void
run
(
final
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
DBNDataSource
dsNode
=
null
;
try
{
if
(!
dataSource
.
isConnected
())
{
dataSource
.
connect
(
monitor
,
true
,
true
);
}
dsNode
=
(
DBNDataSource
)
navigatorModel
.
getNodeByObject
(
monitor
,
dataSource
,
true
);
if
(
dsNode
!=
null
)
{
dsNode
.
initializeNode
(
monitor
,
new
DBRProgressListener
()
{
@Override
public
void
onTaskFinished
(
IStatus
status
)
{
if
(!
status
.
isOK
())
{
errorStatus
=
status
;
return
;
}
try
{
final
DBNNode
node
=
navigatorModel
.
getNodeByPath
(
monitor
,
project
,
nodePath
);
if
(
node
==
null
)
{
throw
new
DBException
(
"Node '"
+
nodePath
+
"' not found"
);
}
Class
<?>
aClass
=
Class
.
forName
(
inputClass
);
if
(
aClass
==
ErrorEditorInput
.
class
)
{
aClass
=
EntityEditorInput
.
class
;
}
Constructor
<?>
constructor
=
null
;
for
(
Class
nodeType
=
node
.
getClass
();
nodeType
!=
null
;
nodeType
=
nodeType
.
getSuperclass
())
{
try
{
constructor
=
aClass
.
getConstructor
(
nodeType
);
break
;
}
catch
(
NoSuchMethodException
e
)
{
// No such constructor
}
}
if
(
constructor
!=
null
)
{
final
DatabaseEditorInput
input
=
DatabaseEditorInput
.
class
.
cast
(
constructor
.
newInstance
(
node
));
input
.
setDefaultPageId
(
activePageId
);
input
.
setDefaultFolderId
(
activeFolderId
);
result
=
input
;
}
else
{
throw
new
DBException
(
"Can't create object instance ["
+
inputClass
+
"]"
);
}
}
catch
(
Exception
e
)
{
errorStatus
=
new
Status
(
IStatus
.
ERROR
,
DBeaverCore
.
getCorePluginID
(),
e
.
getMessage
(),
e
);
log
.
error
(
e
);
}
}
});
}
}
catch
(
Exception
e
)
{
errorStatus
=
new
Status
(
IStatus
.
ERROR
,
DBeaverCore
.
getCorePluginID
(),
e
.
getMessage
(),
e
);
}
if
(
result
==
null
&&
errorStatus
!=
null
)
{
if
(
dsNode
==
null
)
{
log
.
error
(
"Can't find navigator node for datasource '"
+
dataSource
.
getName
()
+
"'"
);
}
else
{
result
=
new
ErrorEditorInput
(
errorStatus
,
dsNode
);
}
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录