Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
82e99467
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,发现更多精彩内容 >>
提交
82e99467
编写于
4月 07, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3278 Notification sample (commit)
上级
3ffbac56
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
25 deletion
+88
-25
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
...r.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
+46
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
...beaver/ui/actions/datasource/DataSourceCommitHandler.java
+20
-13
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java
...ss/dbeaver/ui/notifications/NotificationPopupMessage.java
+22
-12
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
0 → 100644
浏览文件 @
82e99467
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Display
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.ui.notifications.NotificationPopupMessage
;
/**
* DBeaverIcons
*/
public
class
DBeaverNotifications
{
public
static
void
showInformation
(
DBPDataSource
dataSource
,
String
text
)
{
/*
Display.getDefault().syncExec(() -> {
int delayClose = DBeaverCore.getGlobalPreferenceStore().getLong(DBeaverPreferences.AGENT_LONG_OPERATION_NOTIFY)
NotificationPopupMessage popup = new NotificationPopupMessage(dataSource, text, SWT.ICON_INFORMATION);
if (delayClose > 0) {
popup.setDelayClose(delayClose);
}
popup.open();
});
*/
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
浏览文件 @
82e99467
...
...
@@ -18,13 +18,16 @@ package org.jkiss.dbeaver.ui.actions.datasource;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.swt.SWT
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.
runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.
runtime.DBRRunnableWithProgres
s
;
import
org.jkiss.dbeaver.model.
qm.QMTransactionState
;
import
org.jkiss.dbeaver.model.
qm.QMUtil
s
;
import
org.jkiss.dbeaver.runtime.TasksJob
;
import
org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler
;
import
org.jkiss.dbeaver.ui.notifications.NotificationPopupMessage
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -41,18 +44,22 @@ public class DataSourceCommitHandler extends AbstractDataSourceHandler
}
public
static
void
execute
(
@NotNull
final
DBCExecutionContext
context
)
{
TasksJob
.
runTask
(
"Commit transaction"
,
new
DBRRunnableWithProgress
()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
DBCTransactionManager
txnManager
=
DBUtils
.
getTransactionManager
(
context
);
if
(
txnManager
!=
null
)
{
try
(
DBCSession
session
=
context
.
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Commit transaction"
))
{
txnManager
.
commit
(
session
);
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
TasksJob
.
runTask
(
"Commit transaction"
,
monitor
->
{
DBCTransactionManager
txnManager
=
DBUtils
.
getTransactionManager
(
context
);
if
(
txnManager
!=
null
)
{
QMTransactionState
txnInfo
=
QMUtils
.
getTransactionState
(
context
);
try
(
DBCSession
session
=
context
.
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Commit transaction"
))
{
txnManager
.
commit
(
session
);
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
NotificationPopupMessage
.
showMessage
(
context
.
getDataSource
(),
"Transaction has been committed\n\n"
+
"Query count: "
+
txnInfo
.
getUpdateCount
()
+
"\n"
+
"Duration: "
+
RuntimeUtils
.
formatExecutionTime
(
System
.
currentTimeMillis
()
-
txnInfo
.
getTransactionStartTime
())
+
"\n"
,
3000
,
SWT
.
ICON_INFORMATION
);
}
});
}
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java
浏览文件 @
82e99467
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Display
;
...
...
@@ -13,17 +15,14 @@ public class NotificationPopupMessage extends NotificationPopup {
private
final
DBPDataSource
dataSource
;
private
String
messageText
;
private
int
iconType
;
public
NotificationPopupMessage
(
String
text
)
{
this
(
null
,
text
);
}
public
NotificationPopupMessage
(
DBPDataSource
dataSource
,
String
text
)
{
public
NotificationPopupMessage
(
DBPDataSource
dataSource
,
String
text
,
int
iconType
)
{
super
(
PlatformUI
.
getWorkbench
().
getDisplay
());
this
.
dataSource
=
dataSource
;
this
.
messageText
=
text
;
setDelayClose
(
3000
)
;
this
.
iconType
=
iconType
;
}
@Override
...
...
@@ -31,17 +30,28 @@ public class NotificationPopupMessage extends NotificationPopup {
return
dataSource
==
null
?
GeneralUtils
.
getProductName
()
:
dataSource
.
getContainer
().
getName
();
}
@Override
protected
Image
getPopupShellImage
(
int
maximumHeight
)
{
boolean
hasIcon
=
iconType
==
SWT
.
ICON_ERROR
||
iconType
==
SWT
.
ICON_WARNING
||
iconType
==
SWT
.
ICON_QUESTION
;
return
hasIcon
?
getShell
().
getDisplay
().
getSystemImage
(
iconType
)
:
null
;
}
@Override
protected
void
createContentArea
(
Composite
composite
)
{
composite
.
setLayout
(
new
GridLayout
(
1
,
true
));
Label
linkGoogleNews
=
new
Label
(
composite
,
SWT
.
NONE
);
linkGoogleNews
.
setText
(
messageText
);
//linkGoogleNews.setSize(400, 100);
Label
textLabel
=
new
Label
(
composite
,
SWT
.
NONE
);
textLabel
.
setText
(
messageText
);
}
public
static
void
showMessage
(
DBPDataSource
dataSource
,
String
text
)
{
Display
.
getDefault
().
syncExec
(()
->
new
NotificationPopupMessage
(
dataSource
,
text
).
open
());
public
static
void
showMessage
(
DBPDataSource
dataSource
,
String
text
,
long
delayClose
,
int
iconType
)
{
Display
.
getDefault
().
syncExec
(()
->
{
NotificationPopupMessage
popup
=
new
NotificationPopupMessage
(
dataSource
,
text
,
iconType
);
if
(
delayClose
>
0
)
{
popup
.
setDelayClose
(
delayClose
);
}
popup
.
open
();
});
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录