Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
b8d35d45
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,发现更多精彩内容 >>
提交
b8d35d45
编写于
12月 30, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#4814 ERD: entity-specific attributes visibility
上级
d08ca785
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
153 addition
and
20 deletion
+153
-20
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java
...er.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java
+7
-2
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties
...erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties
+5
-0
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java
...d/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java
+71
-10
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
+14
-0
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDDecoratorDefault.java
.../org/jkiss/dbeaver/ext/erd/model/ERDDecoratorDefault.java
+4
-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
+16
-0
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
+1
-0
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/part/EntityPart.java
...xt.erd/src/org/jkiss/dbeaver/ext/erd/part/EntityPart.java
+3
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetReferenceMenu.java
...dbeaver/ui/controls/resultset/ResultSetReferenceMenu.java
+1
-7
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/EmptyAction.java
...kiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/EmptyAction.java
+31
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java
浏览文件 @
b8d35d45
...
...
@@ -23,7 +23,7 @@ import org.eclipse.osgi.util.NLS;
public
class
ERDMessages
extends
NLS
{
static
final
String
BUNDLE_NAME
=
"org.jkiss.dbeaver.ext.erd.ERDResources"
;
//$NON-NLS-1$
static
{
static
{
// initialize resource bundle
NLS
.
initializeMessages
(
BUNDLE_NAME
,
ERDMessages
.
class
);
}
...
...
@@ -69,7 +69,12 @@ public class ERDMessages extends NLS {
public
static
String
erd_tool_create_note
;
public
static
String
erd_tool_create_note_tip
;
public
static
String
erd_tool_create_default
;
public
static
String
menu_view_style
;
public
static
String
menu_attribute_visibility
;
public
static
String
menu_attribute_visibility_default
;
public
static
String
menu_attribute_visibility_entity
;
private
ERDMessages
()
{
}
}
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties
浏览文件 @
b8d35d45
...
...
@@ -41,3 +41,8 @@ erd_tool_create_connection_tip = Create logical connection (foreign key)
erd_tool_create_note
=
Note
erd_tool_create_note_tip
=
Create diagram note
erd_tool_create_default
=
Note
menu_view_style
=
View Styles
menu_attribute_visibility
=
Show Attributes
menu_attribute_visibility_default
=
All Entities
menu_attribute_visibility_entity
=
Selected Entity
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java
浏览文件 @
b8d35d45
...
...
@@ -41,6 +41,7 @@ import org.eclipse.jface.action.*;
import
org.eclipse.jface.preference.IPreferenceStore
;
import
org.eclipse.jface.util.IPropertyChangeListener
;
import
org.eclipse.jface.util.PropertyChangeEvent
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.printing.PrintDialog
;
...
...
@@ -76,10 +77,13 @@ import org.jkiss.dbeaver.ext.erd.export.ERDExportFormatHandler;
import
org.jkiss.dbeaver.ext.erd.export.ERDExportFormatRegistry
;
import
org.jkiss.dbeaver.ext.erd.model.ERDDecorator
;
import
org.jkiss.dbeaver.ext.erd.model.ERDDecoratorDefault
;
import
org.jkiss.dbeaver.ext.erd.model.ERDEntity
;
import
org.jkiss.dbeaver.ext.erd.model.EntityDiagram
;
import
org.jkiss.dbeaver.ext.erd.part.DiagramPart
;
import
org.jkiss.dbeaver.ext.erd.part.EntityPart
;
import
org.jkiss.dbeaver.model.DBPDataSourceTask
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.*
;
import
org.jkiss.dbeaver.ui.controls.ProgressPageControl
;
...
...
@@ -671,7 +675,7 @@ public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette
public
void
fillAttributeVisibilityMenu
(
IMenuManager
menu
)
{
MenuManager
asMenu
=
new
MenuManager
(
"View Styles"
);
MenuManager
asMenu
=
new
MenuManager
(
ERDMessages
.
menu_view_style
);
asMenu
.
add
(
new
ChangeAttributePresentationAction
(
ERDViewStyle
.
ICONS
));
asMenu
.
add
(
new
ChangeAttributePresentationAction
(
ERDViewStyle
.
TYPES
));
asMenu
.
add
(
new
ChangeAttributePresentationAction
(
ERDViewStyle
.
NULLABILITY
));
...
...
@@ -679,11 +683,37 @@ public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette
asMenu
.
add
(
new
ChangeAttributePresentationAction
(
ERDViewStyle
.
ENTITY_FQN
));
menu
.
add
(
asMenu
);
MenuManager
avMenu
=
new
MenuManager
(
"Show Attributes"
);
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
ERDAttributeVisibility
.
ALL
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
ERDAttributeVisibility
.
KEYS
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
ERDAttributeVisibility
.
PRIMARY
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
ERDAttributeVisibility
.
NONE
));
MenuManager
avMenu
=
new
MenuManager
(
ERDMessages
.
menu_attribute_visibility
);
avMenu
.
add
(
new
EmptyAction
(
ERDMessages
.
menu_attribute_visibility_default
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
true
,
ERDAttributeVisibility
.
ALL
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
true
,
ERDAttributeVisibility
.
KEYS
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
true
,
ERDAttributeVisibility
.
PRIMARY
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
true
,
ERDAttributeVisibility
.
NONE
));
ISelection
selection
=
getGraphicalViewer
().
getSelection
();
if
(
selection
instanceof
IStructuredSelection
&&
!
selection
.
isEmpty
())
{
int
totalEntities
=
0
;
for
(
Object
item
:
((
IStructuredSelection
)
selection
).
toArray
())
{
if
(
item
instanceof
EntityPart
)
{
totalEntities
++;
}
}
if
(
totalEntities
>
0
)
{
avMenu
.
add
(
new
Separator
());
String
avaTitle
=
ERDMessages
.
menu_attribute_visibility_entity
;
if
(((
IStructuredSelection
)
selection
).
size
()
==
1
)
{
avaTitle
+=
" ("
+
((
IStructuredSelection
)
selection
).
getFirstElement
()
+
")"
;
}
else
{
avaTitle
+=
" ("
+
totalEntities
+
")"
;
}
avMenu
.
add
(
new
EmptyAction
(
avaTitle
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
false
,
ERDAttributeVisibility
.
ALL
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
false
,
ERDAttributeVisibility
.
KEYS
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
false
,
ERDAttributeVisibility
.
PRIMARY
));
avMenu
.
add
(
new
ChangeAttributeVisibilityAction
(
false
,
ERDAttributeVisibility
.
NONE
));
}
}
menu
.
add
(
avMenu
);
}
...
...
@@ -883,25 +913,56 @@ public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette
}
private
class
ChangeAttributeVisibilityAction
extends
Action
{
private
final
boolean
defStyle
;
private
final
ERDAttributeVisibility
visibility
;
private
ChangeAttributeVisibilityAction
(
ERDAttributeVisibility
visibility
)
private
ChangeAttributeVisibilityAction
(
boolean
defStyle
,
ERDAttributeVisibility
visibility
)
{
super
(
visibility
.
getTitle
(),
IAction
.
AS_RADIO_BUTTON
);
this
.
defStyle
=
defStyle
;
this
.
visibility
=
visibility
;
}
@Override
public
boolean
isChecked
()
{
return
visibility
==
getDiagram
().
getAttributeVisibility
();
if
(
defStyle
)
{
return
visibility
==
getDiagram
().
getAttributeVisibility
();
}
else
{
for
(
Object
object
:
((
IStructuredSelection
)
getGraphicalViewer
().
getSelection
()).
toArray
())
{
if
(
object
instanceof
EntityPart
)
{
if
(((
EntityPart
)
object
).
getEntity
().
getAttributeVisibility
()
==
visibility
)
{
return
true
;
}
}
}
return
false
;
}
}
@Override
public
void
run
()
{
getDiagram
().
setAttributeVisibility
(
visibility
);
refreshDiagram
(
true
,
false
);
EntityDiagram
diagram
=
getDiagram
();
if
(
defStyle
)
{
diagram
.
setAttributeVisibility
(
visibility
);
for
(
ERDEntity
entity
:
diagram
.
getEntities
())
{
entity
.
reloadAttributes
(
diagram
);
}
}
else
{
boolean
reset
=
(
visibility
==
diagram
.
getAttributeVisibility
());
for
(
Object
object
:
((
IStructuredSelection
)
getGraphicalViewer
().
getSelection
()).
toArray
())
{
if
(
object
instanceof
EntityPart
)
{
if
(
reset
)
{
((
EntityPart
)
object
).
getEntity
().
setAttributeVisibility
(
null
);
}
else
{
((
EntityPart
)
object
).
getEntity
().
setAttributeVisibility
(
visibility
);
}
((
EntityPart
)
object
).
getEntity
().
reloadAttributes
(
diagram
);
}
}
}
UIUtils
.
asyncExec
(()
->
getGraphicalViewer
().
setContents
(
diagram
));
}
}
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java
浏览文件 @
b8d35d45
...
...
@@ -33,6 +33,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.erd.ERDConstants
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDAttributeVisibility
;
import
org.jkiss.dbeaver.ext.erd.part.*
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.app.DBPDataSourceRegistry
;
...
...
@@ -75,6 +76,7 @@ public class DiagramLoader
private
static
final
String
ATTR_VERSION
=
"version"
;
private
static
final
String
ATTR_NAME
=
"name"
;
private
static
final
String
ATTR_TIME
=
"time"
;
private
static
final
String
ATTR_ALIAS
=
"alias"
;
private
static
final
String
ATTR_ID
=
"id"
;
private
static
final
String
ATTR_ORDER
=
"order"
;
private
static
final
String
ATTR_COLOR_BG
=
"color-bg"
;
...
...
@@ -83,6 +85,7 @@ public class DiagramLoader
private
static
final
String
ATTR_TYPE
=
"type"
;
private
static
final
String
ATTR_PK_REF
=
"pk-ref"
;
private
static
final
String
ATTR_FK_REF
=
"fk-ref"
;
private
static
final
String
ATTR_ATTRIBUTE_VISIBILITY
=
"showAttrs"
;
private
static
final
String
TAG_COLUMN
=
"column"
;
private
static
final
String
ATTR_X
=
"x"
;
private
static
final
String
ATTR_Y
=
"y"
;
...
...
@@ -272,6 +275,8 @@ public class DiagramLoader
}
String
locX
=
entityElem
.
getAttribute
(
ATTR_X
);
String
locY
=
entityElem
.
getAttribute
(
ATTR_Y
);
String
attrVis
=
entityElem
.
getAttribute
(
ATTR_ATTRIBUTE_VISIBILITY
);
DBSEntity
table
=
(
DBSEntity
)
child
;
EntityDiagram
.
NodeVisualInfo
visualInfo
=
new
EntityDiagram
.
NodeVisualInfo
();
...
...
@@ -291,6 +296,9 @@ public class DiagramLoader
if
(!
CommonUtils
.
isEmpty
(
orderStr
))
{
visualInfo
.
zOrder
=
Integer
.
parseInt
(
orderStr
);
}
if
(!
CommonUtils
.
isEmpty
(
attrVis
))
{
visualInfo
.
attributeVisibility
=
ERDAttributeVisibility
.
valueOf
(
attrVis
);
}
TableLoadInfo
info
=
new
TableLoadInfo
(
tableId
,
table
,
visualInfo
);
tableInfos
.
add
(
info
);
...
...
@@ -498,6 +506,12 @@ public class DiagramLoader
if
(
table
instanceof
DBPQualifiedObject
)
{
xml
.
addAttribute
(
ATTR_FQ_NAME
,
((
DBPQualifiedObject
)
table
).
getFullyQualifiedName
(
DBPEvaluationContext
.
UI
));
}
if
(!
CommonUtils
.
isEmpty
(
erdEntity
.
getAlias
()))
{
xml
.
addAttribute
(
ATTR_ALIAS
,
erdEntity
.
getAlias
());
}
if
(
erdEntity
.
getAttributeVisibility
()
!=
null
)
{
xml
.
addAttribute
(
ATTR_ATTRIBUTE_VISIBILITY
,
erdEntity
.
getAttributeVisibility
().
name
());
}
EntityDiagram
.
NodeVisualInfo
visualInfo
;
if
(
tablePart
!=
null
)
{
visualInfo
=
new
EntityDiagram
.
NodeVisualInfo
();
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDDecoratorDefault.java
浏览文件 @
b8d35d45
...
...
@@ -124,7 +124,10 @@ public class ERDDecoratorDefault implements ERDDecorator {
@Override
public
void
fillEntityFromObject
(
DBRProgressMonitor
monitor
,
EntityDiagram
diagram
,
ERDEntity
erdEntity
)
{
DBSEntity
entity
=
erdEntity
.
getObject
();
ERDAttributeVisibility
attributeVisibility
=
diagram
.
getAttributeVisibility
();
ERDAttributeVisibility
attributeVisibility
=
erdEntity
.
getAttributeVisibility
();
if
(
attributeVisibility
==
null
)
{
attributeVisibility
=
diagram
.
getAttributeVisibility
();
}
if
(
attributeVisibility
!=
ERDAttributeVisibility
.
NONE
)
{
Set
<
DBSEntityAttribute
>
keyColumns
=
null
;
if
(
attributeVisibility
==
ERDAttributeVisibility
.
KEYS
)
{
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java
浏览文件 @
b8d35d45
...
...
@@ -22,9 +22,11 @@ package org.jkiss.dbeaver.ext.erd.model;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.erd.editor.ERDAttributeVisibility
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -49,6 +51,7 @@ public class ERDEntity extends ERDObject<DBSEntity> {
private
List
<
DBSEntityAssociation
>
unresolvedKeys
;
private
boolean
primary
=
false
;
private
ERDAttributeVisibility
attributeVisibility
;
/**
* Special constructore for creating lazy entities.
...
...
@@ -75,6 +78,14 @@ public class ERDEntity extends ERDObject<DBSEntity> {
this
.
alias
=
alias
;
}
public
ERDAttributeVisibility
getAttributeVisibility
()
{
return
attributeVisibility
;
}
public
void
setAttributeVisibility
(
ERDAttributeVisibility
attributeVisibility
)
{
this
.
attributeVisibility
=
attributeVisibility
;
}
public
void
addAttribute
(
ERDEntityAttribute
attribute
,
boolean
reflect
)
{
if
(
attributes
==
null
)
{
attributes
=
new
ArrayList
<>();
...
...
@@ -175,6 +186,11 @@ public class ERDEntity extends ERDObject<DBSEntity> {
return
result
;
}
public
void
reloadAttributes
(
EntityDiagram
diagram
)
{
attributes
.
clear
();
diagram
.
getDecorator
().
fillEntityFromObject
(
new
VoidProgressMonitor
(),
diagram
,
this
);
}
/**
* @return Returns the associations.
*/
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java
浏览文件 @
b8d35d45
...
...
@@ -46,6 +46,7 @@ public class EntityDiagram extends ERDObject<DBSObject> implements ERDContainer
public
Rectangle
initBounds
;
public
Color
bgColor
;
public
int
zOrder
=
0
;
public
ERDAttributeVisibility
attributeVisibility
;
}
private
ERDDecorator
decorator
;
...
...
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/part/EntityPart.java
浏览文件 @
b8d35d45
...
...
@@ -196,6 +196,9 @@ public class EntityPart extends NodePart {
if
(
this
.
customBackground
!=
null
)
{
figure
.
setBackgroundColor
(
this
.
customBackground
);
}
if
(
visualInfo
.
attributeVisibility
!=
null
)
{
getEntity
().
setAttributeVisibility
(
visualInfo
.
attributeVisibility
);
}
}
return
figure
;
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetReferenceMenu.java
浏览文件 @
b8d35d45
...
...
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.model.struct.*;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.EmptyAction
;
import
org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -50,13 +51,6 @@ public class ResultSetReferenceMenu
static
Action
NOREFS_ACTION
,
REFS_TITLE_ACTION
,
NOFKS_ACTION
,
FKS_TITLE_ACTION
;
private
static
class
EmptyAction
extends
Action
{
public
EmptyAction
(
String
text
)
{
super
(
text
);
setEnabled
(
false
);
}
}
static
{
NOREFS_ACTION
=
new
EmptyAction
(
ResultSetMessages
.
controls_resultset_ref_menu_no_references
);
REFS_TITLE_ACTION
=
new
EmptyAction
(
ResultSetMessages
.
controls_resultset_ref_menu_references
);
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/EmptyAction.java
0 → 100644
浏览文件 @
b8d35d45
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui
;
import
org.eclipse.jface.action.Action
;
/**
* Actions used for comments/info strings
*/
public
class
EmptyAction
extends
Action
{
public
EmptyAction
(
String
text
)
{
super
(
text
);
setEnabled
(
false
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录