Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
e35cca24
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,发现更多精彩内容 >>
提交
e35cca24
编写于
6月 30, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3691 Invalidate connection in GoToObject dialog
Former-commit-id:
ff461566
上级
ea9b4fd8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
47 deletion
+61
-47
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/GotoObjectDialog.java
...re/src/org/jkiss/dbeaver/ui/dialogs/GotoObjectDialog.java
+61
-47
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/GotoObjectDialog.java
浏览文件 @
e35cca24
...
...
@@ -37,6 +37,7 @@ import org.jkiss.dbeaver.model.DBPNamedObject;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableParametrized
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
...
...
@@ -45,6 +46,7 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
...
...
@@ -61,8 +63,7 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
private
final
DBCExecutionContext
context
;
private
DBSObject
container
;
public
GotoObjectDialog
(
Shell
shell
,
DBCExecutionContext
context
,
DBSObject
container
)
{
public
GotoObjectDialog
(
Shell
shell
,
DBCExecutionContext
context
,
DBSObject
container
)
{
super
(
shell
,
true
);
this
.
context
=
context
;
this
.
container
=
container
;
...
...
@@ -73,36 +74,30 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
@Override
protected
Control
createExtendedContentArea
(
Composite
parent
)
{
protected
Control
createExtendedContentArea
(
Composite
parent
)
{
return
null
;
}
@Override
protected
IDialogSettings
getDialogSettings
()
{
protected
IDialogSettings
getDialogSettings
()
{
return
UIUtils
.
getDialogSettings
(
DIALOG_ID
);
}
@Override
protected
IStatus
validateItem
(
Object
item
)
{
protected
IStatus
validateItem
(
Object
item
)
{
return
Status
.
OK_STATUS
;
}
@Override
protected
ItemsFilter
createFilter
()
{
protected
ItemsFilter
createFilter
()
{
return
new
ObjectFilter
();
}
@Override
protected
Comparator
getItemsComparator
()
{
protected
Comparator
getItemsComparator
()
{
return
new
Comparator
()
{
@Override
public
int
compare
(
Object
o1
,
Object
o2
)
{
public
int
compare
(
Object
o1
,
Object
o2
)
{
if
(
o1
instanceof
DBPNamedObject
&&
o2
instanceof
DBPNamedObject
)
{
return
DBUtils
.
getObjectFullName
((
DBPNamedObject
)
o1
,
DBPEvaluationContext
.
UI
).
compareToIgnoreCase
(
DBUtils
.
getObjectFullName
((
DBPNamedObject
)
o2
,
DBPEvaluationContext
.
UI
));
...
...
@@ -114,13 +109,12 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
@Override
protected
void
fillContentProvider
(
AbstractContentProvider
contentProvider
,
ItemsFilter
itemsFilter
,
IProgressMonitor
progressMonitor
)
throws
CoreException
{
throws
CoreException
{
DBSStructureAssistant
structureAssistant
=
DBUtils
.
getAdapter
(
DBSStructureAssistant
.
class
,
context
.
getDataSource
());
if
(
structureAssistant
==
null
)
{
return
;
}
String
nameMask
=
((
ObjectFilter
)
itemsFilter
).
getNameMask
();
String
nameMask
=
((
ObjectFilter
)
itemsFilter
).
getNameMask
();
DBRProgressMonitor
monitor
=
RuntimeUtils
.
makeMonitor
(
progressMonitor
);
try
{
monitor
.
beginTask
(
"Search for '"
+
nameMask
+
"'"
,
100
);
...
...
@@ -133,17 +127,12 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
typesToSearch
.
add
(
type
);
}
Collection
<
DBSObjectReference
>
result
=
structureAssistant
.
findObjectsByMask
(
monitor
,
container
,
typesToSearch
.
toArray
(
new
DBSObjectType
[
typesToSearch
.
size
()]),
nameMask
,
false
,
true
,
1000
);
ObjectFinder
objectFinder
=
new
ObjectFinder
(
structureAssistant
,
monitor
,
typesToSearch
,
nameMask
);
DBUtils
.
tryExecuteRecover
(
monitor
,
container
.
getDataSource
(),
objectFinder
);
DBPDataSourceContainer
dsContainer
=
context
.
getDataSource
().
getContainer
();
for
(
DBSObjectReference
ref
:
result
)
{
for
(
DBSObjectReference
ref
:
objectFinder
.
getResult
()
)
{
DBSObjectFilter
filter
=
dsContainer
.
getObjectFilter
(
ref
.
getObjectClass
(),
ref
.
getContainer
(),
true
);
if
(
filter
==
null
||
!
filter
.
isEnabled
()
||
filter
.
matches
(
ref
.
getName
()))
{
contentProvider
.
add
(
ref
,
itemsFilter
);
...
...
@@ -151,15 +140,13 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
}
catch
(
DBException
e
)
{
throw
new
CoreException
(
GeneralUtils
.
makeExceptionStatus
(
e
));
}
finally
{
}
finally
{
monitor
.
done
();
}
}
@Override
public
String
getElementName
(
Object
item
)
{
public
String
getElementName
(
Object
item
)
{
if
(
item
instanceof
DBPNamedObject
)
{
return
DBUtils
.
getObjectFullName
((
DBPNamedObject
)
item
,
DBPEvaluationContext
.
UI
);
}
...
...
@@ -183,8 +170,7 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
@Override
public
Image
getImage
(
Object
element
)
{
public
Image
getImage
(
Object
element
)
{
if
(
element
instanceof
DBSObjectReference
)
{
DBSObjectType
objectType
=
((
DBSObjectReference
)
element
).
getObjectType
();
if
(
objectType
!=
null
)
{
...
...
@@ -195,10 +181,9 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
@Override
public
String
getText
(
Object
element
)
{
public
String
getText
(
Object
element
)
{
if
(
element
instanceof
DBPNamedObject
)
{
return
((
DBPNamedObject
)
element
).
getName
();
return
((
DBPNamedObject
)
element
).
getName
();
}
return
null
;
}
...
...
@@ -206,8 +191,7 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
private
static
class
DetailsLabelProvider
extends
ObjectLabelProvider
{
@Override
public
String
getText
(
Object
element
)
{
public
String
getText
(
Object
element
)
{
if
(
element
instanceof
DBPNamedObject
)
{
return
DBUtils
.
getObjectFullName
((
DBPNamedObject
)
element
,
DBPEvaluationContext
.
UI
);
}
...
...
@@ -218,15 +202,14 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
private
class
ObjectFilter
extends
ItemsFilter
{
private
Pattern
namePattern
=
null
;
@Override
public
int
getMatchRule
()
{
public
int
getMatchRule
()
{
return
SearchPattern
.
RULE_PATTERN_MATCH
|
SearchPattern
.
RULE_PREFIX_MATCH
;
}
@Override
public
boolean
matchItem
(
Object
item
)
{
public
boolean
matchItem
(
Object
item
)
{
if
(
item
instanceof
DBPNamedObject
)
{
String
objectName
=
((
DBPNamedObject
)
item
).
getName
();
if
(!
getNamePattern
().
matcher
(
objectName
).
matches
())
{
...
...
@@ -241,13 +224,11 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
@Override
public
boolean
isConsistentItem
(
Object
item
)
{
public
boolean
isConsistentItem
(
Object
item
)
{
return
false
;
}
public
String
getNameMask
()
{
public
String
getNameMask
()
{
String
nameMask
=
getPattern
();
nameMask
=
nameMask
.
replace
(
"*"
,
"%"
).
replace
(
"?"
,
"_"
);
int
matchRule
=
getMatchRule
();
...
...
@@ -257,8 +238,7 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
return
nameMask
;
}
private
Pattern
getNamePattern
()
{
private
Pattern
getNamePattern
()
{
if
(
namePattern
==
null
)
{
namePattern
=
Pattern
.
compile
(
SQLUtils
.
makeLikePattern
(
getNameMask
()),
Pattern
.
CASE_INSENSITIVE
|
Pattern
.
MULTILINE
);
...
...
@@ -268,4 +248,38 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
private
class
ObjectFinder
implements
DBRRunnableParametrized
<
DBRProgressMonitor
>
{
private
final
DBSStructureAssistant
structureAssistant
;
private
final
DBRProgressMonitor
monitor
;
private
final
List
<
DBSObjectType
>
typesToSearch
;
private
final
String
nameMask
;
private
List
<
DBSObjectReference
>
result
;
public
ObjectFinder
(
DBSStructureAssistant
structureAssistant
,
DBRProgressMonitor
monitor
,
List
<
DBSObjectType
>
typesToSearch
,
String
nameMask
)
{
this
.
structureAssistant
=
structureAssistant
;
this
.
monitor
=
monitor
;
this
.
typesToSearch
=
typesToSearch
;
this
.
nameMask
=
nameMask
;
}
public
List
<
DBSObjectReference
>
getResult
()
{
return
result
;
}
@Override
public
void
run
(
DBRProgressMonitor
param
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
result
=
structureAssistant
.
findObjectsByMask
(
monitor
,
container
,
typesToSearch
.
toArray
(
new
DBSObjectType
[
typesToSearch
.
size
()]),
nameMask
,
false
,
true
,
1000
);
}
catch
(
Exception
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录