Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
1a9bf0ce
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,发现更多精彩内容 >>
提交
1a9bf0ce
编写于
11月 12, 2017
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2462 ER diagram datasources info
上级
0225de07
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
53 addition
and
4 deletion
+53
-4
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java
...rd/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java
+35
-2
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/navigator/ERDResourceHandler.java
...g/jkiss/dbeaver/ext/erd/navigator/ERDResourceHandler.java
+18
-2
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java
浏览文件 @
1a9bf0ce
...
...
@@ -19,7 +19,9 @@
*/
package
org.jkiss.dbeaver.ext.erd.model
;
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.core.resources.IProject
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.draw2d.AbsoluteBendpoint
;
import
org.eclipse.draw2d.Bendpoint
;
import
org.eclipse.draw2d.RelativeBendpoint
;
...
...
@@ -27,12 +29,10 @@ import org.eclipse.draw2d.geometry.Point;
import
org.eclipse.draw2d.geometry.Rectangle
;
import
org.eclipse.jface.resource.StringConverter
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.RGB
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.ext.erd.ERDConstants
;
import
org.jkiss.dbeaver.ext.erd.part.*
;
import
org.jkiss.dbeaver.model.*
;
...
...
@@ -143,6 +143,39 @@ public class DiagramLoader
List
<
ERDEntity
>
entities
=
new
ArrayList
<>();
}
public
static
List
<
DBPDataSourceContainer
>
extractContainers
(
IFile
resource
)
throws
IOException
,
XMLException
,
DBException
{
List
<
DBPDataSourceContainer
>
containers
=
new
ArrayList
<>();
final
DataSourceRegistry
dsRegistry
=
DBeaverCore
.
getInstance
().
getProjectRegistry
().
getDataSourceRegistry
(
resource
.
getProject
());
if
(
dsRegistry
==
null
)
{
return
containers
;
}
try
(
InputStream
is
=
resource
.
getContents
())
{
final
Document
document
=
XMLUtils
.
parseDocument
(
is
);
final
Element
diagramElem
=
document
.
getDocumentElement
();
final
Element
entitiesElem
=
XMLUtils
.
getChildElement
(
diagramElem
,
TAG_ENTITIES
);
if
(
entitiesElem
!=
null
)
{
// Parse data source
for
(
Element
dsElem
:
XMLUtils
.
getChildElementList
(
entitiesElem
,
TAG_DATA_SOURCE
))
{
String
dsId
=
dsElem
.
getAttribute
(
ATTR_ID
);
if
(!
CommonUtils
.
isEmpty
(
dsId
))
{
// Get connected datasource
final
DataSourceDescriptor
dataSourceContainer
=
dsRegistry
.
getDataSource
(
dsId
);
if
(
dataSourceContainer
!=
null
)
{
containers
.
add
(
dataSourceContainer
);
}
}
}
}
}
catch
(
CoreException
e
)
{
throw
new
DBException
(
"Error reading resource contents"
,
e
);
}
return
containers
;
}
public
static
void
load
(
DBRProgressMonitor
monitor
,
IProject
project
,
DiagramPart
diagramPart
,
InputStream
in
)
throws
IOException
,
XMLException
,
DBException
{
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/navigator/ERDResourceHandler.java
浏览文件 @
1a9bf0ce
...
...
@@ -23,12 +23,14 @@ import org.eclipse.core.resources.IResource;
import
org.eclipse.core.runtime.CoreException
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDEditorInput
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDEditorStandalone
;
import
org.jkiss.dbeaver.ext.erd.model.DiagramLoader
;
import
org.jkiss.dbeaver.ext.erd.model.EntityDiagram
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.navigator.DBNResource
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
...
@@ -43,12 +45,15 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Collection
;
/**
*
Bookmarks
handler
*
ERD resource
handler
*/
public
class
ERDResourceHandler
extends
AbstractResourceHandler
{
private
static
final
Log
log
=
Log
.
getLog
(
ERDResourceHandler
.
class
);
private
static
final
String
ERD_EXT
=
"erd"
;
//$NON-NLS-1$
public
static
IFolder
getDiagramsFolder
(
IProject
project
,
boolean
forceCreate
)
throws
CoreException
...
...
@@ -170,5 +175,16 @@ public class ERDResourceHandler extends AbstractResourceHandler {
return
file
;
}
@Override
public
Collection
<
DBPDataSourceContainer
>
getAssociatedDataSources
(
IResource
resource
)
{
if
(
resource
instanceof
IFile
)
{
try
{
return
DiagramLoader
.
extractContainers
((
IFile
)
resource
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
);
return
null
;
}
}
return
super
.
getAssociatedDataSources
(
resource
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录