Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
65936fef
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,发现更多精彩内容 >>
提交
65936fef
编写于
9月 22, 2020
作者:
N
Nikita Akilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#9765 codestyle fixes
上级
0eddafea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
27 deletion
+29
-27
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectDelete.java
...er/ui/navigator/actions/NavigatorHandlerObjectDelete.java
+6
-7
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorObjectsDeleter.java
...dbeaver/ui/navigator/actions/NavigatorObjectsDeleter.java
+23
-20
未找到文件。
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectDelete.java
浏览文件 @
65936fef
...
@@ -43,7 +43,6 @@ import org.jkiss.utils.CommonUtils;
...
@@ -43,7 +43,6 @@ import org.jkiss.utils.CommonUtils;
import
java.util.*
;
import
java.util.*
;
import
java.util.List
;
import
java.util.List
;
@SuppressWarnings
({
"rawtypes"
})
public
class
NavigatorHandlerObjectDelete
extends
NavigatorHandlerObjectBase
implements
IElementUpdater
{
public
class
NavigatorHandlerObjectDelete
extends
NavigatorHandlerObjectBase
implements
IElementUpdater
{
@Override
@Override
public
Object
execute
(
final
ExecutionEvent
event
)
throws
ExecutionException
{
public
Object
execute
(
final
ExecutionEvent
event
)
throws
ExecutionException
{
...
@@ -52,14 +51,14 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
...
@@ -52,14 +51,14 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
return
null
;
return
null
;
}
}
final
IWorkbenchWindow
window
=
HandlerUtil
.
getActiveWorkbenchWindow
(
event
);
final
IWorkbenchWindow
window
=
HandlerUtil
.
getActiveWorkbenchWindow
(
event
);
final
List
selectedObjects
=
((
IStructuredSelection
)
selection
).
toList
();
@SuppressWarnings
(
"unchecked"
)
final
List
<
Object
>
selectedObjects
=
((
IStructuredSelection
)
selection
).
toList
();
final
NavigatorObjectsDeleter
deleter
=
NavigatorObjectsDeleter
.
of
(
selectedObjects
,
window
);
final
NavigatorObjectsDeleter
deleter
=
NavigatorObjectsDeleter
.
of
(
selectedObjects
,
window
);
makeDeletionAttempt
(
window
,
selectedObjects
,
deleter
);
makeDeletionAttempt
(
window
,
selectedObjects
,
deleter
);
return
null
;
return
null
;
}
}
private
void
makeDeletionAttempt
(
final
IWorkbenchWindow
window
,
final
List
selectedObjects
,
final
NavigatorObjectsDeleter
deleter
)
{
private
void
makeDeletionAttempt
(
final
IWorkbenchWindow
window
,
final
List
<
Object
>
selectedObjects
,
final
NavigatorObjectsDeleter
deleter
)
{
if
(
deleter
.
areSome
NodesFromDifferentDataSources
())
{
if
(
deleter
.
has
NodesFromDifferentDataSources
())
{
// attempt to delete database nodes from different databases
// attempt to delete database nodes from different databases
DBWorkbench
.
getPlatformUI
().
DBWorkbench
.
getPlatformUI
().
showError
(
showError
(
...
@@ -89,7 +88,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
...
@@ -89,7 +88,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
}
}
private
static
class
ConfirmationDialog
extends
MessageDialog
{
private
static
class
ConfirmationDialog
extends
MessageDialog
{
private
final
List
selectedObjects
;
private
final
List
<
Object
>
selectedObjects
;
private
final
boolean
showCascade
;
private
final
boolean
showCascade
;
...
@@ -98,7 +97,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
...
@@ -98,7 +97,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
private
boolean
cascadeCheck
;
private
boolean
cascadeCheck
;
private
ConfirmationDialog
(
final
Shell
shell
,
final
String
title
,
final
String
message
,
private
ConfirmationDialog
(
final
Shell
shell
,
final
String
title
,
final
String
message
,
final
List
selectedObjects
,
final
boolean
showCascade
,
final
boolean
showViewScript
)
{
final
List
<
Object
>
selectedObjects
,
final
boolean
showCascade
,
final
boolean
showViewScript
)
{
super
(
super
(
shell
,
shell
,
title
,
title
,
...
@@ -113,7 +112,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
...
@@ -113,7 +112,7 @@ public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase imp
this
.
showViewScript
=
showViewScript
;
this
.
showViewScript
=
showViewScript
;
}
}
static
ConfirmationDialog
of
(
final
Shell
shell
,
final
List
selectedObjects
,
static
ConfirmationDialog
of
(
final
Shell
shell
,
final
List
<
Object
>
selectedObjects
,
final
boolean
showCascade
,
final
boolean
showViewScript
)
{
final
boolean
showCascade
,
final
boolean
showViewScript
)
{
if
(
selectedObjects
.
size
()
>
1
)
{
if
(
selectedObjects
.
size
()
>
1
)
{
return
new
ConfirmationDialog
(
return
new
ConfirmationDialog
(
...
...
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorObjectsDeleter.java
浏览文件 @
65936fef
...
@@ -35,7 +35,6 @@ import org.jkiss.dbeaver.ui.internal.UINavigatorMessages;
...
@@ -35,7 +35,6 @@ import org.jkiss.dbeaver.ui.internal.UINavigatorMessages;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.*
;
import
java.util.*
;
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
class
NavigatorObjectsDeleter
{
class
NavigatorObjectsDeleter
{
private
static
final
Log
log
=
Log
.
getLog
(
NavigatorObjectsDeleter
.
class
);
private
static
final
Log
log
=
Log
.
getLog
(
NavigatorObjectsDeleter
.
class
);
...
@@ -56,7 +55,7 @@ class NavigatorObjectsDeleter {
...
@@ -56,7 +55,7 @@ class NavigatorObjectsDeleter {
/**
/**
* A list containing objects to delete.
* A list containing objects to delete.
*/
*/
private
final
List
selection
;
private
final
List
<
Object
>
selection
;
/**
/**
* {@code true} if 'Cascade delete' button should be shown
* {@code true} if 'Cascade delete' button should be shown
...
@@ -71,25 +70,26 @@ class NavigatorObjectsDeleter {
...
@@ -71,25 +70,26 @@ class NavigatorObjectsDeleter {
/**
/**
* {@code true} in case of attempt to delete database nodes which belong to different data sources
* {@code true} in case of attempt to delete database nodes which belong to different data sources
*/
*/
private
final
boolean
areSome
NodesFromDifferentDataSources
;
private
final
boolean
has
NodesFromDifferentDataSources
;
private
@Nullable
DBECommandContext
commandContext
;
@Nullable
private
DBECommandContext
commandContext
;
private
boolean
checkCascade
=
false
;
private
boolean
checkCascade
=
false
;
private
NavigatorObjectsDeleter
(
final
List
selection
,
final
IWorkbenchWindow
window
,
private
NavigatorObjectsDeleter
(
final
List
<
Object
>
selection
,
final
IWorkbenchWindow
window
,
final
boolean
areSome
NodesFromDifferentDataSources
,
final
boolean
showCascade
,
final
boolean
has
NodesFromDifferentDataSources
,
final
boolean
showCascade
,
final
boolean
showViewScript
)
{
final
boolean
showViewScript
)
{
this
.
selection
=
selection
;
this
.
selection
=
selection
;
this
.
window
=
window
;
this
.
window
=
window
;
this
.
areSomeNodesFromDifferentDataSources
=
areSome
NodesFromDifferentDataSources
;
this
.
hasNodesFromDifferentDataSources
=
has
NodesFromDifferentDataSources
;
this
.
showCascade
=
showCascade
;
this
.
showCascade
=
showCascade
;
this
.
showViewScript
=
showViewScript
;
this
.
showViewScript
=
showViewScript
;
}
}
static
NavigatorObjectsDeleter
of
(
final
List
selection
,
final
IWorkbenchWindow
window
)
{
static
NavigatorObjectsDeleter
of
(
final
List
<
Object
>
selection
,
final
IWorkbenchWindow
window
)
{
DBPDataSource
dataSource
=
null
;
DBPDataSource
dataSource
=
null
;
boolean
areSome
NodesFromDifferentDataSources
=
false
;
boolean
has
NodesFromDifferentDataSources
=
false
;
boolean
showCascade
=
false
;
boolean
showCascade
=
false
;
boolean
showViewScript
=
false
;
boolean
showViewScript
=
false
;
for
(
Object
obj:
selection
)
{
for
(
Object
obj:
selection
)
{
...
@@ -101,7 +101,7 @@ class NavigatorObjectsDeleter {
...
@@ -101,7 +101,7 @@ class NavigatorObjectsDeleter {
if
(
dataSource
==
null
)
{
if
(
dataSource
==
null
)
{
dataSource
=
currentDatasource
;
dataSource
=
currentDatasource
;
}
else
if
(!
dataSource
.
equals
(
currentDatasource
))
{
}
else
if
(!
dataSource
.
equals
(
currentDatasource
))
{
areSome
NodesFromDifferentDataSources
=
true
;
has
NodesFromDifferentDataSources
=
true
;
}
}
if
(!(
node
.
getParentNode
()
instanceof
DBNContainer
))
{
if
(!(
node
.
getParentNode
()
instanceof
DBNContainer
))
{
continue
;
continue
;
...
@@ -110,7 +110,8 @@ class NavigatorObjectsDeleter {
...
@@ -110,7 +110,8 @@ class NavigatorObjectsDeleter {
if
(
object
==
null
)
{
if
(
object
==
null
)
{
continue
;
continue
;
}
}
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
@SuppressWarnings
(
"rawtypes"
)
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
if
(
objectMaker
==
null
)
{
if
(
objectMaker
==
null
)
{
continue
;
continue
;
}
}
...
@@ -130,11 +131,11 @@ class NavigatorObjectsDeleter {
...
@@ -130,11 +131,11 @@ class NavigatorObjectsDeleter {
showViewScript
=
true
;
showViewScript
=
true
;
}
}
}
}
return
new
NavigatorObjectsDeleter
(
selection
,
window
,
areSome
NodesFromDifferentDataSources
,
showCascade
,
showViewScript
);
return
new
NavigatorObjectsDeleter
(
selection
,
window
,
has
NodesFromDifferentDataSources
,
showCascade
,
showViewScript
);
}
}
boolean
areSome
NodesFromDifferentDataSources
()
{
boolean
has
NodesFromDifferentDataSources
()
{
return
areSome
NodesFromDifferentDataSources
;
return
has
NodesFromDifferentDataSources
;
}
}
public
boolean
getShowCascade
()
{
public
boolean
getShowCascade
()
{
...
@@ -196,7 +197,8 @@ class NavigatorObjectsDeleter {
...
@@ -196,7 +197,8 @@ class NavigatorObjectsDeleter {
if
(
object
==
null
)
{
if
(
object
==
null
)
{
throw
new
DBException
(
"Can't delete node with null object"
);
throw
new
DBException
(
"Can't delete node with null object"
);
}
}
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
@SuppressWarnings
(
"rawtypes"
)
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
if
(
objectMaker
==
null
)
{
if
(
objectMaker
==
null
)
{
throw
new
DBException
(
"Object maker not found for type '"
+
object
.
getClass
().
getName
()
+
"'"
);
//$NON-NLS-2$
throw
new
DBException
(
"Object maker not found for type '"
+
object
.
getClass
().
getName
()
+
"'"
);
//$NON-NLS-2$
}
}
...
@@ -218,7 +220,7 @@ class NavigatorObjectsDeleter {
...
@@ -218,7 +220,7 @@ class NavigatorObjectsDeleter {
// try to find corresponding command context
// try to find corresponding command context
// and execute command within it
// and execute command within it
}
}
Map
<
String
,
Object
>
deleteOptions
=
Collections
.
EMPTY_MAP
;
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
deleteOptions
=
Collections
.
EMPTY_MAP
;
if
(
checkCascade
&&
supportsCascade
)
{
if
(
checkCascade
&&
supportsCascade
)
{
deleteOptions
=
OPTIONS_CASCADE
;
deleteOptions
=
OPTIONS_CASCADE
;
}
}
...
@@ -258,6 +260,7 @@ class NavigatorObjectsDeleter {
...
@@ -258,6 +260,7 @@ class NavigatorObjectsDeleter {
UIServiceSQL
serviceSQL
=
DBWorkbench
.
getService
(
UIServiceSQL
.
class
);
UIServiceSQL
serviceSQL
=
DBWorkbench
.
getService
(
UIServiceSQL
.
class
);
if
(
serviceSQL
!=
null
)
{
if
(
serviceSQL
!=
null
)
{
result
=
serviceSQL
.
openSQLViewer
(
result
=
serviceSQL
.
openSQLViewer
(
//command context is not null because sql is not empty, see appendSQL()
commandContext
.
getExecutionContext
(),
commandContext
.
getExecutionContext
(),
UINavigatorMessages
.
actions_navigator_delete_script
,
UINavigatorMessages
.
actions_navigator_delete_script
,
UIIcon
.
SQL_PREVIEW
,
UIIcon
.
SQL_PREVIEW
,
...
@@ -291,12 +294,12 @@ class NavigatorObjectsDeleter {
...
@@ -291,12 +294,12 @@ class NavigatorObjectsDeleter {
if
(!(
node
.
getParentNode
()
instanceof
DBNContainer
))
{
if
(!(
node
.
getParentNode
()
instanceof
DBNContainer
))
{
return
;
return
;
}
}
// Try to delete object using object manager
final
DBSObject
object
=
node
.
getObject
();
final
DBSObject
object
=
node
.
getObject
();
if
(
object
==
null
)
{
if
(
object
==
null
)
{
return
;
return
;
}
}
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
@SuppressWarnings
(
"rawtypes"
)
final
DBEObjectMaker
objectMaker
=
DBWorkbench
.
getPlatform
().
getEditorsRegistry
().
getObjectManager
(
object
.
getClass
(),
DBEObjectMaker
.
class
);
if
(
objectMaker
==
null
)
{
if
(
objectMaker
==
null
)
{
return
;
return
;
}
}
...
@@ -333,11 +336,11 @@ class NavigatorObjectsDeleter {
...
@@ -333,11 +336,11 @@ class NavigatorObjectsDeleter {
}
}
final
StringBuilder
script
=
new
StringBuilder
();
final
StringBuilder
script
=
new
StringBuilder
();
final
DBECommandContext
commandContext
=
commandTarget
.
getContext
();
final
DBECommandContext
commandContext
=
commandTarget
.
getContext
();
final
Collection
<?
extends
DBECommand
>
commands
=
commandContext
.
getFinalCommands
();
final
@SuppressWarnings
(
"rawtypes"
)
Collection
<?
extends
DBECommand
>
commands
=
commandContext
.
getFinalCommands
();
try
{
try
{
UIUtils
.
runInProgressService
(
monitor
->
{
UIUtils
.
runInProgressService
(
monitor
->
{
try
{
try
{
for
(
DBECommand
command
:
commands
)
{
for
(
@SuppressWarnings
(
"rawtypes"
)
DBECommand
command
:
commands
)
{
final
DBEPersistAction
[]
persistActions
=
command
.
getPersistActions
(
monitor
,
commandContext
.
getExecutionContext
(),
deleteOptions
);
final
DBEPersistAction
[]
persistActions
=
command
.
getPersistActions
(
monitor
,
commandContext
.
getExecutionContext
(),
deleteOptions
);
script
.
append
(
script
.
append
(
SQLUtils
.
generateScript
(
commandContext
.
getExecutionContext
().
getDataSource
(),
SQLUtils
.
generateScript
(
commandContext
.
getExecutionContext
().
getDataSource
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录