Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
5fa01537
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,发现更多精彩内容 >>
提交
5fa01537
编写于
4月 07, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3278 Notifications preferences + commit/rollback notifications
上级
1a0ba85f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
51 addition
and
33 deletion
+51
-33
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/DBeaverPreferences.java
...beaver.core/src/org/jkiss/dbeaver/DBeaverPreferences.java
+0
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
...org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
+1
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
...r.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
+12
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
...beaver/ui/actions/datasource/DataSourceCommitHandler.java
+2
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceRollbackHandler.java
...aver/ui/actions/datasource/DataSourceRollbackHandler.java
+14
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
...jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
+5
-4
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java
...dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java
+7
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
...dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
+2
-0
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationSink.java
...ss/dbeaver/ui/notifications/DatabaseNotificationSink.java
+4
-0
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
...org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
+4
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/DBeaverPreferences.java
浏览文件 @
5fa01537
...
...
@@ -26,9 +26,6 @@ public final class DBeaverPreferences
public
static
final
String
AGENT_LONG_OPERATION_NOTIFY
=
"agent.long.operation.notify"
;
//$NON-NLS-1$
public
static
final
String
AGENT_LONG_OPERATION_TIMEOUT
=
"agent.long.operation.timeout"
;
//$NON-NLS-1$
public
static
final
String
NOTIFICATIONS_ENABLED
=
"notifications.enabled"
;
//$NON-NLS-1$
public
static
final
String
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
=
"notifications.closeDelay"
;
//$NON-NLS-1$
public
static
final
String
PLATFORM_LANGUAGE
=
"platform.language"
;
//$NON-NLS-1$
public
static
final
String
NAVIGATOR_EXPAND_ON_CONNECT
=
"navigator.expand.on.connect"
;
//$NON-NLS-1$
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverPreferencesInitializer.java
浏览文件 @
5fa01537
...
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.core;
import
org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer
;
import
org.eclipse.ui.texteditor.AbstractTextEditor
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.ModelPreferences
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore
;
...
...
@@ -63,10 +64,6 @@ public class DBeaverPreferencesInitializer extends AbstractPreferenceInitializer
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
AGENT_LONG_OPERATION_NOTIFY
,
isWindows
);
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
AGENT_LONG_OPERATION_TIMEOUT
,
30
);
// Notifications
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
NOTIFICATIONS_ENABLED
,
true
);
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
,
5000L
);
// Navigator
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
NAVIGATOR_EXPAND_ON_CONNECT
,
false
);
PrefUtils
.
setDefaultPreferenceValue
(
store
,
DBeaverPreferences
.
NAVIGATOR_SORT_ALPHABETICALLY
,
false
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverNotifications.java
浏览文件 @
5fa01537
...
...
@@ -22,25 +22,26 @@ 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.model.DBPMessageType
;
import
org.jkiss.dbeaver.ui.notifications.NotificationPopupMessage
;
import
org.jkiss.dbeaver.ui.notifications.NotificationUtils
;
/**
* 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();
});
*/
public
static
void
showNotification
(
DBPDataSource
dataSource
,
String
id
,
String
text
)
{
NotificationUtils
.
sendNotification
(
dataSource
,
id
,
text
,
null
,
null
);
}
public
static
void
showNotification
(
DBPDataSource
dataSource
,
String
id
,
String
text
,
DBPMessageType
messageType
)
{
NotificationUtils
.
sendNotification
(
dataSource
,
id
,
text
,
messageType
,
null
);
}
public
static
void
showInformation
(
DBPDataSource
dataSource
,
String
id
,
String
text
,
DBPMessageType
messageType
,
Runnable
feedback
)
{
NotificationUtils
.
sendNotification
(
dataSource
,
id
,
text
,
messageType
,
feedback
);
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceCommitHandler.java
浏览文件 @
5fa01537
...
...
@@ -24,8 +24,8 @@ 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.DBeaverNotifications
;
import
org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler
;
import
org.jkiss.dbeaver.ui.notifications.NotificationUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -53,21 +53,12 @@ public class DataSourceCommitHandler extends AbstractDataSourceHandler
throw
new
InvocationTargetException
(
e
);
}
NotificationUtils
.
send
Notification
(
DBeaverNotifications
.
show
Notification
(
context
.
getDataSource
(),
"commit"
,
"Transaction has been committed\n\n"
+
"Query count: "
+
txnInfo
.
getUpdateCount
()
+
"\n"
+
"Duration: "
+
RuntimeUtils
.
formatExecutionTime
(
System
.
currentTimeMillis
()
-
txnInfo
.
getTransactionStartTime
())
+
"\n"
);
/*
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.core/src/org/jkiss/dbeaver/ui/actions/datasource/DataSourceRollbackHandler.java
浏览文件 @
5fa01537
...
...
@@ -18,12 +18,17 @@ package org.jkiss.dbeaver.ui.actions.datasource;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
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.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.runtime.TasksJob
;
import
org.jkiss.dbeaver.ui.DBeaverNotifications
;
import
org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -46,11 +51,20 @@ public class DataSourceRollbackHandler extends AbstractDataSourceHandler
throws
InvocationTargetException
,
InterruptedException
{
DBCTransactionManager
txnManager
=
DBUtils
.
getTransactionManager
(
context
);
if
(
txnManager
!=
null
)
{
QMTransactionState
txnInfo
=
QMUtils
.
getTransactionState
(
context
);
try
(
DBCSession
session
=
context
.
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Rollback transaction"
))
{
txnManager
.
rollback
(
session
,
null
);
}
catch
(
DBCException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
DBeaverNotifications
.
showNotification
(
context
.
getDataSource
(),
"rollback"
,
"Transaction has been rolled back\n\n"
+
"Query count: "
+
txnInfo
.
getUpdateCount
()
+
"\n"
+
"Duration: "
+
RuntimeUtils
.
formatExecutionTime
(
System
.
currentTimeMillis
()
-
txnInfo
.
getTransactionStartTime
())
+
"\n"
,
DBPMessageType
.
ERROR
);
}
}
});
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
浏览文件 @
5fa01537
...
...
@@ -31,6 +31,7 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.ModelPreferences
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
...
...
@@ -165,8 +166,8 @@ public class PrefPageDatabaseGeneral extends AbstractPrefPage implements IWorkbe
automaticUpdateCheck
.
setSelection
(
store
.
getBoolean
(
DBeaverPreferences
.
UI_AUTO_UPDATE_CHECK
));
notificationsEnabled
.
setSelection
(
store
.
getBoolean
(
DBeaver
Preferences
.
NOTIFICATIONS_ENABLED
));
notificationsCloseDelay
.
setSelection
(
store
.
getInt
(
DBeaver
Preferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
));
notificationsEnabled
.
setSelection
(
store
.
getBoolean
(
Model
Preferences
.
NOTIFICATIONS_ENABLED
));
notificationsCloseDelay
.
setSelection
(
store
.
getInt
(
Model
Preferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
));
longOperationsCheck
.
setSelection
(
store
.
getBoolean
(
DBeaverPreferences
.
AGENT_LONG_OPERATION_NOTIFY
));
longOperationsTimeout
.
setSelection
(
store
.
getInt
(
DBeaverPreferences
.
AGENT_LONG_OPERATION_TIMEOUT
));
...
...
@@ -179,8 +180,8 @@ public class PrefPageDatabaseGeneral extends AbstractPrefPage implements IWorkbe
store
.
setValue
(
DBeaverPreferences
.
UI_AUTO_UPDATE_CHECK
,
automaticUpdateCheck
.
getSelection
());
store
.
setValue
(
DBeaver
Preferences
.
NOTIFICATIONS_ENABLED
,
notificationsEnabled
.
getSelection
());
store
.
setValue
(
DBeaver
Preferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
,
notificationsCloseDelay
.
getSelection
());
store
.
setValue
(
Model
Preferences
.
NOTIFICATIONS_ENABLED
,
notificationsEnabled
.
getSelection
());
store
.
setValue
(
Model
Preferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
,
notificationsCloseDelay
.
getSelection
());
store
.
setValue
(
DBeaverPreferences
.
AGENT_LONG_OPERATION_NOTIFY
,
longOperationsCheck
.
getSelection
());
store
.
setValue
(
DBeaverPreferences
.
AGENT_LONG_OPERATION_TIMEOUT
,
longOperationsTimeout
.
getSelection
());
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java
浏览文件 @
5fa01537
...
...
@@ -38,6 +38,9 @@ import java.util.Arrays;
*/
public
final
class
ModelPreferences
{
public
static
final
String
NOTIFICATIONS_ENABLED
=
"notifications.enabled"
;
//$NON-NLS-1$
public
static
final
String
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
=
"notifications.closeDelay"
;
//$NON-NLS-1$
public
static
final
String
QUERY_ROLLBACK_ON_ERROR
=
"query.rollback-on-error"
;
//$NON-NLS-1$
public
static
final
String
EXECUTE_RECOVER_ENABLED
=
"execute.recover.enabled"
;
//$NON-NLS-1$
...
...
@@ -112,6 +115,10 @@ public final class ModelPreferences
}
private
static
void
initializeDefaultPreferences
(
DBPPreferenceStore
store
)
{
// Notifications
PrefUtils
.
setDefaultPreferenceValue
(
store
,
ModelPreferences
.
NOTIFICATIONS_ENABLED
,
true
);
PrefUtils
.
setDefaultPreferenceValue
(
store
,
ModelPreferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
,
3000L
);
// Common
PrefUtils
.
setDefaultPreferenceValue
(
store
,
QUERY_ROLLBACK_ON_ERROR
,
false
);
PrefUtils
.
setDefaultPreferenceValue
(
store
,
EXECUTE_RECOVER_ENABLED
,
true
);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMUtils.java
浏览文件 @
5fa01537
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.model.qm
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.app.DBPPlatform
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
...
@@ -113,6 +114,7 @@ public class QMUtils {
return
null
;
}
@NotNull
public
static
QMTransactionState
getTransactionState
(
DBCExecutionContext
executionContext
)
{
int
execCount
=
0
,
updateCount
=
0
;
final
boolean
txnMode
;
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/DatabaseNotificationSink.java
浏览文件 @
5fa01537
...
...
@@ -13,6 +13,7 @@ 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
org.jkiss.dbeaver.ModelPreferences
;
import
java.util.*
;
...
...
@@ -121,6 +122,9 @@ public class DatabaseNotificationSink extends NotificationSink {
Shell
shell
=
new
Shell
(
PlatformUI
.
getWorkbench
().
getDisplay
());
popup
=
new
DatabaseNotificationPopup
(
shell
);
popup
.
setFadingEnabled
(
isAnimationsEnabled
());
popup
.
setDelayClose
(
ModelPreferences
.
getPreferences
().
getInt
(
ModelPreferences
.
NOTIFICATIONS_CLOSE_DELAY_TIMEOUT
));
List
<
AbstractNotification
>
toDisplay
=
new
ArrayList
<>(
currentlyNotifying
);
Collections
.
sort
(
toDisplay
);
popup
.
setContents
(
toDisplay
);
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationUtils.java
浏览文件 @
5fa01537
...
...
@@ -2,6 +2,7 @@ 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.ModelPreferences
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPMessageType
;
...
...
@@ -14,6 +15,9 @@ public abstract class NotificationUtils {
}
public
static
void
sendNotification
(
DBPDataSource
dataSource
,
String
id
,
String
text
,
DBPMessageType
messageType
,
Runnable
feedback
)
{
if
(!
ModelPreferences
.
getPreferences
().
getBoolean
(
ModelPreferences
.
NOTIFICATIONS_ENABLED
))
{
return
;
}
AbstractNotification
notification
=
new
DatabaseNotification
(
dataSource
,
id
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录