Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
207641fa
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,发现更多精彩内容 >>
提交
207641fa
编写于
5月 08, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Query history loading visualizer
Former-commit-id:
99041d0d
上级
274c9637
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
84 addition
and
47 deletion
+84
-47
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
...rg/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
+80
-33
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/ProgressEditorPart.java
...g/jkiss/dbeaver/ui/editors/entity/ProgressEditorPart.java
+4
-14
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
浏览文件 @
207641fa
...
@@ -18,8 +18,6 @@ package org.jkiss.dbeaver.ui.controls.querylog;
...
@@ -18,8 +18,6 @@ package org.jkiss.dbeaver.ui.controls.querylog;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.core.runtime.jobs.IJobChangeEvent
;
import
org.eclipse.core.runtime.jobs.JobChangeAdapter
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.action.MenuManager
;
...
@@ -51,20 +49,20 @@ import org.jkiss.dbeaver.core.CoreCommands;
...
@@ -51,20 +49,20 @@ import org.jkiss.dbeaver.core.CoreCommands;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceListener
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceListener
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.preferences.DBPPreferenceStore
;
import
org.jkiss.dbeaver.model.qm.*
;
import
org.jkiss.dbeaver.model.qm.*
;
import
org.jkiss.dbeaver.model.qm.meta.*
;
import
org.jkiss.dbeaver.model.qm.meta.*
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.load.AbstractLoadService
;
import
org.jkiss.dbeaver.model.sql.SQLConstants
;
import
org.jkiss.dbeaver.model.sql.SQLConstants
;
import
org.jkiss.dbeaver.model.sql.SQLDialect
;
import
org.jkiss.dbeaver.model.sql.SQLDialect
;
import
org.jkiss.dbeaver.registry.DataSourceRegistry
;
import
org.jkiss.dbeaver.registry.DataSourceRegistry
;
import
org.jkiss.dbeaver.runtime.qm.DefaultEventFilter
;
import
org.jkiss.dbeaver.runtime.qm.DefaultEventFilter
;
import
org.jkiss.dbeaver.ui.*
;
import
org.jkiss.dbeaver.ui.*
;
import
org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer
;
import
org.jkiss.dbeaver.ui.controls.TableColumnSortListener
;
import
org.jkiss.dbeaver.ui.controls.TableColumnSortListener
;
import
org.jkiss.dbeaver.ui.dialogs.sql.BaseSQLDialog
;
import
org.jkiss.dbeaver.ui.dialogs.sql.BaseSQLDialog
;
import
org.jkiss.dbeaver.ui.editors.sql.handlers.OpenHandler
;
import
org.jkiss.dbeaver.ui.editors.sql.handlers.OpenHandler
;
...
@@ -72,6 +70,7 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
...
@@ -72,6 +70,7 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.LongKeyMap
;
import
org.jkiss.utils.LongKeyMap
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -124,7 +123,7 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
...
@@ -124,7 +123,7 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
}
}
private
LogColumn
COLUMN_TIME
=
new
LogColumn
(
"time"
,
CoreMessages
.
controls_querylog_column_time_name
,
CoreMessages
.
controls_querylog_column_time_tooltip
,
80
)
{
private
LogColumn
COLUMN_TIME
=
new
LogColumn
(
"time"
,
CoreMessages
.
controls_querylog_column_time_name
,
CoreMessages
.
controls_querylog_column_time_tooltip
,
80
)
{
private
final
DateFormat
timeFormat
=
new
SimpleDateFormat
(
DBConstants
.
DEFAULT_TIME_FORMAT
,
Locale
.
getDefault
());
//$NON-NLS-1$
//
private final DateFormat timeFormat = new SimpleDateFormat(DBConstants.DEFAULT_TIME_FORMAT, Locale.getDefault()); //$NON-NLS-1$
private
final
DateFormat
timestampFormat
=
new
SimpleDateFormat
(
"MMM-dd HH:mm:ss"
,
Locale
.
getDefault
());
//$NON-NLS-1$
private
final
DateFormat
timestampFormat
=
new
SimpleDateFormat
(
"MMM-dd HH:mm:ss"
,
Locale
.
getDefault
());
//$NON-NLS-1$
@Override
@Override
String
getText
(
QMMetaEvent
event
)
String
getText
(
QMMetaEvent
event
)
...
@@ -619,6 +618,7 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
...
@@ -619,6 +618,7 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
log
.
debug
(
"Event reload is in progress. Skip"
);
log
.
debug
(
"Event reload is in progress. Skip"
);
return
;
return
;
}
}
reloadInProgress
=
true
;
DBPPreferenceStore
store
=
DBeaverCore
.
getGlobalPreferenceStore
();
DBPPreferenceStore
store
=
DBeaverCore
.
getGlobalPreferenceStore
();
this
.
entriesPerPage
=
Math
.
max
(
MIN_ENTRIES_PER_PAGE
,
store
.
getInt
(
QMConstants
.
PROP_ENTRIES_PER_PAGE
));
this
.
entriesPerPage
=
Math
.
max
(
MIN_ENTRIES_PER_PAGE
,
store
.
getInt
(
QMConstants
.
PROP_ENTRIES_PER_PAGE
));
...
@@ -627,34 +627,12 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
...
@@ -627,34 +627,12 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
clearLog
();
clearLog
();
// Extract events
// Extract events
reloadInProgress
=
true
;
AbstractJob
reloadJob
=
new
AbstractJob
(
"Read meta events"
)
{
EventHistoryReadService
loadingService
=
new
EventHistoryReadService
(
searchString
);
@Override
LoadingJob
.
createService
(
protected
IStatus
run
(
DBRProgressMonitor
monitor
)
{
loadingService
,
final
List
<
QMMetaEvent
>
events
=
new
ArrayList
<>();
new
EvenHistoryReadVisualizer
(
loadingService
))
QMEventBrowser
eventBrowser
=
QMUtils
.
getEventBrowser
();
.
schedule
();
if
(
eventBrowser
!=
null
)
{
QMEventCriteria
criteria
=
new
QMEventCriteria
();
criteria
.
setSearchString
(
CommonUtils
.
isEmptyTrimmed
(
searchString
)
?
null
:
searchString
.
trim
());
try
(
QMEventCursor
cursor
=
eventBrowser
.
getQueryHistoryCursor
(
monitor
,
criteria
))
{
while
(
events
.
size
()
<
entriesPerPage
&&
cursor
.
hasNextEvent
(
monitor
))
{
events
.
add
(
cursor
.
nextEvent
(
monitor
));
}
}
catch
(
DBException
e
)
{
return
GeneralUtils
.
makeExceptionStatus
(
e
);
}
}
DBeaverUI
.
asyncExec
(()
->
updateMetaInfo
(
events
));
return
Status
.
OK_STATUS
;
}
};
reloadJob
.
addJobChangeListener
(
new
JobChangeAdapter
()
{
@Override
public
void
done
(
IJobChangeEvent
event
)
{
reloadInProgress
=
false
;
}
});
reloadJob
.
schedule
();
}
}
@Override
@Override
...
@@ -1090,4 +1068,73 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
...
@@ -1090,4 +1068,73 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
}
}
}
}
class
EventHistoryReadService
extends
AbstractLoadService
<
List
<
QMMetaEvent
>>
{
@Nullable
private
String
searchString
;
protected
EventHistoryReadService
(
@Nullable
String
searchString
)
{
super
(
"Load query history"
);
this
.
searchString
=
searchString
;
}
@Override
public
List
<
QMMetaEvent
>
evaluate
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
final
List
<
QMMetaEvent
>
events
=
new
ArrayList
<>();
QMEventBrowser
eventBrowser
=
QMUtils
.
getEventBrowser
();
if
(
eventBrowser
!=
null
)
{
QMEventCriteria
criteria
=
new
QMEventCriteria
();
criteria
.
setSearchString
(
CommonUtils
.
isEmptyTrimmed
(
searchString
)
?
null
:
searchString
.
trim
());
monitor
.
beginTask
(
"Load query history"
,
1
);
if
(!
CommonUtils
.
isEmpty
(
searchString
))
{
monitor
.
subTask
(
"Search queries: "
+
searchString
);
}
else
{
monitor
.
subTask
(
"Load all queries"
);
}
try
(
QMEventCursor
cursor
=
eventBrowser
.
getQueryHistoryCursor
(
monitor
,
criteria
))
{
while
(
events
.
size
()
<
entriesPerPage
&&
cursor
.
hasNextEvent
(
monitor
))
{
if
(
monitor
.
isCanceled
())
{
break
;
}
events
.
add
(
cursor
.
nextEvent
(
monitor
));
monitor
.
subTask
(
events
.
get
(
events
.
size
()
-
1
).
toString
());
}
}
catch
(
DBException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
monitor
.
done
();
}
return
events
;
}
@Override
public
Object
getFamily
()
{
return
QueryLogViewer
.
class
;
}
}
private
class
EvenHistoryReadVisualizer
extends
ProgressLoaderVisualizer
<
List
<
QMMetaEvent
>>
{
public
EvenHistoryReadVisualizer
(
EventHistoryReadService
loadingService
)
{
super
(
loadingService
,
logTable
);
}
@Override
public
void
visualizeLoading
()
{
reloadInProgress
=
true
;
super
.
visualizeLoading
();
}
@Override
public
void
completeLoading
(
List
<
QMMetaEvent
>
result
)
{
try
{
super
.
completeLoading
(
result
);
super
.
visualizeLoading
();
updateMetaInfo
(
result
);
}
finally
{
reloadInProgress
=
false
;
}
}
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/ProgressEditorPart.java
浏览文件 @
207641fa
...
@@ -18,8 +18,6 @@ package org.jkiss.dbeaver.ui.editors.entity;
...
@@ -18,8 +18,6 @@ package org.jkiss.dbeaver.ui.editors.entity;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.PaintEvent
;
import
org.eclipse.swt.events.PaintListener
;
import
org.eclipse.swt.widgets.Canvas
;
import
org.eclipse.swt.widgets.Canvas
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.IEditorInput
;
import
org.eclipse.ui.IEditorInput
;
...
@@ -95,12 +93,8 @@ public class ProgressEditorPart extends EditorPart {
...
@@ -95,12 +93,8 @@ public class ProgressEditorPart extends EditorPart {
private
void
createProgressPane
(
final
Composite
parent
)
{
private
void
createProgressPane
(
final
Composite
parent
)
{
progressCanvas
=
new
Canvas
(
parent
,
SWT
.
NONE
);
progressCanvas
=
new
Canvas
(
parent
,
SWT
.
NONE
);
progressCanvas
.
addPaintListener
(
new
PaintListener
()
{
progressCanvas
.
addPaintListener
(
e
->
@Override
e
.
gc
.
drawText
(
"Connecting to datasource '"
+
getEditorInput
().
getDatabaseObject
().
getName
()
+
"'..."
,
5
,
5
,
true
));
public
void
paintControl
(
PaintEvent
e
)
{
e
.
gc
.
drawText
(
"Connecting to datasource '"
+
getEditorInput
().
getDatabaseObject
().
getName
()
+
"'..."
,
5
,
5
,
true
);
}
});
InitNodeService
loadingService
=
new
InitNodeService
();
InitNodeService
loadingService
=
new
InitNodeService
();
LoadingJob
<
IDatabaseEditorInput
>
loadJob
=
LoadingJob
.
createService
(
LoadingJob
<
IDatabaseEditorInput
>
loadJob
=
LoadingJob
.
createService
(
...
@@ -163,12 +157,8 @@ public class ProgressEditorPart extends EditorPart {
...
@@ -163,12 +157,8 @@ public class ProgressEditorPart extends EditorPart {
initEntityEditor
(
result
);
initEntityEditor
(
result
);
if
(
result
==
null
)
{
if
(
result
==
null
)
{
// Close editor
// Close editor
DBeaverUI
.
asyncExec
(
new
Runnable
()
{
DBeaverUI
.
asyncExec
(()
->
@Override
entityEditor
.
getSite
().
getWorkbenchWindow
().
getActivePage
().
closeEditor
(
entityEditor
,
false
));
public
void
run
()
{
entityEditor
.
getSite
().
getWorkbenchWindow
().
getActivePage
().
closeEditor
(
entityEditor
,
false
);
}
});
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录