Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
5c9be6aa
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
5c9be6aa
编写于
10月 05, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6489 Navigator tree meta reading performance improvements
Former-commit-id:
adfe75cc
上级
ba0c5a03
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
91 addition
and
57 deletion
+91
-57
plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml
plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNDatabaseNode.java
...rc/org/jkiss/dbeaver/model/navigator/DBNDatabaseNode.java
+11
-38
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/meta/DBXTreeItem.java
...c/org/jkiss/dbeaver/model/navigator/meta/DBXTreeItem.java
+59
-2
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
...rc/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
+1
-4
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
...ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
+19
-12
未找到文件。
plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml
浏览文件 @
5c9be6aa
...
...
@@ -95,7 +95,7 @@
</extension>
<extension
point=
"org.eclipse.ui.menus"
>
<menuContribution
allPopups=
"false"
locationURI=
"popup:org.eclipse.ui.popup.any?after=
additions
"
>
<menuContribution
allPopups=
"false"
locationURI=
"popup:org.eclipse.ui.popup.any?after=
navigator_additions_end
"
>
<command
commandId=
"org.jkiss.dbeaver.ext.oracle.code.compile"
>
<visibleWhen
checkEnabled=
"true"
/>
</command>
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/DBNDatabaseNode.java
浏览文件 @
5c9be6aa
...
...
@@ -41,7 +41,6 @@ import org.jkiss.utils.CommonUtils;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Type
;
import
java.util.*
;
...
...
@@ -480,15 +479,14 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
if
(
valueObject
==
null
)
{
return
false
;
}
final
String
propertyName
=
meta
.
getPropertyName
();
final
PropertyValueReader
valueReader
=
new
PropertyValueReader
(
monitor
,
propertyName
,
valueObject
);
final
PropertyValueReader
valueReader
=
new
PropertyValueReader
(
monitor
,
meta
,
valueObject
);
DBExecUtils
.
tryExecuteRecover
(
monitor
,
getDataSource
(),
valueReader
);
final
Object
propertyValue
=
valueReader
.
propertyValue
;
if
(
propertyValue
==
null
)
{
return
false
;
}
if
(!(
propertyValue
instanceof
Collection
<?>))
{
log
.
warn
(
"Bad property '"
+
propertyName
+
"' value: "
+
propertyValue
.
getClass
().
getName
());
//$NON-NLS-1$ //$NON-NLS-2$
log
.
warn
(
"Bad property '"
+
meta
.
getPropertyName
()
+
"' value: "
+
propertyValue
.
getClass
().
getName
());
//$NON-NLS-1$ //$NON-NLS-2$
return
false
;
}
...
...
@@ -776,8 +774,7 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
if
(
valueObject
==
null
)
{
return
null
;
}
String
propertyName
=
childMeta
.
getPropertyName
();
Method
getter
=
findPropertyReadMethod
(
valueObject
.
getClass
(),
propertyName
);
Method
getter
=
childMeta
.
getPropertyReadMethod
(
valueObject
.
getClass
());
if
(
getter
==
null
)
{
return
null
;
}
...
...
@@ -796,14 +793,15 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
////////////////////////////////////////////////////////////////////////////////////
// Reflection utils
private
static
Object
extractPropertyValue
(
DBRProgressMonitor
monitor
,
Object
object
,
String
propertyName
)
private
static
Object
extractPropertyValue
(
DBRProgressMonitor
monitor
,
Object
object
,
DBXTreeItem
meta
)
throws
DBException
{
// Read property using reflection
if
(
object
==
null
)
{
if
(
object
==
null
||
meta
==
null
)
{
return
null
;
}
String
propertyName
=
meta
.
getPropertyName
();
try
{
Method
getter
=
findPropertyReadMethod
(
object
.
getClass
(),
propertyName
);
Method
getter
=
meta
.
getPropertyReadMethod
(
object
.
getClass
()
);
if
(
getter
==
null
)
{
log
.
warn
(
"Can't find property '"
+
propertyName
+
"' read method in '"
+
object
.
getClass
().
getName
()
+
"'"
);
return
null
;
...
...
@@ -830,47 +828,22 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
}
}
private
static
Method
findPropertyReadMethod
(
Class
<?>
clazz
,
String
propertyName
)
{
String
methodName
=
BeanUtils
.
propertyNameToMethodName
(
propertyName
);
return
findPropertyGetter
(
clazz
,
"get"
+
methodName
,
"is"
+
methodName
);
}
private
static
Method
findPropertyGetter
(
Class
<?>
clazz
,
String
getName
,
String
isName
)
{
Method
[]
methods
=
clazz
.
getDeclaredMethods
();
for
(
Method
method
:
methods
)
{
if
((!
Modifier
.
isPublic
(
method
.
getModifiers
()))
||
(!
Modifier
.
isPublic
(
method
.
getDeclaringClass
().
getModifiers
()))
||
(
method
.
getReturnType
().
equals
(
void
.
class
)))
{
// skip
}
else
if
(
method
.
getName
().
equals
(
getName
)
||
(
method
.
getName
().
equals
(
isName
)
&&
method
.
getReturnType
().
equals
(
boolean
.
class
)))
{
// If it matches the get name, it's the right method
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
if
(
parameterTypes
.
length
==
0
||
(
parameterTypes
.
length
==
1
&&
parameterTypes
[
0
]
==
DBRProgressMonitor
.
class
))
{
return
method
;
}
}
}
return
clazz
==
Object
.
class
?
null
:
findPropertyGetter
(
clazz
.
getSuperclass
(),
getName
,
isName
);
}
private
static
class
PropertyValueReader
implements
DBRRunnableParametrized
<
DBRProgressMonitor
>
{
private
final
DBRProgressMonitor
monitor
;
private
final
String
propertyName
;
private
final
DBXTreeItem
meta
;
private
final
Object
valueObject
;
private
Object
propertyValue
;
PropertyValueReader
(
DBRProgressMonitor
monitor
,
String
propertyName
,
Object
valueObject
)
{
PropertyValueReader
(
DBRProgressMonitor
monitor
,
DBXTreeItem
meta
,
Object
valueObject
)
{
this
.
monitor
=
monitor
;
this
.
propertyName
=
propertyName
;
this
.
meta
=
meta
;
this
.
valueObject
=
valueObject
;
}
@Override
public
void
run
(
DBRProgressMonitor
param
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
propertyValue
=
extractPropertyValue
(
monitor
,
valueObject
,
propertyName
);
propertyValue
=
extractPropertyValue
(
monitor
,
valueObject
,
meta
);
}
catch
(
DBException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/navigator/meta/DBXTreeItem.java
浏览文件 @
5c9be6aa
...
...
@@ -17,14 +17,20 @@
package
org.jkiss.dbeaver.model.navigator.meta
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPTermProvider
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPTermProvider
;
import
org.jkiss.dbeaver.model.impl.AbstractDescriptor
;
import
org.jkiss.dbeaver.model.messages.ModelMessages
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.utils.BeanUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.util.IdentityHashMap
;
import
java.util.Map
;
/**
* DBXTreeItem
*/
...
...
@@ -36,6 +42,20 @@ public class DBXTreeItem extends DBXTreeNode
private
String
propertyName
;
private
boolean
optional
;
private
Map
<
Class
<?>,
Method
>
propertyGettersCache
=
new
IdentityHashMap
<>();
private
static
final
Method
NULL_GETTER
;
static
{
Method
dummyMethod
;
try
{
dummyMethod
=
Object
.
class
.
getMethod
(
"hashCode"
);
}
catch
(
NoSuchMethodException
e
)
{
dummyMethod
=
null
;
}
NULL_GETTER
=
dummyMethod
;
}
public
DBXTreeItem
(
AbstractDescriptor
source
,
DBXTreeNode
parent
,
...
...
@@ -146,4 +166,41 @@ public class DBXTreeItem extends DBXTreeNode
return
"Item "
+
label
;
}
public
synchronized
Method
getPropertyReadMethod
(
Class
<?>
objectClass
)
{
Method
getter
=
propertyGettersCache
.
get
(
objectClass
);
if
(
getter
==
null
)
{
getter
=
findPropertyReadMethod
(
objectClass
,
propertyName
);
if
(
getter
==
null
)
{
getter
=
NULL_GETTER
;
}
propertyGettersCache
.
put
(
objectClass
,
getter
);
}
return
getter
==
NULL_GETTER
?
null
:
getter
;
}
private
static
Method
findPropertyReadMethod
(
Class
<?>
clazz
,
String
propertyName
)
{
String
methodName
=
BeanUtils
.
propertyNameToMethodName
(
propertyName
);
return
findPropertyGetter
(
clazz
,
"get"
+
methodName
,
"is"
+
methodName
);
}
private
static
Method
findPropertyGetter
(
Class
<?>
clazz
,
String
getName
,
String
isName
)
{
Method
[]
methods
=
clazz
.
getDeclaredMethods
();
for
(
Method
method
:
methods
)
{
if
((!
Modifier
.
isPublic
(
method
.
getModifiers
()))
||
(!
Modifier
.
isPublic
(
method
.
getDeclaringClass
().
getModifiers
()))
||
(
method
.
getReturnType
().
equals
(
void
.
class
)))
{
// skip
}
else
if
(
method
.
getName
().
equals
(
getName
)
||
(
method
.
getName
().
equals
(
isName
)
&&
method
.
getReturnType
().
equals
(
boolean
.
class
)))
{
// If it matches the get name, it's the right method
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
if
(
parameterTypes
.
length
==
0
||
(
parameterTypes
.
length
==
1
&&
parameterTypes
[
0
]
==
DBRProgressMonitor
.
class
))
{
return
method
;
}
}
}
return
clazz
==
Object
.
class
?
null
:
findPropertyGetter
(
clazz
.
getSuperclass
(),
getName
,
isName
);
}
}
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/ObjectPropertyTester.java
浏览文件 @
5c9be6aa
...
...
@@ -264,10 +264,7 @@ public class ObjectPropertyTester extends PropertyTester
if
(
objectMaker
==
null
)
{
return
false
;
}
if
(!
objectMaker
.
canCreateObject
(
container
.
getValueObject
()))
{
return
false
;
}
return
true
;
return
objectMaker
.
canCreateObject
(
container
.
getValueObject
());
}
if
(
DBNUtils
.
isReadOnly
(
node
))
{
return
false
;
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectCreateNew.java
浏览文件 @
5c9be6aa
...
...
@@ -20,7 +20,6 @@ import org.eclipse.core.commands.ExecutionEvent;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.core.resources.IFolder
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.jface.action.ActionContributionItem
;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.viewers.ISelection
;
...
...
@@ -49,7 +48,10 @@ import org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem;
import
org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.*
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.internal.UINavigatorMessages
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorCommands
;
import
org.jkiss.dbeaver.ui.navigator.NavigatorUtils
;
...
...
@@ -69,6 +71,7 @@ import java.util.Map;
public
class
NavigatorHandlerObjectCreateNew
extends
NavigatorHandlerObjectCreateBase
implements
IElementUpdater
{
private
static
final
Log
log
=
Log
.
getLog
(
NavigatorHandlerObjectCreateNew
.
class
);
public
static
final
Separator
DUMMY_CONTRIBUTION_ITEM
=
new
Separator
();
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
...
...
@@ -212,17 +215,20 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
}
}
else
{
Class
<?>
nodeItemClass
=
node
.
getObject
().
getClass
();
DBPImage
nodeIcon
=
node
.
getNodeIconDefault
();
if
(
node
instanceof
DBNDataSource
)
{
nodeIcon
=
UIIcon
.
SQL_NEW_CONNECTION
;
}
DBNNode
parentNode
=
node
.
getParentNode
();
if
(
isCreateSupported
(
node
.
getParentNode
()
instanceof
DBNDatabaseNode
?
(
DBNDatabaseNode
)
node
.
getParentNode
()
:
null
,
parentNode
instanceof
DBNDatabaseNode
?
(
DBNDatabaseNode
)
parentNode
:
null
,
nodeItemClass
))
{
createActions
.
add
(
makeCreateContributionItem
(
site
,
nodeItemClass
.
getName
(),
node
.
getNodeType
(),
nodeIcon
,
false
));
if
(
site
==
null
)
{
createActions
.
add
(
DUMMY_CONTRIBUTION_ITEM
);
}
else
{
DBPImage
nodeIcon
=
node
instanceof
DBNDataSource
?
UIIcon
.
SQL_NEW_CONNECTION
:
node
.
getNodeIconDefault
();
createActions
.
add
(
makeCreateContributionItem
(
site
,
nodeItemClass
.
getName
(),
node
.
getNodeType
(),
nodeIcon
,
false
));
}
}
if
(!
node
.
getDataSourceContainer
().
hasModifyPermission
(
DBPDataSourcePermission
.
PERMISSION_EDIT_METADATA
))
{
...
...
@@ -281,7 +287,8 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
private
static
IContributionItem
makeCommandContributionItem
(
@Nullable
IWorkbenchPartSite
site
,
String
commandId
)
{
if
(
site
==
null
)
{
return
new
ActionContributionItem
(
new
EmptyAction
(
commandId
));
// Dummy item. We need only count
return
DUMMY_CONTRIBUTION_ITEM
;
}
else
{
return
ActionUtils
.
makeCommandContribution
(
site
,
commandId
);
}
...
...
@@ -291,7 +298,7 @@ public class NavigatorHandlerObjectCreateNew extends NavigatorHandlerObjectCreat
@Nullable
IWorkbenchPartSite
site
,
String
objectType
,
String
objectTypeName
,
DBPImage
objectIcon
,
boolean
isFolder
)
{
if
(
site
==
null
)
{
return
new
ActionContributionItem
(
new
EmptyAction
(
objectType
))
;
return
DUMMY_CONTRIBUTION_ITEM
;
}
CommandContributionItemParameter
params
=
new
CommandContributionItemParameter
(
site
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录