Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
91d8b9d3
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,发现更多精彩内容 >>
提交
91d8b9d3
编写于
6月 24, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#1652 Keep ERD association attributes cached
上级
91d08e32
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
68 addition
and
32 deletion
+68
-32
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
...c/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
+3
-0
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDAssociation.java
...d/src/org/jkiss/dbeaver/ext/erd/model/ERDAssociation.java
+48
-5
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntityAttribute.java
...c/org/jkiss/dbeaver/ext/erd/model/ERDEntityAttribute.java
+1
-3
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDLogicalAssociation.java
...rg/jkiss/dbeaver/ext/erd/model/ERDLogicalAssociation.java
+2
-2
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDUtils.java
...ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDUtils.java
+1
-1
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/part/AssociationPart.java
...d/src/org/jkiss/dbeaver/ext/erd/part/AssociationPart.java
+13
-21
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
浏览文件 @
91d8b9d3
...
...
@@ -136,6 +136,8 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
public
EntityDiagram
evaluate
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
// Do not refresh actual metadata. It is slow and it may corrupt diagram state
/*
if (refreshMetadata && object instanceof DBPRefreshableObject) {
try {
getEditorInput().getNavigatorNode().refreshNode(monitor, ERDEditorEmbedded.this);
...
...
@@ -143,6 +145,7 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
log.warn("Error refreshing database metadata", e);
}
}
*/
try
{
return
loadFromDatabase
(
monitor
);
}
catch
(
DBException
e
)
{
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDAssociation.java
浏览文件 @
91d8b9d3
...
...
@@ -20,9 +20,13 @@ import org.eclipse.draw2d.geometry.Point;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAssociation
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttributeRef
;
import
org.jkiss.dbeaver.model.struct.DBSEntityReferrer
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableForeignKeyColumn
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -56,7 +60,7 @@ public class ERDAssociation extends ERDObject<DBSEntityAssociation>
sourceEntity
,
sourceEntity
.
getObject
().
getName
()
+
" -> "
+
targetEntity
.
getObject
().
getName
(),
""
,
new
ERDLogicalPrimaryKey
(
targetEntity
,
"
P
rimary key"
,
""
)));
new
ERDLogicalPrimaryKey
(
targetEntity
,
"
Logical p
rimary key"
,
""
)));
this
.
targetEntity
=
targetEntity
;
this
.
sourceEntity
=
sourceEntity
;
this
.
targetEntity
.
addPrimaryKeyRelationship
(
this
,
reflect
);
...
...
@@ -65,20 +69,59 @@ public class ERDAssociation extends ERDObject<DBSEntityAssociation>
/**
* Constructor for physical association
* @param
object
physical FK
* @param
association
physical FK
* @param sourceEntity fk table
* @param targetEntity pk table
* @param reflect reflect flag
*/
public
ERDAssociation
(
DBSEntityAssociation
object
,
ERDEntity
sourceEntity
,
ERDEntity
targetEntity
,
boolean
reflect
)
public
ERDAssociation
(
DBSEntityAssociation
association
,
ERDEntity
sourceEntity
,
ERDEntity
targetEntity
,
boolean
reflect
)
{
super
(
object
);
super
(
association
);
this
.
targetEntity
=
targetEntity
;
this
.
sourceEntity
=
sourceEntity
;
// Resolve association attributes
if
(
association
instanceof
DBSEntityReferrer
)
{
resolveAttributes
((
DBSEntityReferrer
)
association
,
sourceEntity
,
targetEntity
);
}
this
.
targetEntity
.
addPrimaryKeyRelationship
(
this
,
reflect
);
this
.
sourceEntity
.
addForeignKeyRelationship
(
this
,
reflect
);
}
private
void
resolveAttributes
(
DBSEntityReferrer
association
,
ERDEntity
sourceEntity
,
ERDEntity
targetEntity
)
{
try
{
List
<?
extends
DBSEntityAttributeRef
>
attrRefs
=
association
.
getAttributeReferences
(
new
VoidProgressMonitor
());
if
(!
CommonUtils
.
isEmpty
(
attrRefs
))
{
for
(
DBSEntityAttributeRef
attrRef
:
attrRefs
)
{
if
(
attrRef
instanceof
DBSTableForeignKeyColumn
)
{
DBSEntityAttribute
sourceAttr
=
((
DBSTableForeignKeyColumn
)
attrRef
).
getReferencedColumn
();
DBSEntityAttribute
targetAttr
=
attrRef
.
getAttribute
();
if
(
sourceAttr
!=
null
&&
targetAttr
!=
null
)
{
ERDEntityAttribute
erdSourceAttr
=
getAttributeByModel
(
sourceEntity
,
sourceAttr
);
ERDEntityAttribute
erdTargetAttr
=
getAttributeByModel
(
targetEntity
,
targetAttr
);
if
(
erdSourceAttr
!=
null
&&
erdTargetAttr
!=
null
)
{
addCondition
(
erdSourceAttr
,
erdTargetAttr
);
}
}
}
}
}
}
catch
(
DBException
e
)
{
log
.
error
(
"Error resolving ERD association attributes"
,
e
);
}
}
private
static
ERDEntityAttribute
getAttributeByModel
(
ERDEntity
entity
,
DBSEntityAttribute
attr
)
{
for
(
ERDEntityAttribute
erdAttr
:
entity
.
getAttributes
())
{
if
(
erdAttr
.
getObject
()
==
attr
)
{
return
erdAttr
;
}
}
return
null
;
}
public
boolean
isLogical
()
{
return
getObject
()
instanceof
ERDLogicalAssociation
;
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntityAttribute.java
浏览文件 @
91d8b9d3
...
...
@@ -30,13 +30,11 @@ import org.jkiss.dbeaver.model.struct.DBSEntityAttribute;
* @author Serge Rider
*/
public
class
ERDEntityAttribute
extends
ERDObject
<
DBSEntityAttribute
>
{
private
ERDEntity
entity
;
private
boolean
inPrimaryKey
;
private
boolean
inForeignKey
;
public
ERDEntityAttribute
(
ERDEntity
entity
,
DBSEntityAttribute
attribute
,
boolean
inPrimaryKey
)
{
public
ERDEntityAttribute
(
DBSEntityAttribute
attribute
,
boolean
inPrimaryKey
)
{
super
(
attribute
);
this
.
entity
=
entity
;
this
.
inPrimaryKey
=
inPrimaryKey
;
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDLogicalAssociation.java
浏览文件 @
91d8b9d3
...
...
@@ -24,6 +24,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.struct.*
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -35,7 +36,6 @@ public class ERDLogicalAssociation implements DBSEntityAssociation, DBSEntityRef
private
String
name
;
private
String
description
;
private
ERDLogicalPrimaryKey
pk
;
private
List
<?
extends
DBSEntityAttributeRef
>
attributes
=
new
ArrayList
<>();
public
ERDLogicalAssociation
(
ERDEntity
entity
,
String
name
,
String
description
,
ERDLogicalPrimaryKey
pk
)
{
...
...
@@ -102,6 +102,6 @@ public class ERDLogicalAssociation implements DBSEntityAssociation, DBSEntityRef
@Override
public
List
<?
extends
DBSEntityAttributeRef
>
getAttributeReferences
(
DBRProgressMonitor
monitor
)
{
return
attributes
;
return
Collections
.
emptyList
()
;
}
}
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDUtils.java
浏览文件 @
91d8b9d3
...
...
@@ -136,7 +136,7 @@ public class ERDUtils
break
;
}
boolean
inPrimaryKey
=
idColumns
!=
null
&&
idColumns
.
contains
(
attribute
);
ERDEntityAttribute
c1
=
new
ERDEntityAttribute
(
erdEntity
,
attribute
,
inPrimaryKey
);
ERDEntityAttribute
c1
=
new
ERDEntityAttribute
(
attribute
,
inPrimaryKey
);
erdEntity
.
addAttribute
(
c1
,
false
);
}
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/part/AssociationPart.java
浏览文件 @
91d8b9d3
...
...
@@ -30,6 +30,7 @@ import org.eclipse.swt.SWT;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.widgets.Display
;
import
org.jkiss.dbeaver.ext.erd.model.ERDAssociation
;
import
org.jkiss.dbeaver.ext.erd.model.ERDEntityAttribute
;
import
org.jkiss.dbeaver.ext.erd.model.ERDUtils
;
import
org.jkiss.dbeaver.ext.erd.policy.AssociationBendEditPolicy
;
import
org.jkiss.dbeaver.ext.erd.policy.AssociationEditPolicy
;
...
...
@@ -212,33 +213,24 @@ public class AssociationPart extends PropertyAwareConnectionPart {
return
;
}
DBSEntityAssociation
association
=
getAssociation
().
getObject
();
if
(
association
instanceof
DBSEntityReferrer
&&
association
.
getReferencedConstraint
()
instanceof
DBSEntityReferrer
)
{
List
<
AttributePart
>
sourceAttributes
=
getEntityAttributes
(
(
EntityPart
)
getSource
(),
DBUtils
.
getEntityAttributes
(
new
VoidProgressMonitor
(),
(
DBSEntityReferrer
)
association
.
getReferencedConstraint
()));
List
<
AttributePart
>
targetAttributes
=
getEntityAttributes
(
(
EntityPart
)
getTarget
(),
DBUtils
.
getEntityAttributes
(
new
VoidProgressMonitor
(),
(
DBSEntityReferrer
)
association
));
Color
columnColor
=
value
!=
EditPart
.
SELECTED_NONE
?
Display
.
getDefault
().
getSystemColor
(
SWT
.
COLOR_RED
)
:
getViewer
().
getControl
().
getForeground
();
for
(
AttributePart
attr
:
sourceAttributes
)
{
attr
.
getFigure
().
setForegroundColor
(
columnColor
);
}
for
(
AttributePart
attr
:
targetAttributes
)
{
attr
.
getFigure
().
setForegroundColor
(
columnColor
);
}
Color
columnColor
=
value
!=
EditPart
.
SELECTED_NONE
?
Display
.
getDefault
().
getSystemColor
(
SWT
.
COLOR_RED
)
:
getViewer
().
getControl
().
getForeground
();
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getSource
(),
getAssociation
().
getSourceAttributes
()))
{
attrPart
.
getFigure
().
setForegroundColor
(
columnColor
);
}
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getTarget
(),
getAssociation
().
getTargetAttributes
()))
{
attrPart
.
getFigure
().
setForegroundColor
(
columnColor
);
}
}
private
List
<
AttributePart
>
getEntityAttributes
(
EntityPart
source
,
Collection
<?
extends
DBS
EntityAttribute
>
columns
)
private
List
<
AttributePart
>
getEntityAttributes
(
EntityPart
source
,
List
<
ERD
EntityAttribute
>
columns
)
{
List
<
AttributePart
>
erdColumns
=
new
ArrayList
<>(
source
.
getChildren
()
);
for
(
Iterator
<
AttributePart
>
iter
=
erdColumns
.
iterator
();
iter
.
hasNext
();
)
{
if
(
!
columns
.
contains
(
iter
.
next
().
getAttribute
().
getObject
()))
{
iter
.
remove
(
);
List
<
AttributePart
>
result
=
new
ArrayList
<>(
);
for
(
AttributePart
attrPart
:
(
List
<
AttributePart
>)
source
.
getChildren
()
)
{
if
(
columns
.
contains
(
attrPart
.
getAttribute
()))
{
result
.
add
(
attrPart
);
}
}
return
erdColumns
;
return
result
;
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录