提交 65936fef 编写于 作者: N Nikita Akilov

#9765 codestyle fixes

上级 0eddafea
...@@ -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.areSomeNodesFromDifferentDataSources()) { if (deleter.hasNodesFromDifferentDataSources()) {
// 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(
......
...@@ -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 areSomeNodesFromDifferentDataSources; private final boolean hasNodesFromDifferentDataSources;
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 areSomeNodesFromDifferentDataSources, final boolean showCascade, final boolean hasNodesFromDifferentDataSources, final boolean showCascade,
final boolean showViewScript) { final boolean showViewScript) {
this.selection = selection; this.selection = selection;
this.window = window; this.window = window;
this.areSomeNodesFromDifferentDataSources = areSomeNodesFromDifferentDataSources; this.hasNodesFromDifferentDataSources = hasNodesFromDifferentDataSources;
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 areSomeNodesFromDifferentDataSources = false; boolean hasNodesFromDifferentDataSources = 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)) {
areSomeNodesFromDifferentDataSources = true; hasNodesFromDifferentDataSources = 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, areSomeNodesFromDifferentDataSources, showCascade, showViewScript); return new NavigatorObjectsDeleter(selection, window, hasNodesFromDifferentDataSources, showCascade, showViewScript);
} }
boolean areSomeNodesFromDifferentDataSources() { boolean hasNodesFromDifferentDataSources() {
return areSomeNodesFromDifferentDataSources; return hasNodesFromDifferentDataSources;
} }
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.
先完成此消息的编辑!
想要评论请 注册