Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
fd880e45
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,发现更多精彩内容 >>
提交
fd880e45
编写于
4月 07, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3278 Database notifications model
上级
1b96f70d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
183 addition
and
44 deletion
+183
-44
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
+0
-2
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+4
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
...beaver/ui/actions/datasource/DataSourceCommitHandler.java
+3
-11
plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF
+1
-0
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationPopup.java
...s/dbeaver/ui/notifications/DatabaseNotificationPopup.java
+13
-0
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationSink.java
...ss/dbeaver/ui/notifications/DatabaseNotificationSink.java
+133
-0
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java
...org/jkiss/dbeaver/ui/notifications/NotificationPopup.java
+0
-25
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java
...ss/dbeaver/ui/notifications/NotificationPopupMessage.java
+2
-4
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
...org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
+27
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
浏览文件 @
fd880e45
...
...
@@ -136,8 +136,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench.renderers.swt,
org.eclipse.e4.ui.css.core,
org.eclipse.e4.ui.css.swt,
org.eclipse.mylyn.commons.notifications.core,
org.eclipse.mylyn.commons.notifications.ui,
org.jkiss.dbeaver.runtime.ide.core,
org.jkiss.dbeaver.runtime.ide.ui
Bundle-Localization: OSGI-INF/l10n/bundle
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
fd880e45
...
...
@@ -3762,14 +3762,16 @@
<extension
point=
"org.eclipse.mylyn.commons.notifications.ui.notifications"
>
<category
id=
"org.jkiss.dbeaver.notifications.database.category"
label=
"Database"
/>
<sink
id=
"org.jkiss.dbeaver.notifications.sink.Popup"
class=
"org.jkiss.dbeaver.ui.notifications.DatabaseNotificationSink"
label=
"Desktop Popup"
/>
<event
categoryId=
"org.jkiss.dbeaver.notifications.database.category"
id=
"org.jkiss.dbeaver.notifications.event.commit"
label=
"Commit"
>
<defaultHandler
sinkId=
"org.
eclipse.mylyn.commons
.notifications.sink.Popup"
/>
<defaultHandler
sinkId=
"org.
jkiss.dbeaver
.notifications.sink.Popup"
/>
<description>
This event is triggered when transaction was committed.
</description>
</event>
<event
categoryId=
"org.jkiss.dbeaver.notifications.database.category"
id=
"org.jkiss.dbeaver.notifications.event.rollback"
label=
"Rollback"
>
<defaultHandler
sinkId=
"org.
eclipse.mylyn.commons
.notifications.sink.Popup"
/>
<defaultHandler
sinkId=
"org.
jkiss.dbeaver
.notifications.sink.Popup"
/>
<description>
This event is triggered when transaction was rolled back.
</description>
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
浏览文件 @
fd880e45
...
...
@@ -18,21 +18,17 @@ package org.jkiss.dbeaver.ui.actions.datasource;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.mylyn.commons.notifications.core.AbstractNotification
;
import
org.eclipse.mylyn.commons.notifications.ui.NotificationsUi
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.DBPMessageType
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.qm.QMTransactionState
;
import
org.jkiss.dbeaver.model.qm.QMUtils
;
import
org.jkiss.dbeaver.runtime.TasksJob
;
import
org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler
;
import
org.jkiss.dbeaver.ui.notifications.
DatabaseNotification
;
import
org.jkiss.dbeaver.ui.notifications.
NotificationUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Collections
;
public
class
DataSourceCommitHandler
extends
AbstractDataSourceHandler
{
...
...
@@ -57,16 +53,12 @@ public class DataSourceCommitHandler extends AbstractDataSourceHandler
throw
new
InvocationTargetException
(
e
);
}
AbstractNotification
notification
=
new
Database
Notification
(
NotificationUtils
.
send
Notification
(
context
.
getDataSource
(),
"commit"
,
"Transaction has been committed\n\n"
+
"Query count: "
+
txnInfo
.
getUpdateCount
()
+
"\n"
+
"Duration: "
+
RuntimeUtils
.
formatExecutionTime
(
System
.
currentTimeMillis
()
-
txnInfo
.
getTransactionStartTime
())
+
"\n"
,
DBPMessageType
.
WARNING
,
null
);
NotificationsUi
.
getService
().
notify
(
Collections
.
singletonList
(
notification
));
"Duration: "
+
RuntimeUtils
.
formatExecutionTime
(
System
.
currentTimeMillis
()
-
txnInfo
.
getTransactionStartTime
())
+
"\n"
);
/*
NotificationPopupMessage.showMessage(
context.getDataSource(),
...
...
plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF
浏览文件 @
fd880e45
...
...
@@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.views,
org.eclipse.ui.workbench.texteditor,
org.eclipse.mylyn.commons.ui,
org.eclipse.mylyn.commons.notifications.core,
org.eclipse.mylyn.commons.notifications.ui,
org.jkiss.dbeaver.model
Export-Package: org.jkiss.dbeaver.ui,
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationPopup.java
0 → 100644
浏览文件 @
fd880e45
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup
;
import
org.eclipse.swt.widgets.Shell
;
public
class
DatabaseNotificationPopup
extends
NotificationPopup
{
public
DatabaseNotificationPopup
(
Shell
parent
)
{
super
(
parent
);
setDelayClose
(
3000
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationSink.java
0 → 100644
浏览文件 @
fd880e45
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.core.runtime.jobs.Job
;
import
org.eclipse.jface.preference.IPreferenceStore
;
import
org.eclipse.jface.window.Window
;
import
org.eclipse.mylyn.commons.notifications.core.AbstractNotification
;
import
org.eclipse.mylyn.commons.notifications.core.NotificationSink
;
import
org.eclipse.mylyn.commons.notifications.core.NotificationSinkEvent
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.IWorkbenchPreferenceConstants
;
import
org.eclipse.ui.PlatformUI
;
import
java.util.*
;
public
class
DatabaseNotificationSink
extends
NotificationSink
{
private
static
final
long
DELAY_OPEN
=
200
;
private
static
final
boolean
runSystem
=
true
;
private
final
WeakHashMap
<
Object
,
Object
>
cancelledTokens
=
new
WeakHashMap
<>();
private
final
Set
<
AbstractNotification
>
notifications
=
new
HashSet
<>();
private
final
Set
<
AbstractNotification
>
currentlyNotifying
=
Collections
.
synchronizedSet
(
notifications
);
private
final
Job
openJob
=
new
Job
(
"Database notifications"
)
{
@Override
protected
IStatus
run
(
IProgressMonitor
monitor
)
{
try
{
if
(
Platform
.
isRunning
()
&&
PlatformUI
.
getWorkbench
()
!=
null
&&
PlatformUI
.
getWorkbench
().
getDisplay
()
!=
null
&&
!
PlatformUI
.
getWorkbench
().
getDisplay
().
isDisposed
())
{
PlatformUI
.
getWorkbench
().
getDisplay
().
asyncExec
(()
->
{
collectNotifications
();
if
(
popup
!=
null
&&
popup
.
getReturnCode
()
==
Window
.
CANCEL
)
{
List
<
AbstractNotification
>
notifications
=
popup
.
getNotifications
();
for
(
AbstractNotification
notification
:
notifications
)
{
if
(
notification
.
getToken
()
!=
null
)
{
cancelledTokens
.
put
(
notification
.
getToken
(),
null
);
}
}
}
currentlyNotifying
.
removeIf
(
notification
->
notification
.
getToken
()
!=
null
&&
cancelledTokens
.
containsKey
(
notification
.
getToken
()));
synchronized
(
DatabaseNotificationSink
.
class
)
{
if
(
currentlyNotifying
.
size
()
>
0
)
{
// popup.close();
showPopup
();
}
}
});
}
}
finally
{
if
(
popup
!=
null
)
{
schedule
(
popup
.
getDelayClose
()
/
2
);
}
}
if
(
monitor
.
isCanceled
())
{
return
Status
.
CANCEL_STATUS
;
}
return
Status
.
OK_STATUS
;
}
};
private
DatabaseNotificationPopup
popup
;
public
DatabaseNotificationSink
()
{
openJob
.
setSystem
(
runSystem
);
}
private
void
cleanNotified
()
{
currentlyNotifying
.
clear
();
}
/** public for testing */
private
void
collectNotifications
()
{
}
/**
* public for testing purposes
*/
public
Set
<
AbstractNotification
>
getNotifications
()
{
synchronized
(
DatabaseNotificationSink
.
class
)
{
return
currentlyNotifying
;
}
}
private
boolean
isAnimationsEnabled
()
{
IPreferenceStore
store
=
PlatformUI
.
getPreferenceStore
();
return
store
.
getBoolean
(
IWorkbenchPreferenceConstants
.
ENABLE_ANIMATIONS
);
}
@Override
public
void
notify
(
NotificationSinkEvent
event
)
{
currentlyNotifying
.
addAll
(
event
.
getNotifications
());
if
(!
openJob
.
cancel
())
{
try
{
openJob
.
join
();
}
catch
(
InterruptedException
e
)
{
// ignore
}
}
openJob
.
schedule
(
DELAY_OPEN
);
}
private
void
showPopup
()
{
if
(
popup
!=
null
)
{
popup
.
close
();
}
Shell
shell
=
new
Shell
(
PlatformUI
.
getWorkbench
().
getDisplay
());
popup
=
new
DatabaseNotificationPopup
(
shell
);
popup
.
setFadingEnabled
(
isAnimationsEnabled
());
List
<
AbstractNotification
>
toDisplay
=
new
ArrayList
<>(
currentlyNotifying
);
Collections
.
sort
(
toDisplay
);
popup
.
setContents
(
toDisplay
);
cleanNotified
();
popup
.
setBlockOnOpen
(
false
);
popup
.
open
();
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java
已删除
100644 → 0
浏览文件 @
1b96f70d
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.ui.PlatformUI
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
public
abstract
class
NotificationPopup
extends
AbstractNotificationPopup
{
public
NotificationPopup
(
Display
display
)
{
super
(
display
);
}
public
NotificationPopup
(
Display
display
,
int
style
)
{
super
(
display
,
style
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java
浏览文件 @
fd880e45
...
...
@@ -2,8 +2,6 @@ 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
;
import
org.eclipse.swt.widgets.Label
;
...
...
@@ -11,14 +9,14 @@ import org.eclipse.ui.PlatformUI;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
public
class
NotificationPopupMessage
extends
NotificationPopup
{
public
class
NotificationPopupMessage
extends
Database
NotificationPopup
{
private
final
DBPDataSource
dataSource
;
private
String
messageText
;
private
int
iconType
;
public
NotificationPopupMessage
(
DBPDataSource
dataSource
,
String
text
,
int
iconType
)
{
super
(
PlatformUI
.
getWorkbench
().
getDisplay
());
super
(
PlatformUI
.
getWorkbench
().
getDisplay
()
.
getActiveShell
()
);
this
.
dataSource
=
dataSource
;
this
.
messageText
=
text
;
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
0 → 100644
浏览文件 @
fd880e45
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.mylyn.commons.notifications.core.AbstractNotification
;
import
org.eclipse.mylyn.commons.notifications.ui.NotificationsUi
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPMessageType
;
import
java.util.Collections
;
public
abstract
class
NotificationUtils
{
public
static
void
sendNotification
(
DBPDataSource
dataSource
,
String
id
,
String
text
)
{
sendNotification
(
dataSource
,
id
,
text
,
null
,
null
);
}
public
static
void
sendNotification
(
DBPDataSource
dataSource
,
String
id
,
String
text
,
DBPMessageType
messageType
,
Runnable
feedback
)
{
AbstractNotification
notification
=
new
DatabaseNotification
(
dataSource
,
id
,
text
,
messageType
,
feedback
);
NotificationsUi
.
getService
().
notify
(
Collections
.
singletonList
(
notification
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录