Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
65df2077
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,发现更多精彩内容 >>
提交
65df2077
编写于
4月 22, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3347 Bookmark name in DND
Former-commit-id:
3d578ee1
上级
f6293c8f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
121 addition
and
70 deletion
+121
-70
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/navigator/NavigatorUtils.java
...re/src/org/jkiss/dbeaver/ui/navigator/NavigatorUtils.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/BookmarkStorage.java
...jkiss/dbeaver/ui/resources/bookmarks/BookmarkStorage.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/BookmarksHandlerImpl.java
.../dbeaver/ui/resources/bookmarks/BookmarksHandlerImpl.java
+96
-67
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/DBNBookmark.java
...org/jkiss/dbeaver/ui/resources/bookmarks/DBNBookmark.java
+15
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNNode.java
....model/src/org/jkiss/dbeaver/model/navigator/DBNNode.java
+8
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/navigator/NavigatorUtils.java
浏览文件 @
65df2077
...
...
@@ -313,7 +313,7 @@ public class NavigatorUtils {
nodeName
=
DBUtils
.
getObjectFullName
(
object
,
DBPEvaluationContext
.
UI
);
objects
.
add
(
object
);
}
else
{
nodeName
=
((
DBNNode
)
nextSelected
).
getNodeName
();
nodeName
=
((
DBNNode
)
nextSelected
).
getNode
Target
Name
();
}
if
(
buf
.
length
()
>
0
)
{
buf
.
append
(
lineSeparator
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/BookmarkStorage.java
浏览文件 @
65df2077
...
...
@@ -137,7 +137,7 @@ public class BookmarkStorage {
return
dataSourceId
;
}
public
Collection
<
String
>
getDataSourcePath
()
public
List
<
String
>
getDataSourcePath
()
{
return
dataSourcePath
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/BookmarksHandlerImpl.java
浏览文件 @
65df2077
...
...
@@ -21,7 +21,6 @@ import org.eclipse.core.resources.IFolder;
import
org.eclipse.core.resources.IProject
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.NullProgressMonitor
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
...
...
@@ -30,7 +29,6 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.navigator.*
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressListener
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
...
...
@@ -122,23 +120,14 @@ public class BookmarksHandlerImpl extends AbstractResourceHandler {
if
(
dsNode
==
null
)
{
throw
new
DBException
(
"Can't find datasource node for '"
+
dataSourceContainer
.
getName
()
+
"'"
);
//$NON-NLS-2$
}
dsNode
.
initializeNode
(
null
,
new
DBRProgressListener
()
{
@Override
public
void
onTaskFinished
(
IStatus
status
)
{
if
(
status
.
isOK
())
{
DBeaverUI
.
syncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
openNodeByPath
(
dsNode
,
(
IFile
)
resource
,
storage
);
}
});
}
else
{
DBUserInterface
.
getInstance
().
showError
(
"Open bookmark"
,
"Can't open bookmark"
,
status
);
}
dsNode
.
initializeNode
(
null
,
status
->
{
if
(
status
.
isOK
())
{
DBeaverUI
.
syncExec
(()
->
openNodeByPath
(
dsNode
,
(
IFile
)
resource
,
storage
));
}
else
{
DBUserInterface
.
getInstance
().
showError
(
"Open bookmark"
,
"Can't open bookmark"
,
status
);
}
});
}
...
...
@@ -147,62 +136,52 @@ public class BookmarksHandlerImpl extends AbstractResourceHandler {
}
}
private
void
openNodeByPath
(
final
DBNDataSource
dsNode
,
final
IFile
file
,
final
BookmarkStorage
storage
)
private
static
void
openNodeByPath
(
final
DBNDataSource
dsNode
,
final
IFile
file
,
final
BookmarkStorage
storage
)
{
try
{
DBeaverUI
.
runInProgressService
(
new
DBRRunnableWithProgress
()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
DBNNode
currentNode
=
dsNode
;
final
Collection
<
String
>
dataSourcePath
=
storage
.
getDataSourcePath
();
for
(
String
path
:
dataSourcePath
)
{
DBNNode
nextChild
=
null
;
final
DBNNode
[]
children
=
currentNode
.
getChildren
(
monitor
);
if
(!
ArrayUtils
.
isEmpty
(
children
))
{
for
(
DBNNode
node
:
children
)
{
if
(
path
.
equals
(
node
.
getNodeName
()))
{
nextChild
=
node
;
break
;
}
}
}
if
(
nextChild
==
null
)
{
throw
new
DBException
(
"Can't find node '"
+
path
+
"' in '"
+
currentNode
.
getNodeFullName
()
+
"'"
);
//$NON-NLS-2$ //$NON-NLS-3$
}
currentNode
=
nextChild
;
}
if
(
currentNode
instanceof
DBNDatabaseNode
)
{
// Update bookmark image
storage
.
setImage
(
currentNode
.
getNodeIconDefault
());
file
.
setContents
(
storage
.
serialize
(),
true
,
false
,
RuntimeUtils
.
getNestedMonitor
(
monitor
));
// Open entity editor
final
DBNDatabaseNode
databaseNode
=
(
DBNDatabaseNode
)
currentNode
;
DBeaverUI
.
syncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
NavigatorHandlerObjectOpen
.
openEntityEditor
(
databaseNode
,
null
,
DBeaverUI
.
getActiveWorkbenchWindow
());
}
});
}
else
if
(
currentNode
!=
null
)
{
throw
new
DBException
(
"Node '"
+
currentNode
.
getNodeFullName
()
+
"' is not a database object"
);
}
else
{
throw
new
DBException
(
"Can't find database node by path"
);
}
}
catch
(
Exception
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
});
BookmarkNodeLoader
nodeLoader
=
new
BookmarkNodeLoader
(
dsNode
,
storage
,
file
);
DBeaverUI
.
runInProgressService
(
nodeLoader
);
if
(
nodeLoader
.
databaseNode
!=
null
)
{
DBeaverUI
.
syncExec
(()
->
NavigatorHandlerObjectOpen
.
openEntityEditor
(
nodeLoader
.
databaseNode
,
null
,
DBeaverUI
.
getActiveWorkbenchWindow
()));
}
}
catch
(
InvocationTargetException
e
)
{
DBUserInterface
.
getInstance
().
showError
(
CoreMessages
.
model_project_open_bookmark
,
CoreMessages
.
model_project_cant_open_bookmark
,
e
.
getTargetException
());
DBUserInterface
.
getInstance
().
showError
(
CoreMessages
.
model_project_open_bookmark
,
CoreMessages
.
model_project_cant_open_bookmark
,
e
.
getTargetException
());
}
catch
(
InterruptedException
e
)
{
// do nothing
}
}
static
DBNDatabaseNode
getTargetBookmarkNode
(
DBRProgressMonitor
monitor
,
DBNBookmark
bookmark
)
{
IFile
resource
=
(
IFile
)
bookmark
.
getResource
();
final
DBNProject
projectNode
=
DBeaverCore
.
getInstance
().
getNavigatorModel
().
getRoot
().
getProject
(
resource
.
getProject
());
if
(
projectNode
!=
null
)
{
BookmarkStorage
storage
=
bookmark
.
getStorage
();
final
DBPDataSourceContainer
dataSourceContainer
=
projectNode
.
getDatabases
().
getDataSourceRegistry
().
getDataSource
(
storage
.
getDataSourceId
());
if
(
dataSourceContainer
!=
null
)
{
final
DBNDataSource
dsNode
=
(
DBNDataSource
)
NavigatorUtils
.
getNodeByObject
(
dataSourceContainer
);
if
(
dsNode
!=
null
)
{
DBNDatabaseNode
[]
result
=
new
DBNDatabaseNode
[
1
];
dsNode
.
initializeNode
(
monitor
,
status
->
{
if
(
status
.
isOK
())
{
try
{
BookmarkNodeLoader
nodeLoader
=
new
BookmarkNodeLoader
(
dsNode
,
storage
,
resource
);
nodeLoader
.
run
(
monitor
);
result
[
0
]
=
nodeLoader
.
databaseNode
;
}
catch
(
Exception
e
)
{
// Doesn't matter
}
}
});
return
result
[
0
];
}
}
}
return
null
;
}
public
static
void
createBookmark
(
final
DBNDatabaseNode
node
,
String
title
,
IFolder
folder
)
throws
DBException
{
if
(
folder
==
null
)
{
...
...
@@ -254,4 +233,54 @@ public class BookmarksHandlerImpl extends AbstractResourceHandler {
}
}
private
static
class
BookmarkNodeLoader
implements
DBRRunnableWithProgress
{
private
final
DBNDataSource
dsNode
;
private
final
BookmarkStorage
storage
;
private
final
IFile
file
;
private
DBNDatabaseNode
databaseNode
;
BookmarkNodeLoader
(
DBNDataSource
dsNode
,
BookmarkStorage
storage
,
IFile
file
)
{
this
.
dsNode
=
dsNode
;
this
.
storage
=
storage
;
this
.
file
=
file
;
}
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
DBNNode
currentNode
=
dsNode
;
final
Collection
<
String
>
dataSourcePath
=
storage
.
getDataSourcePath
();
for
(
String
path
:
dataSourcePath
)
{
DBNNode
nextChild
=
null
;
final
DBNNode
[]
children
=
currentNode
.
getChildren
(
monitor
);
if
(!
ArrayUtils
.
isEmpty
(
children
))
{
for
(
DBNNode
node
:
children
)
{
if
(
path
.
equals
(
node
.
getNodeName
()))
{
nextChild
=
node
;
break
;
}
}
}
if
(
nextChild
==
null
)
{
throw
new
DBException
(
"Can't find node '"
+
path
+
"' in '"
+
currentNode
.
getNodeFullName
()
+
"'"
);
//$NON-NLS-2$ //$NON-NLS-3$
}
currentNode
=
nextChild
;
}
if
(
currentNode
instanceof
DBNDatabaseNode
)
{
// Update bookmark image
storage
.
setImage
(
currentNode
.
getNodeIconDefault
());
file
.
setContents
(
storage
.
serialize
(),
true
,
false
,
RuntimeUtils
.
getNestedMonitor
(
monitor
));
// Open entity editor
databaseNode
=
(
DBNDatabaseNode
)
currentNode
;
}
else
if
(
currentNode
!=
null
)
{
throw
new
DBException
(
"Node '"
+
currentNode
.
getNodeFullName
()
+
"' is not a database object"
);
}
else
{
throw
new
DBException
(
"Can't find database node by path"
);
}
}
catch
(
Exception
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/DBNBookmark.java
浏览文件 @
65df2077
...
...
@@ -24,9 +24,12 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.app.DBPResourceHandler
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.navigator.DBNResource
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSAlias
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.registry.DataSourceRegistry
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -34,6 +37,7 @@ import org.jkiss.utils.CommonUtils;
import
java.io.InputStream
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
/**
* DBNBookmark
...
...
@@ -42,7 +46,7 @@ public class DBNBookmark extends DBNResource
{
private
BookmarkStorage
storage
;
public
DBNBookmark
(
DBNNode
parentNode
,
IResource
resource
,
DBPResourceHandler
handler
)
throws
DBException
,
CoreException
DBNBookmark
(
DBNNode
parentNode
,
IResource
resource
,
DBPResourceHandler
handler
)
throws
DBException
,
CoreException
{
super
(
parentNode
,
resource
,
handler
);
storage
=
new
BookmarkStorage
((
IFile
)
resource
,
true
);
...
...
@@ -55,6 +59,10 @@ public class DBNBookmark extends DBNResource
super
.
dispose
(
reflect
);
}
public
BookmarkStorage
getStorage
()
{
return
storage
;
}
@Override
public
String
getNodeName
()
{
...
...
@@ -79,6 +87,12 @@ public class DBNBookmark extends DBNResource
return
storage
.
getImage
();
}
@Override
public
String
getNodeTargetName
()
{
List
<
String
>
dsPath
=
storage
.
getDataSourcePath
();
return
CommonUtils
.
isEmpty
(
dsPath
)
?
super
.
getNodeName
()
:
dsPath
.
get
(
dsPath
.
size
()
-
1
);
}
@Override
public
void
rename
(
DBRProgressMonitor
monitor
,
String
newName
)
throws
DBException
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNNode.java
浏览文件 @
65df2077
...
...
@@ -151,6 +151,14 @@ public abstract class DBNNode implements DBPNamedObject, DBPPersistedObject, IAd
return
pathName
.
toString
();
}
/**
* Used to copy target name in clipboard and in DND operations.
* Equals to regular node name by default.
*/
public
String
getNodeTargetName
()
{
return
getNodeName
();
}
public
boolean
hasChildren
(
boolean
navigableOnly
)
{
return
navigableOnly
?
allowsNavigableChildren
()
:
allowsChildren
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录