Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
6277fc99
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,发现更多精彩内容 >>
提交
6277fc99
编写于
2月 16, 2017
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Transactions monitor state rendering
上级
7fcffc38
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
53 deletion
+49
-53
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/DataSourcePropertyTester.java
...rg/jkiss/dbeaver/ui/actions/DataSourcePropertyTester.java
+4
-6
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/txn/TransactionMonitorToolbar.java
...ss/dbeaver/ui/controls/txn/TransactionMonitorToolbar.java
+40
-45
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
...dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
+5
-2
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/DataSourcePropertyTester.java
浏览文件 @
6277fc99
...
...
@@ -23,15 +23,13 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.CoreCommands
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.DBPContextProvider
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.IDataSourceContainerProvider
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.qm.QMUtils
;
import
org.jkiss.dbeaver.model.qm.meta.QMMSessionInfo
;
import
org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo
;
import
org.jkiss.dbeaver.model.qm.meta.QMMTransactionInfo
;
import
org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo
;
import
org.jkiss.dbeaver.runtime.IPluginService
;
import
org.jkiss.dbeaver.runtime.qm.DefaultExecutionHandler
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/txn/TransactionMonitorToolbar.java
浏览文件 @
6277fc99
...
...
@@ -27,11 +27,9 @@ import org.eclipse.swt.events.PaintEvent;
import
org.eclipse.swt.events.PaintListener
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.Point
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.graphics.Rectangle
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Text
;
import
org.eclipse.ui.*
;
import
org.eclipse.ui.menus.WorkbenchWindowControlContribution
;
import
org.jkiss.code.NotNull
;
...
...
@@ -47,7 +45,6 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor
;
import
org.jkiss.dbeaver.runtime.qm.DefaultExecutionHandler
;
import
org.jkiss.dbeaver.ui.IActionConstants
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.perspective.AbstractPartListener
;
/**
...
...
@@ -106,11 +103,11 @@ public class TransactionMonitorToolbar {
private
class
MonitorPanel
extends
Composite
{
private
QMEventsHandler
qmHandler
;
private
final
Text
txnText
;
private
RefreshJob
refreshJob
;
private
QMTransactionState
txnState
;
public
MonitorPanel
(
Composite
parent
)
{
super
(
parent
,
SWT
.
NONE
);
super
(
parent
,
SWT
.
BORDER
);
//setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
setCursor
(
parent
.
getDisplay
().
getSystemCursor
(
SWT
.
CURSOR_HAND
));
addPaintListener
(
new
PaintListener
()
{
...
...
@@ -119,23 +116,8 @@ public class TransactionMonitorToolbar {
paint
(
e
);
}
});
GridLayout
layout
=
new
GridLayout
(
1
,
false
);
layout
.
marginHeight
=
0
;
//layout.marginWidth = 0;
setLayout
(
layout
);
txnText
=
new
Text
(
this
,
SWT
.
BORDER
|
SWT
.
SINGLE
|
SWT
.
CENTER
);
txnText
.
setEnabled
(
false
);
txnText
.
setBackground
(
parent
.
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WIDGET_BACKGROUND
));
txnText
.
setCursor
(
parent
.
getDisplay
().
getSystemCursor
(
SWT
.
CURSOR_HAND
));
txnText
.
setText
(
""
);
setToolTipText
(
"Transactions monitor"
);
GridData
gd
=
new
GridData
();
gd
.
verticalAlignment
=
GridData
.
CENTER
;
gd
.
grabExcessVerticalSpace
=
true
;
gd
.
widthHint
=
UIUtils
.
getFontHeight
(
txnText
)
*
6
;
txnText
.
setLayoutData
(
gd
);
setBackground
(
parent
.
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WIDGET_BACKGROUND
));
setToolTipText
(
"Transactions monitor"
);
qmHandler
=
new
QMEventsHandler
(
this
);
...
...
@@ -155,11 +137,33 @@ public class TransactionMonitorToolbar {
@Override
public
void
setToolTipText
(
String
string
)
{
super
.
setToolTipText
(
string
);
txnText
.
setToolTipText
(
string
);
}
private
void
paint
(
PaintEvent
e
)
{
//e.gc.drawRectangle(e.x, e.y, e.width, e.height);
Color
bg
;
if
(!
txnState
.
isTransactionMode
())
{
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WIDGET_BACKGROUND
);
}
else
if
(
txnState
.
getUpdateCount
()
==
0
)
{
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WHITE
);
}
else
{
// Use gradient depending on update count
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_INFO_BACKGROUND
);
}
Rectangle
bounds
=
getBounds
();
e
.
gc
.
setBackground
(
bg
);
e
.
gc
.
fillRectangle
(
bounds
.
x
,
bounds
.
y
,
bounds
.
width
,
bounds
.
height
);
String
count
=
""
;
if
(
txnState
==
null
)
{
count
=
"N/A"
;
}
else
if
(!
txnState
.
isTransactionMode
())
{
count
=
"Auto"
;
}
else
if
(
txnState
.
getUpdateCount
()
>
0
)
{
count
=
String
.
valueOf
(
txnState
.
getUpdateCount
());
}
else
{
count
=
"None"
;
}
final
Point
textSize
=
e
.
gc
.
textExtent
(
count
);
e
.
gc
.
drawText
(
count
,
bounds
.
x
+
(
bounds
.
width
-
textSize
.
x
)
/
2
-
2
,
bounds
.
y
+
2
);
}
@Override
...
...
@@ -180,36 +184,23 @@ public class TransactionMonitorToolbar {
executionContext
=
((
DBPContextProvider
)
activeEditor
).
getExecutionContext
();
}
final
QMTransactionState
txnState
=
executionContext
==
null
?
null
:
QMUtils
.
getTransactionState
(
executionContext
);
this
.
txnState
=
executionContext
==
null
?
null
:
QMUtils
.
getTransactionState
(
executionContext
);
monitor
.
done
();
// Update UI
DBeaverUI
.
asyncExec
(
new
Runnable
()
{
@Override
public
void
run
()
{
redrawMonitor
(
txnState
);
redraw
();
updateToolTipText
();
}
});
}
private
void
redrawMonitor
(
QMTransactionState
txnState
)
{
Color
bg
;
if
(!
txnState
.
isTransactionMode
())
{
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WIDGET_BACKGROUND
);
}
else
if
(
txnState
.
getUpdateCount
()
==
0
)
{
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_WHITE
);
}
else
{
// Use gradient depending on update count
bg
=
getDisplay
().
getSystemColor
(
SWT
.
COLOR_INFO_BACKGROUND
);
}
//setBackground(bg);
txnText
.
setBackground
(
bg
);
if
(
txnState
.
getUpdateCount
()
==
0
)
{
txnText
.
setText
(
""
);
}
else
{
txnText
.
setText
(
String
.
valueOf
(
txnState
.
getUpdateCount
()));
}
if
(
txnState
.
isTransactionMode
())
{
private
void
updateToolTipText
()
{
if
(
txnState
==
null
)
{
setToolTipText
(
"Not connected"
);
}
else
if
(
txnState
.
isTransactionMode
())
{
final
long
txnUptime
=
txnState
.
getTransactionStartTime
()
>
0
?
((
System
.
currentTimeMillis
()
-
txnState
.
getTransactionStartTime
())
/
1000
)
+
1
:
0
;
String
toolTip
=
String
.
valueOf
(
txnState
.
getExecuteCount
())
+
" total statements\n"
+
...
...
@@ -221,7 +212,6 @@ public class TransactionMonitorToolbar {
}
else
{
setToolTipText
(
"Auto-commit mode"
);
}
redraw
();
}
}
...
...
@@ -280,6 +270,11 @@ public class TransactionMonitorToolbar {
refreshMonitor
();
}
@Override
public
void
handleContextOpen
(
@NotNull
DBCExecutionContext
context
,
boolean
transactional
)
{
refreshMonitor
();
}
@Override
public
void
handleContextClose
(
@NotNull
DBCExecutionContext
context
)
{
refreshMonitor
();
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
浏览文件 @
6277fc99
...
...
@@ -105,7 +105,7 @@ public class QMUtils {
QMMSessionInfo
sessionInfo
=
application
.
getQueryManager
().
getMetaCollector
().
getSessionInfo
(
executionContext
);
if
(
sessionInfo
.
isClosed
())
{
txnMode
=
false
;
}
else
{
}
else
if
(
sessionInfo
.
isTransactional
())
{
QMMTransactionInfo
txnInfo
=
sessionInfo
.
getTransaction
();
if
(
txnInfo
!=
null
)
{
txnMode
=
true
;
...
...
@@ -119,8 +119,11 @@ public class QMUtils {
}
}
}
else
{
txnMode
=
sessionInfo
.
isTransactional
();
// No active transaction?
txnMode
=
false
;
}
}
else
{
txnMode
=
false
;
}
}
return
new
QMTransactionState
(
execCount
,
updateCount
,
txnMode
,
txnStartTime
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录