Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
687cec02
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,发现更多精彩内容 >>
提交
687cec02
编写于
6月 25, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ERD join render
Former-commit-id:
36ffc0ec
上级
7a0c9611
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
60 deletion
+67
-60
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java
...c/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java
+1
-1
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java
...rg/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java
+3
-7
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
+36
-21
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
+27
-31
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java
浏览文件 @
687cec02
...
...
@@ -78,7 +78,7 @@ public class EntityAddCommand extends Command
public
void
undo
()
{
for
(
ERDEntity
entity
:
entities
)
{
diagramPart
.
getDiagram
().
remove
Table
(
entity
,
true
);
diagramPart
.
getDiagram
().
remove
Entity
(
entity
,
true
);
}
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java
浏览文件 @
687cec02
...
...
@@ -95,7 +95,7 @@ public class EntityDeleteCommand extends Command
// Delete entity
deleteRelationships
(
entity
);
index
=
entityDiagram
.
getEntities
().
indexOf
(
entity
);
entityDiagram
.
remove
Table
(
entity
,
true
);
entityDiagram
.
remove
Entity
(
entity
,
true
);
}
/**
...
...
@@ -109,16 +109,12 @@ public class EntityDeleteCommand extends Command
private
void
restoreRelationships
()
{
for
(
int
i
=
0
;
i
<
foreignKeyRelationships
.
size
();
i
++)
{
ERDAssociation
r
=
foreignKeyRelationships
.
get
(
i
);
for
(
ERDAssociation
r
:
foreignKeyRelationships
)
{
r
.
getSourceEntity
().
addAssociation
(
r
,
true
);
r
.
getTargetEntity
().
addReferenceAssociation
(
r
,
true
);
}
foreignKeyRelationships
.
clear
();
for
(
int
i
=
0
;
i
<
primaryKeyRelationships
.
size
();
i
++)
{
ERDAssociation
r
=
primaryKeyRelationships
.
get
(
i
);
for
(
ERDAssociation
r
:
primaryKeyRelationships
)
{
r
.
getSourceEntity
().
addAssociation
(
r
,
true
);
r
.
getTargetEntity
().
addReferenceAssociation
(
r
,
true
);
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java
浏览文件 @
687cec02
...
...
@@ -50,15 +50,15 @@ public class EntityDiagram extends ERDObject<DBSObject> {
private
ERDDecorator
decorator
;
private
String
name
;
private
List
<
ERDEntity
>
entities
=
new
ArrayList
<>();
private
final
List
<
ERDEntity
>
entities
=
new
ArrayList
<>();
private
boolean
layoutManualDesired
=
true
;
private
boolean
layoutManualAllowed
=
false
;
private
boolean
needsAutoLayout
;
private
Map
<
DBSEntity
,
ERDEntity
>
entityMap
=
new
IdentityHashMap
<>();
private
Map
<
ERDObject
,
NodeVisualInfo
>
nodeVisuals
=
new
IdentityHashMap
<>();
private
final
Map
<
DBSEntity
,
ERDEntity
>
entityMap
=
new
IdentityHashMap
<>();
private
final
Map
<
ERDObject
,
NodeVisualInfo
>
nodeVisuals
=
new
IdentityHashMap
<>();
private
List
<
ERDNote
>
notes
=
new
ArrayList
<>();
private
final
List
<
ERDNote
>
notes
=
new
ArrayList
<>();
private
ERDAttributeVisibility
attributeVisibility
;
private
ERDViewStyle
[]
attributeStyles
;
...
...
@@ -102,17 +102,25 @@ public class EntityDiagram extends ERDObject<DBSObject> {
ERDAttributeVisibility
.
setDefaultVisibility
(
ERDActivator
.
getDefault
().
getPreferences
(),
attributeVisibility
);
}
public
synchronized
void
addEntity
(
ERDEntity
entity
,
boolean
reflect
)
{
public
int
getEntityOrder
(
ERDEntity
entity
)
{
synchronized
(
entities
)
{
return
entities
.
indexOf
(
entity
);
}
}
public
void
addEntity
(
ERDEntity
entity
,
boolean
reflect
)
{
addEntity
(
entity
,
-
1
,
reflect
);
}
public
synchronized
void
addEntity
(
ERDEntity
entity
,
int
i
,
boolean
reflect
)
{
if
(
i
<
0
)
{
entities
.
add
(
entity
);
}
else
{
entities
.
add
(
i
,
entity
);
public
void
addEntity
(
ERDEntity
entity
,
int
i
,
boolean
reflect
)
{
synchronized
(
entities
)
{
if
(
i
<
0
)
{
entities
.
add
(
entity
);
}
else
{
entities
.
add
(
i
,
entity
);
}
entityMap
.
put
(
entity
.
getObject
(),
entity
);
}
entityMap
.
put
(
entity
.
getObject
(),
entity
);
if
(
reflect
)
{
firePropertyChange
(
CHILD
,
null
,
entity
);
...
...
@@ -135,6 +143,7 @@ public class EntityDiagram extends ERDObject<DBSObject> {
}
}
private
void
resolveRelations
(
boolean
reflect
)
{
// Resolve incomplete relations
for
(
ERDEntity
erdEntity
:
getEntities
())
{
...
...
@@ -142,9 +151,11 @@ public class EntityDiagram extends ERDObject<DBSObject> {
}
}
public
synchronized
void
removeTable
(
ERDEntity
entity
,
boolean
reflect
)
{
entityMap
.
remove
(
entity
.
getObject
());
entities
.
remove
(
entity
);
public
synchronized
void
removeEntity
(
ERDEntity
entity
,
boolean
reflect
)
{
synchronized
(
entities
)
{
entityMap
.
remove
(
entity
.
getObject
());
entities
.
remove
(
entity
);
}
if
(
reflect
)
{
firePropertyChange
(
CHILD
,
entity
,
null
);
}
...
...
@@ -153,24 +164,28 @@ public class EntityDiagram extends ERDObject<DBSObject> {
/**
* @return the Tables for the current schema
*/
public
synchronized
List
<
ERDEntity
>
getEntities
()
{
public
List
<
ERDEntity
>
getEntities
()
{
return
entities
;
}
public
synchronized
List
<
ERDNote
>
getNotes
()
{
public
List
<
ERDNote
>
getNotes
()
{
return
notes
;
}
public
synchronized
void
addNote
(
ERDNote
note
,
boolean
reflect
)
{
notes
.
add
(
note
);
public
void
addNote
(
ERDNote
note
,
boolean
reflect
)
{
synchronized
(
notes
)
{
notes
.
add
(
note
);
}
if
(
reflect
)
{
firePropertyChange
(
CHILD
,
null
,
note
);
}
}
public
synchronized
void
removeNote
(
ERDNote
note
,
boolean
reflect
)
{
notes
.
remove
(
note
);
public
void
removeNote
(
ERDNote
note
,
boolean
reflect
)
{
synchronized
(
notes
)
{
notes
.
remove
(
note
);
}
if
(
reflect
)
{
firePropertyChange
(
CHILD
,
note
,
null
);
...
...
@@ -228,7 +243,7 @@ public class EntityDiagram extends ERDObject<DBSObject> {
copy
.
entityMap
.
putAll
(
this
.
entityMap
);
copy
.
layoutManualDesired
=
this
.
layoutManualDesired
;
copy
.
layoutManualAllowed
=
this
.
layoutManualAllowed
;
copy
.
nodeVisuals
=
nodeVisuals
;
copy
.
nodeVisuals
.
putAll
(
this
.
nodeVisuals
)
;
return
copy
;
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/part/AssociationPart.java
浏览文件 @
687cec02
...
...
@@ -56,12 +56,10 @@ public class AssociationPart extends PropertyAwareConnectionPart {
// Keep original line width to visualize selection
private
Integer
oldLineWidth
;
public
AssociationPart
()
{
public
AssociationPart
()
{
}
public
ERDAssociation
getAssociation
()
{
public
ERDAssociation
getAssociation
()
{
return
(
ERDAssociation
)
getModel
();
}
...
...
@@ -170,7 +168,7 @@ public class AssociationPart extends PropertyAwareConnectionPart {
if
(!
identifying
||
association
.
isLogical
())
{
conn
.
setLineStyle
(
SWT
.
LINE_CUSTOM
);
conn
.
setLineDash
(
new
float
[]
{
5
}
);
conn
.
setLineDash
(
new
float
[]
{
5
}
);
}
//ChopboxAnchor sourceAnchor = new ChopboxAnchor(classFigure);
...
...
@@ -214,18 +212,17 @@ public class AssociationPart extends PropertyAwareConnectionPart {
}
Color
columnColor
=
value
!=
EditPart
.
SELECTED_NONE
?
Display
.
getDefault
().
getSystemColor
(
SWT
.
COLOR_RED
)
:
getViewer
().
getControl
().
getForeground
();
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getSource
(),
getAssociation
().
getSourceAttributes
()))
{
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getSource
(),
getAssociation
().
getSourceAttributes
()))
{
attrPart
.
getFigure
().
setForegroundColor
(
columnColor
);
}
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getTarget
(),
getAssociation
().
getTargetAttributes
()))
{
for
(
AttributePart
attrPart
:
getEntityAttributes
((
EntityPart
)
getTarget
(),
getAssociation
().
getTargetAttributes
()))
{
attrPart
.
getFigure
().
setForegroundColor
(
columnColor
);
}
}
private
List
<
AttributePart
>
getEntityAttributes
(
EntityPart
source
,
List
<
ERDEntityAttribute
>
columns
)
{
private
List
<
AttributePart
>
getEntityAttributes
(
EntityPart
source
,
List
<
ERDEntityAttribute
>
columns
)
{
List
<
AttributePart
>
result
=
new
ArrayList
<>();
for
(
AttributePart
attrPart
:
(
List
<
AttributePart
>)
source
.
getChildren
())
{
for
(
AttributePart
attrPart
:
(
List
<
AttributePart
>)
source
.
getChildren
())
{
if
(
columns
.
contains
(
attrPart
.
getAttribute
()))
{
result
.
add
(
attrPart
);
}
...
...
@@ -234,8 +231,7 @@ public class AssociationPart extends PropertyAwareConnectionPart {
}
@Override
public
void
performRequest
(
Request
request
)
{
public
void
performRequest
(
Request
request
)
{
if
(
request
.
getType
()
==
RequestConstants
.
REQ_OPEN
)
{
ERDUtils
.
openObjectEditor
(
getAssociation
());
}
...
...
@@ -291,8 +287,7 @@ public class AssociationPart extends PropertyAwareConnectionPart {
}
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getAssociation
().
getObject
().
getConstraintType
().
getName
()
+
" "
+
getAssociation
().
getObject
().
getName
();
}
...
...
@@ -305,25 +300,24 @@ public class AssociationPart extends PropertyAwareConnectionPart {
super
();
}
public
void
setRadius
(
int
radius
)
{
public
void
setRadius
(
int
radius
)
{
this
.
radius
=
radius
;
}
@Override
public
void
setLocation
(
Point
p
)
{
location
=
p
;
Rectangle
bounds
=
new
Rectangle
(
location
.
x
-
radius
,
location
.
y
-
radius
,
radius
*
2
,
radius
*
2
);
Rectangle
bounds
=
new
Rectangle
(
location
.
x
-
radius
,
location
.
y
-
radius
,
radius
*
2
,
radius
*
2
);
setBounds
(
bounds
);
}
@Override
public
void
setReferencePoint
(
Point
p
)
{
// length of line between reference point and location
double
d
=
Math
.
sqrt
(
Math
.
pow
((
location
.
x
-
p
.
x
),
2
)+
Math
.
pow
(
location
.
y
-
p
.
y
,
2
));
double
d
=
Math
.
sqrt
(
Math
.
pow
((
location
.
x
-
p
.
x
),
2
)
+
Math
.
pow
(
location
.
y
-
p
.
y
,
2
));
// do nothing if link is too short.
if
(
d
<
radius
)
if
(
d
<
radius
)
return
;
//
...
...
@@ -356,40 +350,42 @@ public class AssociationPart extends PropertyAwareConnectionPart {
//
// remember that d > radius.
//
double
k
=
(
d
-
radius
)/
d
;
double
longx
=
Math
.
abs
(
p
.
x
-
location
.
x
);
double
longy
=
Math
.
abs
(
p
.
y
-
location
.
y
);
double
k
=
(
d
-
radius
)
/
d
;
double
longx
=
Math
.
abs
(
p
.
x
-
location
.
x
);
double
longy
=
Math
.
abs
(
p
.
y
-
location
.
y
);
double
shortx
=
k
*
longx
;
double
shorty
=
k
*
longy
;
double
shortx
=
k
*
longx
;
double
shorty
=
k
*
longy
;
// now create locate the new point using the distances depending on the location of the original points.
int
rx
,
ry
;
if
(
location
.
x
<
p
.
x
)
{
rx
=
p
.
x
-
(
int
)
shortx
;
if
(
location
.
x
<
p
.
x
)
{
rx
=
p
.
x
-
(
int
)
shortx
;
}
else
{
rx
=
p
.
x
+
(
int
)
shortx
;
rx
=
p
.
x
+
(
int
)
shortx
;
}
if
(
location
.
y
>
p
.
y
)
{
ry
=
p
.
y
+
(
int
)
shorty
;
if
(
location
.
y
>
p
.
y
)
{
ry
=
p
.
y
+
(
int
)
shorty
;
}
else
{
ry
=
p
.
y
-
(
int
)
shorty
;
ry
=
p
.
y
-
(
int
)
shorty
;
}
// For reasons that are still unknown to me, I had to increase the radius
// of the circle for the graphics to look right.
setBounds
(
new
Rectangle
(
rx
-
radius
,
ry
-
radius
,
(
int
)(
radius
*
2.5
),
(
int
)(
radius
*
2.5
)));
setBounds
(
new
Rectangle
(
rx
-
radius
,
ry
-
radius
,
(
int
)
(
radius
*
2.5
),
(
int
)
(
radius
*
2.5
)));
}
}
public
static
class
RhombusDecoration
extends
PolygonDecoration
{
private
static
PointList
GEOMETRY
=
new
PointList
();
static
{
GEOMETRY
.
addPoint
(
0
,
0
);
GEOMETRY
.
addPoint
(-
1
,
1
);
GEOMETRY
.
addPoint
(-
2
,
0
);
GEOMETRY
.
addPoint
(-
1
,
-
1
);
}
public
RhombusDecoration
()
{
setTemplate
(
GEOMETRY
);
setFill
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录