Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
4fdebd34
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,发现更多精彩内容 >>
提交
4fdebd34
编写于
8月 23, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6570 ERD save (for entities and containers). EntityEditor save prompt fix (show sub-editor names)
上级
baea716f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
137 addition
and
48 deletion
+137
-48
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
...c/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
+8
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVContainer.java
...del/src/org/jkiss/dbeaver/model/virtual/DBVContainer.java
+11
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
+3
-38
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModel.java
...r.model/src/org/jkiss/dbeaver/model/virtual/DBVModel.java
+26
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
...jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
+1
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVObject.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVObject.java
+54
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
...r.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
+6
-0
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
...rg/jkiss/dbeaver/registry/DataSourceSerializerModern.java
+3
-0
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
...src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
+12
-2
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditorDescriptor.java
...iss/dbeaver/ui/editors/entity/EntityEditorDescriptor.java
+4
-0
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditorsRegistry.java
...kiss/dbeaver/ui/editors/entity/EntityEditorsRegistry.java
+9
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java
浏览文件 @
4fdebd34
...
...
@@ -33,7 +33,7 @@ import org.jkiss.dbeaver.model.exec.DBExecUtils;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.model.virtual.DBV
Entity
;
import
org.jkiss.dbeaver.model.virtual.DBV
Object
;
import
org.jkiss.dbeaver.model.virtual.DBVUtils
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.IActiveWorkbenchPart
;
...
...
@@ -322,17 +322,17 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
public
void
doSave
(
IProgressMonitor
monitor
)
{
try
{
// Save in virtual model as entity property.
DBV
Entity
vEntity
=
this
.
getVirtualEntity
();
if
(
v
Entity
==
null
)
{
DBV
Object
vObject
=
this
.
getVirtualObject
();
if
(
v
Object
==
null
)
{
return
;
}
Map
<
String
,
Object
>
diagramStateMap
=
new
LinkedHashMap
<>();
v
Entity
.
setProperty
(
PROP_DIAGRAM_STATE
,
diagramStateMap
);
v
Object
.
setProperty
(
PROP_DIAGRAM_STATE
,
diagramStateMap
);
String
diagramState
=
DiagramLoader
.
serializeDiagram
(
RuntimeUtils
.
makeMonitor
(
monitor
),
getDiagramPart
(),
getDiagram
(),
false
,
true
);
diagramStateMap
.
put
(
PROPS_DIAGRAM_SERIALIZED
,
diagramState
);
v
Entity
.
persistConfiguration
();
v
Object
.
persistConfiguration
();
getCommandStack
().
markSaveLocation
();
}
catch
(
Exception
e
)
{
...
...
@@ -341,12 +341,13 @@ public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor,
}
@Nullable
private
DBV
Entity
getVirtualEntity
()
{
private
DBV
Object
getVirtualObject
()
{
DBSObject
rootObject
=
getRootObject
();
if
(
rootObject
instanceof
DBSEntity
)
{
return
DBVUtils
.
getVirtualEntity
((
DBSEntity
)
rootObject
,
true
);
}
else
{
return
DBVUtils
.
getVirtualObject
(
rootObject
,
true
);
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVContainer.java
浏览文件 @
4fdebd34
...
...
@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.model.DBPDataSource;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSObjectContainer
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.Collection
;
import
java.util.LinkedHashMap
;
...
...
@@ -34,6 +35,7 @@ import java.util.Map;
public
class
DBVContainer
extends
DBVObject
implements
DBSObjectContainer
{
static
final
String
ENTITY_PREFIX
=
":"
;
static
final
String
CONFIG_PREFIX
=
"@"
;
private
final
DBVContainer
parent
;
private
String
name
;
...
...
@@ -58,6 +60,7 @@ public class DBVContainer extends DBVObject implements DBSObjectContainer {
for
(
Map
.
Entry
<
String
,
DBVEntity
>
ee
:
source
.
entities
.
entrySet
())
{
this
.
entities
.
put
(
ee
.
getKey
(),
new
DBVEntity
(
this
,
ee
.
getValue
()));
}
super
.
copyFrom
(
source
);
}
DBVContainer
(
DBVContainer
parent
,
String
name
,
Map
<
String
,
Object
>
map
)
{
...
...
@@ -67,7 +70,11 @@ public class DBVContainer extends DBVObject implements DBSObjectContainer {
String
id
=
element
.
getKey
();
if
(
id
.
startsWith
(
ENTITY_PREFIX
))
{
DBVEntity
entity
=
new
DBVEntity
(
this
,
id
.
substring
(
ENTITY_PREFIX
.
length
()),
(
Map
<
String
,
Object
>)
element
.
getValue
());
entities
.
put
(
entity
.
getName
(),
entity
);
}
else
if
(
id
.
startsWith
(
CONFIG_PREFIX
))
{
String
configMap
=
id
.
substring
(
CONFIG_PREFIX
.
length
());
if
(
configMap
.
equals
(
"properties"
))
{
loadPropertiesFrom
(
map
,
id
);
}
}
else
if
(
element
.
getValue
()
instanceof
Map
)
{
DBVContainer
child
=
new
DBVContainer
(
this
,
id
,
(
Map
<
String
,
Object
>)
element
.
getValue
());
containers
.
put
(
child
.
getName
(),
child
);
...
...
@@ -161,6 +168,9 @@ public class DBVContainer extends DBVObject implements DBSObjectContainer {
@Override
public
boolean
hasValuableData
()
{
if
(!
CommonUtils
.
isEmpty
(
getProperties
()))
{
return
true
;
}
for
(
DBVEntity
entity
:
getEntities
())
{
if
(
entity
.
hasValuableData
())
{
return
true
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
浏览文件 @
4fdebd34
...
...
@@ -62,7 +62,6 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
private
List
<
DBVEntityConstraint
>
entityConstraints
;
private
List
<
DBVEntityForeignKey
>
entityForeignKeys
;
private
List
<
DBVEntityAttribute
>
entityAttributes
;
private
Map
<
String
,
Object
>
properties
;
private
List
<
DBVColorOverride
>
colorOverrides
;
public
DBVEntity
(
@NotNull
DBVContainer
container
,
@NotNull
String
name
,
String
descriptionColumnNames
)
{
...
...
@@ -99,15 +98,13 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
this
.
entityAttributes
.
add
(
new
DBVEntityAttribute
(
this
,
null
,
attribute
));
}
}
if
(!
CommonUtils
.
isEmpty
(
src
.
properties
))
{
this
.
properties
=
new
LinkedHashMap
<>(
src
.
properties
);
}
if
(!
CommonUtils
.
isEmpty
(
src
.
colorOverrides
))
{
this
.
colorOverrides
=
new
ArrayList
<>(
src
.
colorOverrides
.
size
());
for
(
DBVColorOverride
co
:
src
.
colorOverrides
)
{
this
.
colorOverrides
.
add
(
new
DBVColorOverride
(
co
));
}
}
super
.
copyFrom
(
src
);
}
DBVEntity
(
@NotNull
DBVContainer
container
,
@NotNull
String
name
,
@NotNull
Map
<
String
,
Object
>
map
)
{
...
...
@@ -176,7 +173,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
addColorOverride
(
curColor
);
}
properties
=
JSONUtils
.
deserializeProperties
(
map
,
"properties"
);
loadPropertiesFrom
(
map
,
"properties"
);
}
@NotNull
...
...
@@ -236,31 +233,6 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
return
DBSEntityType
.
VIRTUAL_ENTITY
;
}
/**
* Property value can be String, Number, Boolean, List or Map
* @param name property name
*/
@Nullable
public
Object
getProperty
(
@NotNull
String
name
)
{
return
CommonUtils
.
isEmpty
(
properties
)
?
null
:
properties
.
get
(
name
);
}
public
void
setProperty
(
String
name
,
@Nullable
Object
value
)
{
if
(
properties
==
null
)
{
properties
=
new
LinkedHashMap
<>();
}
if
(
value
==
null
)
{
properties
.
remove
(
name
);
}
else
{
properties
.
put
(
name
,
value
);
}
}
@NotNull
public
Map
<
String
,
Object
>
getProperties
()
{
return
properties
==
null
?
Collections
.
emptyMap
()
:
properties
;
}
public
List
<
DBVEntityAttribute
>
getEntityAttributes
()
{
return
entityAttributes
;
}
...
...
@@ -554,7 +526,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Override
public
boolean
hasValuableData
()
{
if
(!
CommonUtils
.
isEmpty
(
descriptionColumnNames
)
||
!
CommonUtils
.
isEmpty
(
properties
)
||
!
CommonUtils
.
isEmpty
(
getProperties
()
)
||
!
CommonUtils
.
isEmpty
(
entityForeignKeys
)
||
!
CommonUtils
.
isEmpty
(
colorOverrides
))
{
...
...
@@ -598,13 +570,6 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
}
}
public
void
persistConfiguration
()
{
DBPDataSource
dataSource
=
getDataSource
();
if
(
dataSource
!=
null
)
{
dataSource
.
getContainer
().
persistConfiguration
();
}
}
@Override
public
<
T
>
T
getAdapter
(
Class
<
T
>
adapter
)
{
return
null
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModel.java
浏览文件 @
4fdebd34
...
...
@@ -121,6 +121,32 @@ public class DBVModel extends DBVContainer {
return
container
.
getEntity
(
entity
.
getName
(),
createNew
);
}
public
DBVObject
findObject
(
DBSObject
source
,
boolean
create
)
{
DBSObject
[]
path
=
DBUtils
.
getObjectPath
(
source
,
true
);
if
(
path
.
length
==
0
)
{
log
.
warn
(
"Empty entity path"
);
return
null
;
}
if
(
path
[
0
]
!=
dataSourceContainer
)
{
log
.
warn
(
"Entity's root must be datasource container '"
+
dataSourceContainer
.
getName
()
+
"'"
);
return
null
;
}
DBVContainer
container
=
this
;
for
(
int
i
=
1
;
i
<
path
.
length
;
i
++)
{
DBSObject
item
=
path
[
i
];
DBVContainer
childContainer
=
container
.
getContainer
(
item
.
getName
(),
create
);
if
(
childContainer
==
null
)
{
if
(
i
==
path
.
length
-
1
)
{
return
container
.
getEntity
(
item
.
getName
(),
create
);
}
return
null
;
}
else
{
container
=
childContainer
;
}
}
return
container
;
}
public
void
serialize
(
DBRProgressMonitor
monitor
,
JsonWriter
json
)
throws
IOException
,
DBException
{
DBVModelSerializerModern
.
serializeContainer
(
monitor
,
json
,
this
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
浏览文件 @
4fdebd34
...
...
@@ -53,6 +53,7 @@ class DBVModelSerializerModern implements DBVModelSerializer
}
json
.
beginObject
();
JSONUtils
.
serializeProperties
(
json
,
DBVContainer
.
CONFIG_PREFIX
+
"properties"
,
object
.
getProperties
());
for
(
DBVEntity
entity
:
object
.
getEntities
())
{
if
(
entity
.
hasValuableData
())
{
serializeEntity
(
monitor
,
json
,
entity
);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVObject.java
浏览文件 @
4fdebd34
...
...
@@ -16,8 +16,18 @@
*/
package
org.jkiss.dbeaver.model.virtual
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.data.json.JSONUtils
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* Virtual model object
...
...
@@ -27,6 +37,7 @@ public abstract class DBVObject implements DBSObject {
static
final
Log
log
=
Log
.
getLog
(
DBVObject
.
class
);
private
DBVTransformSettings
transformSettings
;
private
Map
<
String
,
Object
>
properties
;
@Override
public
abstract
DBVContainer
getParentObject
();
...
...
@@ -46,4 +57,47 @@ public abstract class DBVObject implements DBSObject {
abstract
public
boolean
hasValuableData
();
/**
* Property value can be String, Number, Boolean, List or Map
* @param name property name
*/
@Nullable
public
Object
getProperty
(
@NotNull
String
name
)
{
return
CommonUtils
.
isEmpty
(
properties
)
?
null
:
properties
.
get
(
name
);
}
public
void
setProperty
(
String
name
,
@Nullable
Object
value
)
{
if
(
properties
==
null
)
{
properties
=
new
LinkedHashMap
<>();
}
if
(
value
==
null
)
{
properties
.
remove
(
name
);
}
else
{
properties
.
put
(
name
,
value
);
}
}
@NotNull
public
Map
<
String
,
Object
>
getProperties
()
{
return
properties
==
null
?
Collections
.
emptyMap
()
:
properties
;
}
protected
void
copyFrom
(
@NotNull
DBVObject
src
)
{
if
(!
CommonUtils
.
isEmpty
(
src
.
properties
))
{
this
.
properties
=
new
LinkedHashMap
<>(
src
.
properties
);
}
}
protected
void
loadPropertiesFrom
(
@NotNull
Map
<
String
,
Object
>
map
,
String
elemName
)
{
properties
=
JSONUtils
.
deserializeProperties
(
map
,
elemName
);
}
public
void
persistConfiguration
()
{
DBPDataSource
dataSource
=
getDataSource
();
if
(
dataSource
!=
null
)
{
dataSource
.
getContainer
().
persistConfiguration
();
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
浏览文件 @
4fdebd34
...
...
@@ -303,4 +303,10 @@ public abstract class DBVUtils {
return
entity
;
}
public
static
DBVObject
getVirtualObject
(
DBSObject
source
,
boolean
create
)
{
if
(
source
instanceof
DBVObject
)
{
return
(
DBVObject
)
source
;
}
return
source
.
getDataSource
().
getContainer
().
getVirtualModel
().
findObject
(
source
,
create
);
}
}
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
浏览文件 @
4fdebd34
...
...
@@ -704,6 +704,9 @@ class DataSourceSerializerModern implements DataSourceSerializer
json
.
beginObject
();
for
(
DBPConnectionEventType
eventType
:
connectionInfo
.
getDeclaredEvents
())
{
DBRShellCommand
command
=
connectionInfo
.
getEvent
(
eventType
);
if
(!
command
.
isEnabled
())
{
continue
;
}
json
.
name
(
eventType
.
name
());
json
.
beginObject
();
JSONUtils
.
field
(
json
,
RegistryConstants
.
ATTR_ENABLED
,
command
.
isEnabled
());
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
浏览文件 @
4fdebd34
...
...
@@ -61,6 +61,7 @@ import org.jkiss.dbeaver.ui.controls.folders.ITabbedFolderContainer;
import
org.jkiss.dbeaver.ui.controls.folders.ITabbedFolderListener
;
import
org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog
;
import
org.jkiss.dbeaver.ui.editors.*
;
import
org.jkiss.dbeaver.ui.editors.entity.properties.ObjectPropertiesEditor
;
import
org.jkiss.dbeaver.ui.internal.UINavigatorMessages
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorPreferences
;
import
org.jkiss.dbeaver.ui.navigator.actions.NavigatorHandlerObjectOpen
;
...
...
@@ -682,13 +683,22 @@ public class EntityEditor extends MultiPageDatabaseEditor
public
int
promptToSaveOnClose
()
{
List
<
String
>
changedSubEditors
=
new
ArrayList
<>();
final
DBECommandContext
commandContext
=
getCommandContext
();
if
(
commandContext
!=
null
&&
commandContext
.
isDirty
())
{
changedSubEditors
.
add
(
UINavigatorMessages
.
registry_entity_editor_descriptor_name
);
}
for
(
IEditorPart
editor
:
editorMap
.
values
())
{
if
(
editor
.
isDirty
())
{
changedSubEditors
.
add
(
editor
.
getTitle
());
EntityEditorDescriptor
editorDescriptor
=
EntityEditorsRegistry
.
getInstance
().
getEntityEditor
(
editor
);
if
(
editorDescriptor
!=
null
)
{
changedSubEditors
.
add
(
editorDescriptor
.
getName
());
}
}
}
String
subEditorsString
=
"("
+
String
.
join
(
", "
,
changedSubEditors
)
+
")"
;
String
subEditorsString
=
changedSubEditors
.
isEmpty
()
?
""
:
"("
+
String
.
join
(
", "
,
changedSubEditors
)
+
")"
;
final
int
result
=
ConfirmationDialog
.
showConfirmDialog
(
ResourceBundle
.
getBundle
(
UINavigatorMessages
.
BUNDLE_NAME
),
getSite
().
getShell
(),
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditorDescriptor.java
浏览文件 @
4fdebd34
...
...
@@ -174,6 +174,10 @@ public class EntityEditorDescriptor extends AbstractContextDescriptor
}
}
public
ObjectType
getEditorType
()
{
return
editorType
;
}
@Override
public
String
toString
()
{
return
id
;
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditorsRegistry.java
浏览文件 @
4fdebd34
...
...
@@ -20,6 +20,7 @@ package org.jkiss.dbeaver.ui.editors.entity;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.ui.IEditorPart
;
import
org.jkiss.dbeaver.model.DBPObject
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -114,4 +115,12 @@ public class EntityEditorsRegistry {
return
null
;
}
public
EntityEditorDescriptor
getEntityEditor
(
IEditorPart
editor
)
{
for
(
EntityEditorDescriptor
ed
:
entityEditors
)
{
if
(
ed
.
getEditorType
().
getImplName
().
equals
(
editor
.
getClass
().
getName
()))
{
return
ed
;
}
}
return
null
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录