Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
7afb4e24
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,发现更多精彩内容 >>
提交
7afb4e24
编写于
8月 12, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Compelx elements add/edit fixes
Former-commit-id:
2d4c86e2
上级
838f6afb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
112 addition
and
46 deletion
+112
-46
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
...ss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
+12
-4
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
...ss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
+33
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeBindingType.java
...org/jkiss/dbeaver/model/data/DBDAttributeBindingType.java
+10
-4
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNModel.java
...model/src/org/jkiss/dbeaver/model/navigator/DBNModel.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/ui/DBPPlatformUI.java
...model/src/org/jkiss/dbeaver/runtime/ui/DBPPlatformUI.java
+6
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/ui/console/ConsoleUserInterface.java
...kiss/dbeaver/runtime/ui/console/ConsoleUserInterface.java
+10
-1
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
...g/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
+35
-2
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/dialogs/ComplexObjectEditor.java
...rg/jkiss/dbeaver/ui/data/dialogs/ComplexObjectEditor.java
+5
-30
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
浏览文件 @
7afb4e24
...
...
@@ -35,14 +35,13 @@ import org.jkiss.dbeaver.ModelPreferences;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.DBPErrorAssistant
;
import
org.jkiss.dbeaver.model.connection.DBPAuthInfo
;
import
org.jkiss.dbeaver.model.access.DBAPasswordChangeInfo
;
import
org.jkiss.dbeaver.model.connection.DBPAuthInfo
;
import
org.jkiss.dbeaver.model.connection.DBPDriver
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.exec.DBExecUtils
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessListener
;
import
org.jkiss.dbeaver.model.runtime.*
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadService
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadVisualizer
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
...
...
@@ -66,6 +65,7 @@ import org.jkiss.dbeaver.ui.views.process.ProcessPropertyTester;
import
org.jkiss.dbeaver.ui.views.process.ShellProcessView
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -361,10 +361,18 @@ public class DBeaverUI implements DBPPlatformUI {
}
@Override
public
void
execute
InUI
(
@NotNull
Runnable
runnable
)
{
public
void
execute
WithProgress
(
@NotNull
Runnable
runnable
)
{
UIUtils
.
syncExec
(
runnable
);
}
@Override
public
void
executeWithProgress
(
@NotNull
DBRRunnableWithProgress
runnable
)
throws
InvocationTargetException
,
InterruptedException
{
// FIXME: we need to run with progress service bu we can't change active control focus
// Otherwise it breaks soem functions (e.g. data editor value save as it handles focus events).
// so we can use runInProgressServie function
runnable
.
run
(
new
VoidProgressMonitor
());
}
@NotNull
@Override
public
<
RESULT
>
Job
createLoadingService
(
ILoadService
<
RESULT
>
loadingService
,
ILoadVisualizer
<
RESULT
>
visualizer
)
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
浏览文件 @
7afb4e24
...
...
@@ -31,10 +31,8 @@ import org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer;
import
org.jkiss.dbeaver.model.impl.data.DBDValueError
;
import
org.jkiss.dbeaver.model.impl.data.DefaultValueHandler
;
import
org.jkiss.dbeaver.model.impl.sql.BasicSQLDialect
;
import
org.jkiss.dbeaver.model.navigator.DBNDataSource
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.*
;
import
org.jkiss.dbeaver.model.struct.*
;
...
...
@@ -46,6 +44,7 @@ import org.jkiss.dbeaver.utils.RuntimeUtils;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.*
;
/**
...
...
@@ -1851,4 +1850,35 @@ public final class DBUtils {
DBPDataSource
dataSource
=
object
.
getDataSource
();
return
dataSource
==
null
||
!
dataSource
.
getContainer
().
hasModifyPermission
(
DBPDataSourcePermission
.
PERMISSION_EDIT_METADATA
);
}
public
static
<
T
>
T
createNewAttributeValue
(
DBCExecutionContext
context
,
DBDValueHandler
valueHandler
,
DBSTypedObject
valueType
,
Class
<
T
>
targetType
)
throws
DBCException
{
DBRRunnableWithResult
<
Object
>
runnable
=
new
DBRRunnableWithResult
<
Object
>()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
{
try
(
DBCSession
session
=
context
.
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Create new object"
))
{
result
=
valueHandler
.
createNewValueObject
(
session
,
valueType
);
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
};
try
{
DBWorkbench
.
getPlatformUI
().
executeWithProgress
(
runnable
);
//UIUtils.runInProgressService(runnable);
}
catch
(
InvocationTargetException
e
)
{
throw
new
DBCException
(
e
.
getTargetException
(),
context
.
getDataSource
());
}
catch
(
InterruptedException
e
)
{
throw
new
DBCException
(
e
,
context
.
getDataSource
());
}
Object
result
=
runnable
.
getResult
();
if
(
result
==
null
)
{
throw
new
DBCException
(
"Internal error - null object created"
);
}
if
(!
targetType
.
isInstance
(
result
))
{
throw
new
DBCException
(
"Internal error - wrong object type '"
+
result
.
getClass
().
getName
()
+
"' while '"
+
targetType
.
getName
()
+
"' was expected"
);
}
return
targetType
.
cast
(
result
);
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeBindingType.java
浏览文件 @
7afb4e24
...
...
@@ -20,10 +20,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.utils.CommonUtils
;
/**
...
...
@@ -149,6 +146,15 @@ public class DBDAttributeBindingType extends DBDAttributeBindingNested implement
return
null
;
}
@Nullable
@Override
public
DBSDataType
getDataType
()
{
if
(
attribute
instanceof
DBSTypedObjectEx
)
{
return
((
DBSTypedObjectEx
)
attribute
).
getDataType
();
}
return
super
.
getDataType
();
}
@Nullable
@Override
public
DBPImage
getObjectImage
()
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNModel.java
浏览文件 @
7afb4e24
...
...
@@ -651,7 +651,7 @@ public class DBNModel implements IResourceChangeListener {
}
try
{
DBWorkbench
.
getPlatformUI
().
execute
InUI
(()
->
{
DBWorkbench
.
getPlatformUI
().
execute
WithProgress
(()
->
{
for
(
int
i
=
0
;
i
<
realEvents
.
length
;
i
++)
{
for
(
INavigatorListener
listener
:
listenersCopy
)
{
listener
.
nodeChanged
(
realEvents
[
i
]);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/ui/DBPPlatformUI.java
浏览文件 @
7afb4e24
...
...
@@ -28,10 +28,13 @@ import org.jkiss.dbeaver.model.connection.DBPDriver;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadService
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadVisualizer
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
java.lang.reflect.InvocationTargetException
;
/**
* User interface interactions
*/
...
...
@@ -96,7 +99,9 @@ public interface DBPPlatformUI {
void
executeProcess
(
@NotNull
DBRProcessDescriptor
processDescriptor
);
// Execute some action in UI thread
void
executeInUI
(
@NotNull
Runnable
runnable
);
void
executeWithProgress
(
@NotNull
Runnable
runnable
);
void
executeWithProgress
(
@NotNull
DBRRunnableWithProgress
runnable
)
throws
InvocationTargetException
,
InterruptedException
;
@NotNull
<
RESULT
>
Job
createLoadingService
(
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/ui/console/ConsoleUserInterface.java
浏览文件 @
7afb4e24
...
...
@@ -28,12 +28,16 @@ import org.jkiss.dbeaver.model.connection.DBPDriver;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.runtime.LoggingProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadService
;
import
org.jkiss.dbeaver.model.runtime.load.ILoadVisualizer
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.runtime.ui.DBPPlatformUI
;
import
java.lang.reflect.InvocationTargetException
;
public
class
ConsoleUserInterface
implements
DBPPlatformUI
{
@Override
public
UserResponse
showError
(
@NotNull
String
title
,
@Nullable
String
message
,
@NotNull
IStatus
status
)
{
...
...
@@ -143,10 +147,15 @@ public class ConsoleUserInterface implements DBPPlatformUI {
}
@Override
public
void
execute
InUI
(
@NotNull
Runnable
runnable
)
{
public
void
execute
WithProgress
(
@NotNull
Runnable
runnable
)
{
runnable
.
run
();
}
@Override
public
void
executeWithProgress
(
@NotNull
DBRRunnableWithProgress
runnable
)
throws
InvocationTargetException
,
InterruptedException
{
runnable
.
run
(
new
LoggingProgressMonitor
());
}
@NotNull
@Override
public
<
RESULT
>
Job
createLoadingService
(
ILoadService
<
RESULT
>
loadingService
,
ILoadVisualizer
<
RESULT
>
visualizer
)
{
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
浏览文件 @
7afb4e24
...
...
@@ -22,6 +22,7 @@ import org.eclipse.swt.graphics.Color;
import
org.eclipse.swt.graphics.RGB
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ModelPreferences
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
...
...
@@ -32,6 +33,7 @@ import org.jkiss.dbeaver.model.exec.*;
import
org.jkiss.dbeaver.model.exec.trace.DBCTrace
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.model.virtual.DBVColorOverride
;
import
org.jkiss.dbeaver.model.virtual.DBVEntity
;
...
...
@@ -354,7 +356,7 @@ public class ResultSetModel {
for
(
int
i
=
0
;
i
<
depth
;
i
++)
{
if
(
ownerValue
==
null
)
{
// Create new owner object
log
.
warn
(
"Null owner value
"
);
log
.
warn
(
"Null owner value
for '"
+
attr
.
getName
()
+
"', row "
+
row
.
getVisualNumber
()
);
return
false
;
}
if
(
i
==
depth
-
1
)
{
...
...
@@ -363,7 +365,32 @@ public class ResultSetModel {
DBDAttributeBinding
ownerAttr
=
attr
.
getParent
(
depth
-
i
-
1
);
assert
ownerAttr
!=
null
;
try
{
ownerValue
=
ownerAttr
.
extractNestedValue
(
ownerValue
);
Object
nestedValue
=
ownerAttr
.
extractNestedValue
(
ownerValue
);
if
(
nestedValue
==
null
)
{
// Try to create nested value
DBCExecutionContext
context
=
DBUtils
.
getDefaultContext
(
ownerAttr
,
false
);
nestedValue
=
DBUtils
.
createNewAttributeValue
(
context
,
ownerAttr
.
getValueHandler
(),
ownerAttr
.
getAttribute
(),
DBDComplexValue
.
class
);
if
(
ownerValue
instanceof
DBDComposite
)
{
((
DBDComposite
)
ownerValue
).
setAttributeValue
(
ownerAttr
,
nestedValue
);
}
if
(
ownerAttr
.
getDataKind
()
==
DBPDataKind
.
ARRAY
)
{
// That's a tough case. Collection of elements. We need to create first element in this collection
if
(
nestedValue
instanceof
DBDCollection
)
{
Object
elemValue
=
null
;
try
{
DBSDataType
componentType
=
((
DBDCollection
)
nestedValue
).
getComponentType
();
DBDValueHandler
elemValueHandler
=
DBUtils
.
findValueHandler
(
context
.
getDataSource
(),
componentType
);
elemValue
=
DBUtils
.
createNewAttributeValue
(
context
,
elemValueHandler
,
componentType
,
DBDComplexValue
.
class
);
}
catch
(
DBException
e
)
{
log
.
warn
(
"Error while getting component type name"
,
e
);
}
((
DBDCollection
)
nestedValue
).
setContents
(
new
Object
[]
{
elemValue
}
);
}
else
{
log
.
warn
(
"Attribute '"
+
ownerAttr
.
getName
()
+
"' has collection type but attribute value is not a collection: "
+
nestedValue
);
}
}
}
ownerValue
=
nestedValue
;
}
catch
(
DBCException
e
)
{
log
.
warn
(
"Error getting field ["
+
ownerAttr
.
getName
()
+
"] value"
,
e
);
return
false
;
...
...
@@ -387,6 +414,12 @@ public class ResultSetModel {
}
// Check composite type
if
(
ownerValue
!=
null
)
{
if
(
ownerValue
instanceof
DBDCollection
)
{
DBDCollection
collection
=
(
DBDCollection
)
ownerValue
;
if
(
collection
.
getItemCount
()
>
0
)
{
ownerValue
=
collection
.
getItem
(
0
);
}
}
if
(!(
ownerValue
instanceof
DBDComposite
))
{
log
.
warn
(
"Value ["
+
ownerValue
+
"] edit is not supported"
);
return
false
;
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/dialogs/ComplexObjectEditor.java
浏览文件 @
7afb4e24
...
...
@@ -802,7 +802,11 @@ public class ComplexObjectEditor extends TreeViewer {
ComplexElement
[]
arrayItems
=
childrenMap
.
get
(
collection
);
if
(
collection
==
null
)
{
try
{
collection
=
createNewObject
(
DBDCollection
.
class
);
collection
=
DBUtils
.
createNewAttributeValue
(
parentController
.
getExecutionContext
(),
parentController
.
getValueHandler
(),
parentController
.
getValueType
(),
DBDCollection
.
class
);
setInput
(
collection
);
}
catch
(
DBCException
e
)
{
DBWorkbench
.
getPlatformUI
().
showError
(
"New object create"
,
"Error creating new collection"
,
e
);
...
...
@@ -836,35 +840,6 @@ public class ComplexObjectEditor extends TreeViewer {
autoUpdateComplexValue
();
}
private
<
T
>
T
createNewObject
(
Class
<
T
>
targetType
)
throws
DBCException
{
DBRRunnableWithResult
<
Object
>
runnable
=
new
DBRRunnableWithResult
<
Object
>()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
{
try
(
DBCSession
session
=
executionContext
.
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Create new object"
))
{
result
=
parentController
.
getValueHandler
().
createNewValueObject
(
session
,
parentController
.
getValueType
());
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
};
try
{
UIUtils
.
runInProgressService
(
runnable
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
DBCException
(
e
.
getTargetException
(),
executionContext
.
getDataSource
());
}
catch
(
InterruptedException
e
)
{
throw
new
DBCException
(
e
,
executionContext
.
getDataSource
());
}
Object
result
=
runnable
.
getResult
();
if
(
result
==
null
)
{
throw
new
DBCException
(
"Internal error - null object created"
);
}
if
(!
targetType
.
isInstance
(
result
))
{
throw
new
DBCException
(
"Internal error - wrong object type '"
+
result
.
getClass
().
getName
()
+
"' while '"
+
targetType
.
getName
()
+
"' was expected"
);
}
return
targetType
.
cast
(
result
);
}
}
private
class
RemoveElementAction
extends
Action
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录