Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
8f500011
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,发现更多精彩内容 >>
提交
8f500011
编写于
6月 06, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Search objects model
Former-commit-id:
1fae213a
上级
79e49981
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
431 addition
and
0 deletion
+431
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchContainer.java
...c/org/jkiss/dbeaver/ui/search/IObjectSearchContainer.java
+28
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchListener.java
...rc/org/jkiss/dbeaver/ui/search/IObjectSearchListener.java
+34
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchPage.java
...re/src/org/jkiss/dbeaver/ui/search/IObjectSearchPage.java
+32
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchQuery.java
...e/src/org/jkiss/dbeaver/ui/search/IObjectSearchQuery.java
+33
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchResultPage.java
.../org/jkiss/dbeaver/ui/search/IObjectSearchResultPage.java
+29
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsPage.java
...dbeaver/ui/search/database/SearchDatabaseObjectsPage.java
+51
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsParams.java
...eaver/ui/search/database/SearchDatabaseObjectsParams.java
+101
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsQuery.java
...beaver/ui/search/database/SearchDatabaseObjectsQuery.java
+123
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchContainer.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search
;
/**
* Search container
*/
public
interface
IObjectSearchContainer
{
void
setSearchEnabled
(
boolean
enabled
);
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchListener.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search
;
import
java.util.Collection
;
/**
* Search listener
*/
public
interface
IObjectSearchListener
{
void
searchStarted
();
void
objectsFound
(
Collection
<?>
objects
);
void
searchFinished
();
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchPage.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search
;
import
org.eclipse.ui.part.IPage
;
/**
* Search page
*/
public
interface
IObjectSearchPage
extends
IPage
{
void
setSearchContainer
(
IObjectSearchContainer
container
);
IObjectSearchQuery
createQuery
();
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchQuery.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.lang.reflect.InvocationTargetException
;
/**
* Search query
*/
public
interface
IObjectSearchQuery
{
public
void
runQuery
(
DBRProgressMonitor
monitor
,
IObjectSearchListener
listener
)
throws
InvocationTargetException
,
InterruptedException
;
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/IObjectSearchResultPage.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search
;
import
org.eclipse.ui.part.IPage
;
/**
* Search results page
*/
public
interface
IObjectSearchResultPage
extends
IPage
{
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsPage.java
浏览文件 @
8f500011
...
...
@@ -32,6 +32,7 @@ import org.eclipse.swt.events.SelectionEvent;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
...
...
@@ -348,4 +349,54 @@ public class SearchDatabaseObjectsPage extends DialogPage {
}
}
public
SearchDatabaseObjectsQuery
createQuery
()
throws
DBException
{
DBNNode
selectedNode
=
getSelectedNode
();
DBSObjectContainer
parentObject
=
null
;
if
(
selectedNode
instanceof
DBSWrapper
&&
((
DBSWrapper
)
selectedNode
).
getObject
()
instanceof
DBSObjectContainer
)
{
parentObject
=
(
DBSObjectContainer
)
((
DBSWrapper
)
selectedNode
).
getObject
();
}
DBPDataSource
dataSource
=
getSelectedDataSource
();
DBSStructureAssistant
assistant
=
getSelectedStructureAssistant
();
if
(
dataSource
==
null
||
assistant
==
null
)
{
throw
new
IllegalStateException
(
"No active datasource"
);
}
java
.
util
.
List
<
DBSObjectType
>
objectTypes
=
new
ArrayList
<
DBSObjectType
>();
for
(
TableItem
item
:
typesTable
.
getItems
())
{
if
(
item
.
getChecked
())
{
objectTypes
.
add
((
DBSObjectType
)
item
.
getData
());
}
}
String
objectNameMask
=
nameMask
;
// Save search query
if
(!
searchHistory
.
contains
(
objectNameMask
))
{
searchHistory
.
add
(
objectNameMask
);
searchText
.
add
(
objectNameMask
);
}
if
(
matchTypeIndex
==
SearchDatabaseConstants
.
MATCH_INDEX_STARTS_WITH
)
{
if
(!
objectNameMask
.
endsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
objectNameMask
+
"%"
;
//$NON-NLS-1$
}
}
else
if
(
matchTypeIndex
==
SearchDatabaseConstants
.
MATCH_INDEX_CONTAINS
)
{
if
(!
objectNameMask
.
startsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
"%"
+
objectNameMask
;
//$NON-NLS-1$
}
if
(!
objectNameMask
.
endsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
objectNameMask
+
"%"
;
//$NON-NLS-1$
}
}
SearchDatabaseObjectsParams
params
=
new
SearchDatabaseObjectsParams
();
params
.
setParentObject
(
parentObject
);
params
.
setObjectTypes
(
objectTypes
);
params
.
setObjectNameMask
(
objectNameMask
);
params
.
setCaseSensitive
(
caseSensitive
);
params
.
setMaxResults
(
maxResults
);
return
SearchDatabaseObjectsQuery
.
createQuery
(
dataSource
,
params
);
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsParams.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search.database
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSObjectType
;
import
java.util.List
;
/**
* Search parameters
*/
public
class
SearchDatabaseObjectsParams
{
private
DBSObject
parentObject
;
private
List
<
DBSObjectType
>
objectTypes
;
private
String
objectNameMask
;
private
boolean
caseSensitive
;
private
int
maxResults
;
private
int
matchType
;
public
SearchDatabaseObjectsParams
()
{
}
public
DBSObject
getParentObject
()
{
return
parentObject
;
}
public
void
setParentObject
(
DBSObject
parentObject
)
{
this
.
parentObject
=
parentObject
;
}
public
List
<
DBSObjectType
>
getObjectTypes
()
{
return
objectTypes
;
}
public
void
setObjectTypes
(
List
<
DBSObjectType
>
objectTypes
)
{
this
.
objectTypes
=
objectTypes
;
}
public
String
getObjectNameMask
()
{
return
objectNameMask
;
}
public
void
setObjectNameMask
(
String
objectNameMask
)
{
this
.
objectNameMask
=
objectNameMask
;
}
public
boolean
isCaseSensitive
()
{
return
caseSensitive
;
}
public
void
setCaseSensitive
(
boolean
caseSensitive
)
{
this
.
caseSensitive
=
caseSensitive
;
}
public
int
getMaxResults
()
{
return
maxResults
;
}
public
void
setMaxResults
(
int
maxResults
)
{
this
.
maxResults
=
maxResults
;
}
public
int
getMatchType
()
{
return
matchType
;
}
public
void
setMatchType
(
int
matchType
)
{
this
.
matchType
=
matchType
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/search/database/SearchDatabaseObjectsQuery.java
0 → 100644
浏览文件 @
8f500011
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.search.database
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.navigator.DBNModel
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSObjectReference
;
import
org.jkiss.dbeaver.model.struct.DBSObjectType
;
import
org.jkiss.dbeaver.model.struct.DBSStructureAssistant
;
import
org.jkiss.dbeaver.ui.search.IObjectSearchListener
;
import
org.jkiss.dbeaver.ui.search.IObjectSearchQuery
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
public
class
SearchDatabaseObjectsQuery
implements
IObjectSearchQuery
{
static
final
Log
log
=
LogFactory
.
getLog
(
SearchDatabaseObjectsDialog
.
class
);
private
final
DBSStructureAssistant
structureAssistant
;
private
final
SearchDatabaseObjectsParams
params
;
private
SearchDatabaseObjectsQuery
(
DBSStructureAssistant
structureAssistant
,
SearchDatabaseObjectsParams
params
)
{
this
.
structureAssistant
=
structureAssistant
;
this
.
params
=
params
;
}
@Override
public
void
runQuery
(
DBRProgressMonitor
monitor
,
IObjectSearchListener
listener
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
List
<
DBSObjectType
>
objectTypes
=
params
.
getObjectTypes
();
String
objectNameMask
=
params
.
getObjectNameMask
();
if
(
params
.
getMatchType
()
==
SearchDatabaseConstants
.
MATCH_INDEX_STARTS_WITH
)
{
if
(!
objectNameMask
.
endsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
objectNameMask
+
"%"
;
//$NON-NLS-1$
}
}
else
if
(
params
.
getMatchType
()
==
SearchDatabaseConstants
.
MATCH_INDEX_CONTAINS
)
{
if
(!
objectNameMask
.
startsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
"%"
+
objectNameMask
;
//$NON-NLS-1$
}
if
(!
objectNameMask
.
endsWith
(
"%"
))
{
//$NON-NLS-1$
objectNameMask
=
objectNameMask
+
"%"
;
//$NON-NLS-1$
}
}
DBNModel
navigatorModel
=
DBeaverCore
.
getInstance
().
getNavigatorModel
();
Collection
<
DBSObjectReference
>
objects
=
structureAssistant
.
findObjectsByMask
(
monitor
,
params
.
getParentObject
(),
objectTypes
.
toArray
(
new
DBSObjectType
[
objectTypes
.
size
()]),
objectNameMask
,
params
.
isCaseSensitive
(),
params
.
getMaxResults
());
for
(
DBSObjectReference
reference
:
objects
)
{
try
{
DBSObject
object
=
reference
.
resolveObject
(
monitor
);
if
(
object
!=
null
)
{
DBNNode
node
=
navigatorModel
.
getNodeByObject
(
monitor
,
object
,
true
);
if
(
node
!=
null
)
{
listener
.
objectsFound
(
Collections
.
singleton
(
node
));
}
}
}
catch
(
DBException
e
)
{
log
.
error
(
e
);
}
}
}
catch
(
Throwable
ex
)
{
if
(
ex
instanceof
InvocationTargetException
)
{
throw
(
InvocationTargetException
)
ex
;
}
else
{
throw
new
InvocationTargetException
(
ex
);
}
}
}
public
static
SearchDatabaseObjectsQuery
createQuery
(
DBPDataSource
dataSource
,
SearchDatabaseObjectsParams
params
)
throws
DBException
{
DBSStructureAssistant
assistant
=
DBUtils
.
getAdapter
(
DBSStructureAssistant
.
class
,
dataSource
);
if
(
dataSource
==
null
||
assistant
==
null
)
{
throw
new
DBException
(
"Can't obtain database structure assistance from ["
+
dataSource
+
"]"
);
}
return
new
SearchDatabaseObjectsQuery
(
assistant
,
params
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录