Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
05ccc195
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
05ccc195
编写于
8月 23, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6570 ERD entities coloring
Former-commit-id:
037ebab8
上级
2144af05
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
77 addition
and
14 deletion
+77
-14
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java
...r.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java
+14
-0
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
...c/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
+6
-5
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java
...d/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java
+12
-1
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
+1
-1
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
...xt.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
+1
-1
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java
...rd/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java
+43
-6
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java
浏览文件 @
05ccc195
...
...
@@ -18,8 +18,11 @@
package
org.jkiss.dbeaver.ext.erd
;
import
org.eclipse.draw2d.PrintFigureOperation
;
import
org.eclipse.swt.graphics.RGB
;
import
org.jkiss.dbeaver.model.struct.DBSEntityConstraintType
;
import
java.awt.*
;
/**
* ERD constants
*/
...
...
@@ -62,4 +65,15 @@ public class ERDConstants {
public
static
final
int
DEFAULT_ENTITY_BORDER_WIDTH
=
2
;
public
static
DBSEntityConstraintType
CONSTRAINT_LOGICAL_FK
=
new
DBSEntityConstraintType
(
"erdkey"
,
"Logical Key"
,
null
,
true
,
false
,
false
,
true
);
public
static
final
RGB
[]
EXTRA_DS_COLORS
=
new
RGB
[]
{
new
RGB
(
119
,
206
,
130
),
new
RGB
(
206
,
63
,
34
),
new
RGB
(
242
,
132
,
35
),
new
RGB
(
124
,
38
,
19
),
new
RGB
(
157
,
214
,
245
),
new
RGB
(
173
,
140
,
127
),
new
RGB
(
249
,
214
,
205
)
};
}
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
浏览文件 @
05ccc195
...
...
@@ -188,6 +188,12 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
}
else
{
diagram
=
new
EntityDiagram
(
getDecorator
(),
dbObject
,
dbObject
.
getName
());
// Fill from database even if we loaded from state (something could change since last view)
diagram
.
fillEntities
(
monitor
,
collectDatabaseTables
(
monitor
,
dbObject
,
diagram
),
dbObject
);
boolean
hasPersistedState
=
false
;
try
{
// Load persisted state
...
...
@@ -209,11 +215,6 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
diagram
.
setLayoutManualAllowed
(
true
);
diagram
.
setNeedsAutoLayout
(!
hasPersistedState
);
// Fill from database even if we loaded from state (something could change since last view)
diagram
.
fillEntities
(
monitor
,
collectDatabaseTables
(
monitor
,
dbObject
,
diagram
),
dbObject
);
}
return
diagram
;
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java
浏览文件 @
05ccc195
...
...
@@ -23,6 +23,7 @@ import org.eclipse.draw2d.*;
import
org.eclipse.jface.resource.ColorRegistry
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.graphics.RGB
;
import
org.jkiss.dbeaver.ext.erd.ERDConstants
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDViewStyle
;
import
org.jkiss.dbeaver.ext.erd.model.ERDEntity
;
...
...
@@ -114,7 +115,17 @@ public class EntityFigure extends Figure {
}
protected
Color
getBorderColor
()
{
return
UIUtils
.
getColorRegistry
().
get
(
ERDConstants
.
COLOR_ERD_LINES_FOREGROUND
);
int
dsIndex
=
getPart
().
getDiagram
().
getDataSourceIndex
(
part
.
getEntity
().
getDataSource
().
getContainer
());
RGB
[]
extraDsColors
=
ERDConstants
.
EXTRA_DS_COLORS
;
if
(
dsIndex
==
0
)
{
return
UIUtils
.
getColorRegistry
().
get
(
ERDConstants
.
COLOR_ERD_LINES_FOREGROUND
);
}
else
{
dsIndex
--;
if
(
dsIndex
>
extraDsColors
.
length
)
{
dsIndex
=
dsIndex
%
extraDsColors
.
length
;
}
return
UIUtils
.
getSharedColor
(
extraDsColors
[
dsIndex
]);
}
}
public
EntityPart
getPart
()
{
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java
浏览文件 @
05ccc195
...
...
@@ -198,13 +198,13 @@ public class DiagramLoader
}
final
Document
document
=
XMLUtils
.
parseDocument
(
in
);
monitor
.
done
();
loadDiagram
(
monitor
,
document
,
projectMeta
,
diagram
);
}
public
static
void
loadDiagram
(
DBRProgressMonitor
monitor
,
Document
document
,
DBPProject
projectMeta
,
EntityDiagram
diagram
)
throws
DBException
{
final
Element
diagramElem
=
document
.
getDocumentElement
();
monitor
.
done
();
// Check version
final
String
diagramVersion
=
diagramElem
.
getAttribute
(
ATTR_VERSION
);
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
浏览文件 @
05ccc195
...
...
@@ -69,7 +69,7 @@ public class ERDEntity extends ERDElement<DBSEntity> {
}
public
DBPDataSource
getDataSource
()
{
return
dataSource
;
return
dataSource
!=
null
?
dataSource
:
getObject
().
getDataSource
()
;
}
public
String
getAlias
()
{
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java
浏览文件 @
05ccc195
...
...
@@ -30,6 +30,7 @@ import org.jkiss.dbeaver.ext.erd.ERDActivator;
import
org.jkiss.dbeaver.ext.erd.editor.ERDAttributeVisibility
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDViewStyle
;
import
org.jkiss.dbeaver.ext.erd.part.NodePart
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
...
...
@@ -71,9 +72,19 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
}
}
private
static
class
DataSourceInfo
{
int
index
;
List
<
ERDEntity
>
entities
=
new
ArrayList
<>();
public
DataSourceInfo
(
int
index
)
{
this
.
index
=
index
;
}
}
private
ERDDecorator
decorator
;
private
String
name
;
private
final
List
<
ERDEntity
>
entities
=
new
ArrayList
<>();
private
final
Map
<
DBPDataSourceContainer
,
DataSourceInfo
>
dataSourceMap
=
new
LinkedHashMap
<>();
private
boolean
layoutManualDesired
=
true
;
private
boolean
layoutManualAllowed
=
false
;
private
boolean
needsAutoLayout
;
...
...
@@ -144,6 +155,10 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
entities
.
add
(
i
,
entity
);
}
entityMap
.
put
(
entity
.
getObject
(),
entity
);
DBPDataSourceContainer
dataSource
=
entity
.
getObject
().
getDataSource
().
getContainer
();
DataSourceInfo
dsInfo
=
dataSourceMap
.
computeIfAbsent
(
dataSource
,
dsc
->
new
DataSourceInfo
(
dataSourceMap
.
size
()));
dsInfo
.
entities
.
add
(
entity
);
}
if
(
reflect
)
{
...
...
@@ -182,6 +197,14 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
synchronized
(
entities
)
{
entityMap
.
remove
(
entity
.
getObject
());
entities
.
remove
(
entity
);
DBPDataSourceContainer
dataSource
=
entity
.
getObject
().
getDataSource
().
getContainer
();
DataSourceInfo
dsInfo
=
dataSourceMap
.
get
(
dataSource
);
dsInfo
.
entities
.
remove
(
entity
);
if
(
dsInfo
.
entities
.
isEmpty
())
{
dataSourceMap
.
remove
(
dataSource
);
}
}
if
(
reflect
)
{
firePropertyChange
(
CHILD
,
entity
,
null
);
...
...
@@ -284,6 +307,9 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
if
(
monitor
.
isCanceled
())
{
break
;
}
if
(
entityMap
.
containsKey
(
table
))
{
continue
;
}
monitor
.
subTask
(
"Load "
+
table
.
getName
());
ERDEntity
erdEntity
=
ERDUtils
.
makeEntityFromObject
(
monitor
,
this
,
entityCache
,
table
,
null
);
erdEntity
.
setPrimary
(
table
==
dbObject
);
...
...
@@ -299,15 +325,12 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
// Load relations
monitor
.
beginTask
(
"Load entities' relations"
,
entities
.
size
());
for
(
DBSEntity
table
:
entities
)
{
for
(
ERDEntity
erdEntity
:
entityCache
)
{
if
(
monitor
.
isCanceled
())
{
break
;
}
monitor
.
subTask
(
"Load "
+
table
.
getName
());
final
ERDEntity
erdEntity
=
entityMap
.
get
(
table
);
if
(
erdEntity
!=
null
)
{
erdEntity
.
addModelRelations
(
monitor
,
this
,
true
,
false
);
}
monitor
.
subTask
(
"Load "
+
erdEntity
.
getName
());
erdEntity
.
addModelRelations
(
monitor
,
this
,
true
,
false
);
monitor
.
worked
(
1
);
}
monitor
.
done
();
...
...
@@ -340,6 +363,20 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
return
result
;
}
public
List
<
DBPDataSourceContainer
>
getDataSources
()
{
return
new
ArrayList
<>(
dataSourceMap
.
keySet
());
}
public
List
<
ERDEntity
>
getEntities
(
DBPDataSourceContainer
dataSourceContainer
)
{
DataSourceInfo
dsInfo
=
dataSourceMap
.
get
(
dataSourceContainer
);
return
dsInfo
==
null
?
Collections
.
emptyList
()
:
dsInfo
.
entities
;
}
public
int
getDataSourceIndex
(
DBPDataSourceContainer
dataSource
)
{
DataSourceInfo
dsInfo
=
dataSourceMap
.
get
(
dataSource
);
return
dsInfo
==
null
?
0
:
dsInfo
.
index
;
}
public
void
clear
()
{
this
.
entities
.
clear
();
this
.
entityMap
.
clear
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录