Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
ce3c6710
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,发现更多精彩内容 >>
提交
ce3c6710
编写于
5月 08, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Query manager log filtering menu
上级
4b92e7d3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
98 addition
and
27 deletion
+98
-27
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
...rg/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
+62
-8
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/exec/DBCExecutionPurpose.java
...src/org/jkiss/dbeaver/model/exec/DBCExecutionPurpose.java
+17
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
...model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
+9
-8
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMObjectType.java
...er.model/src/org/jkiss/dbeaver/model/qm/QMObjectType.java
+10
-4
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
浏览文件 @
ce3c6710
...
...
@@ -18,10 +18,7 @@ package org.jkiss.dbeaver.ui.controls.querylog;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.action.*
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.resource.ColorRegistry
;
...
...
@@ -51,6 +48,7 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceListener
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.qm.*
;
...
...
@@ -67,16 +65,17 @@ import org.jkiss.dbeaver.ui.controls.TableColumnSortListener;
import
org.jkiss.dbeaver.ui.dialogs.sql.BaseSQLDialog
;
import
org.jkiss.dbeaver.ui.editors.sql.handlers.OpenHandler
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.dbeaver.utils.PrefUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.LongKeyMap
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Locale
;
/**
* QueryLogViewer
...
...
@@ -545,7 +544,7 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
}
else
{
statement
=
((
QMMStatementExecuteInfo
)
object
).
getStatement
();
}
return
"SQL"
+
(
statement
==
null
?
""
:
" / "
+
statement
.
getPurpose
().
name
(
));
//$NON-NLS-1$
return
"SQL"
+
(
statement
==
null
?
""
:
" / "
+
CommonUtils
.
capitalizeWord
(
statement
.
getPurpose
().
getTitle
()
));
//$NON-NLS-1$
// } else if (object instanceof QMMStatementScripInfo) {
// return CoreMessages.controls_querylog_script;
}
else
if
(
object
instanceof
QMMTransactionInfo
)
{
...
...
@@ -814,12 +813,67 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
manager
.
add
(
clearLogAction
);
manager
.
add
(
ActionUtils
.
makeCommandContribution
(
site
,
IWorkbenchCommandConstants
.
FILE_REFRESH
));
//manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
manager
.
add
(
new
Separator
());
createFiltersMenu
(
manager
);
});
menuMgr
.
setRemoveAllWhenShown
(
true
);
logTable
.
setMenu
(
menu
);
site
.
registerContextMenu
(
menuMgr
,
this
);
}
private
void
createFiltersMenu
(
IMenuManager
manager
)
{
DBPPreferenceStore
store
=
DBeaverCore
.
getGlobalPreferenceStore
();
QMEventCriteria
criteria
=
QMUtils
.
createDefaultCriteria
(
store
);
for
(
DBCExecutionPurpose
purpose
:
DBCExecutionPurpose
.
values
())
{
IAction
toggleAction
=
new
Action
(
purpose
.
getTitle
(),
Action
.
AS_CHECK_BOX
)
{
@Override
public
boolean
isChecked
()
{
return
criteria
.
hasQueryType
(
purpose
);
}
@Override
public
void
run
()
{
DBCExecutionPurpose
[]
queryTypes
=
criteria
.
getQueryTypes
();
if
(
isChecked
())
{
queryTypes
=
ArrayUtils
.
remove
(
DBCExecutionPurpose
.
class
,
queryTypes
,
purpose
);
}
else
{
queryTypes
=
ArrayUtils
.
add
(
DBCExecutionPurpose
.
class
,
queryTypes
,
purpose
);
}
List
<
String
>
typeNames
=
new
ArrayList
<>(
queryTypes
.
length
);
for
(
DBCExecutionPurpose
queryType
:
queryTypes
)
typeNames
.
add
(
queryType
.
name
());
store
.
setValue
(
QMConstants
.
PROP_QUERY_TYPES
,
CommonUtils
.
makeString
(
typeNames
,
','
));
PrefUtils
.
savePreferenceStore
(
store
);
scheduleLogRefresh
();
}
};
manager
.
add
(
toggleAction
);
}
manager
.
add
(
new
Separator
());
for
(
QMObjectType
type
:
QMObjectType
.
values
())
{
IAction
toggleAction
=
new
Action
(
type
.
getTitle
(),
Action
.
AS_CHECK_BOX
)
{
@Override
public
boolean
isChecked
()
{
return
criteria
.
hasObjectType
(
type
);
}
@Override
public
void
run
()
{
QMObjectType
[]
objectTypes
=
criteria
.
getObjectTypes
();
if
(
isChecked
())
{
objectTypes
=
ArrayUtils
.
remove
(
QMObjectType
.
class
,
objectTypes
,
type
);
}
else
{
objectTypes
=
ArrayUtils
.
add
(
QMObjectType
.
class
,
objectTypes
,
type
);
}
List
<
QMObjectType
>
typeList
=
new
ArrayList
<>();
Collections
.
addAll
(
typeList
,
objectTypes
);
store
.
setValue
(
QMConstants
.
PROP_OBJECT_TYPES
,
QMObjectType
.
toString
(
typeList
));
PrefUtils
.
savePreferenceStore
(
store
);
scheduleLogRefresh
();
}
};
manager
.
add
(
toggleAction
);
}
}
private
void
openSelectionInEditor
()
{
DBPDataSourceContainer
dsContainer
=
null
;
StringBuilder
sql
=
new
StringBuilder
();
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/exec/DBCExecutionPurpose.java
浏览文件 @
ce3c6710
...
...
@@ -17,6 +17,8 @@
package
org.jkiss.dbeaver.model.exec
;
import
org.jkiss.utils.CommonUtils
;
/**
* Execution purpose.
*
...
...
@@ -29,18 +31,21 @@ package org.jkiss.dbeaver.model.exec;
*/
public
enum
DBCExecutionPurpose
{
USER
(
0
,
true
),
// User query
USER_FILTERED
(
1
,
true
),
// User query with additional filters
USER_SCRIPT
(
2
,
true
),
// User script query
UTIL
(
3
,
false
),
// Utility query (utility method initialized by user)
META
(
4
,
false
),
// Metadata query, processed by data source providers internally
META_DDL
(
5
,
false
),;
USER
(
0
,
"User"
,
true
),
// User query
USER_FILTERED
(
1
,
"User filtered"
,
true
),
// User query with additional filters
USER_SCRIPT
(
2
,
"User script"
,
true
),
// User script query
UTIL
(
3
,
"Util"
,
false
),
// Utility query (utility method initialized by user)
META
(
4
,
"Meta"
,
false
),
// Metadata query, processed by data source providers internally
META_DDL
(
5
,
"Meta DDL"
,
false
),
;
private
final
int
id
;
private
final
String
title
;
private
final
boolean
user
;
DBCExecutionPurpose
(
int
id
,
boolean
user
)
{
DBCExecutionPurpose
(
int
id
,
String
title
,
boolean
user
)
{
this
.
id
=
id
;
this
.
title
=
title
;
this
.
user
=
user
;
}
...
...
@@ -48,6 +53,10 @@ public enum DBCExecutionPurpose {
return
id
;
}
public
String
getTitle
()
{
return
title
;
}
public
boolean
isUser
()
{
return
user
;
}
// Metadata modifications (DDL)
...
...
@@ -60,4 +69,5 @@ public enum DBCExecutionPurpose {
}
return
USER
;
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
浏览文件 @
ce3c6710
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.model.qm
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.utils.ArrayUtils
;
...
...
@@ -30,10 +31,10 @@ public class QMEventCriteria {
String
containerId
;
@Nullable
String
sessionId
;
@N
ullable
QMObjectType
[]
objectTypes
;
@N
ullable
DBCExecutionPurpose
[]
queryTypes
;
@N
otNull
QMObjectType
[]
objectTypes
=
new
QMObjectType
[
0
]
;
@N
otNull
DBCExecutionPurpose
[]
queryTypes
=
new
DBCExecutionPurpose
[
0
]
;
@Nullable
String
searchString
;
...
...
@@ -62,12 +63,12 @@ public class QMEventCriteria {
}
public
boolean
hasObjectTypes
()
{
return
!
ArrayUtils
.
isEmpty
(
objectTypes
)
&&
objectTypes
.
length
!=
QMObjectType
.
values
().
length
;
return
objectTypes
.
length
>
0
&&
objectTypes
.
length
!=
QMObjectType
.
values
().
length
;
}
public
boolean
hasObjectType
(
QMObjectType
type
)
{
// If all object types are here it is the same as no object type
return
!
ArrayUtils
.
isEmpty
(
objectTypes
)
&&
ArrayUtils
.
contains
(
objectTypes
,
type
);
return
objectTypes
.
length
>
0
&&
ArrayUtils
.
contains
(
objectTypes
,
type
);
}
public
DBCExecutionPurpose
[]
getQueryTypes
()
{
...
...
@@ -80,11 +81,11 @@ public class QMEventCriteria {
public
boolean
hasQueryTypes
()
{
// If all query types are here it is the same as no query type
return
!
ArrayUtils
.
isEmpty
(
queryTypes
)
&&
queryTypes
.
length
!=
DBCExecutionPurpose
.
values
().
length
;
return
queryTypes
.
length
>
0
&&
queryTypes
.
length
!=
DBCExecutionPurpose
.
values
().
length
;
}
public
boolean
hasQueryType
(
DBCExecutionPurpose
type
)
{
return
!
ArrayUtils
.
isEmpty
(
queryTypes
)
&&
ArrayUtils
.
contains
(
queryTypes
,
type
);
return
queryTypes
.
length
>
0
&&
ArrayUtils
.
contains
(
queryTypes
,
type
);
}
public
String
getSearchString
()
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMObjectType.java
浏览文件 @
ce3c6710
...
...
@@ -31,14 +31,16 @@ import java.util.List;
*/
public
enum
QMObjectType
{
session
(
QMMSessionInfo
.
class
),
txn
(
QMMTransactionInfo
.
class
),
query
(
QMMStatementInfo
.
class
);
session
(
"Session"
,
QMMSessionInfo
.
class
),
txn
(
"Transactions"
,
QMMTransactionInfo
.
class
),
query
(
"Queries"
,
QMMStatementInfo
.
class
);
private
final
String
title
;
private
final
Class
<?
extends
QMMObject
>
type
;
QMObjectType
(
Class
<?
extends
QMMObject
>
type
)
QMObjectType
(
String
title
,
Class
<?
extends
QMMObject
>
type
)
{
this
.
title
=
title
;
this
.
type
=
type
;
}
...
...
@@ -47,6 +49,10 @@ public enum QMObjectType {
return
type
;
}
public
String
getTitle
()
{
return
title
;
}
public
static
String
toString
(
Collection
<
QMObjectType
>
objectTypes
)
{
List
<
String
>
names
=
new
ArrayList
<>(
objectTypes
.
size
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录