From 9bae28b30f6fe09dca3a1130de3f0971ec3b5bd5 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Mon, 23 Jul 2018 21:21:06 +0300 Subject: [PATCH] vcs: Replace "DeleteUnversionedFilesAction" with common "DeleteAction" --- .../src/idea/VcsActions.xml | 2 +- .../actions/DeleteUnversionedFilesAction.java | 41 ------------------- .../vcs/changes/ui/SelectFilesDialog.java | 25 ++++------- 3 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java diff --git a/platform/platform-resources/src/idea/VcsActions.xml b/platform/platform-resources/src/idea/VcsActions.xml index 7a4676272c97..8eaef9bafe92 100644 --- a/platform/platform-resources/src/idea/VcsActions.xml +++ b/platform/platform-resources/src/idea/VcsActions.xml @@ -123,7 +123,7 @@ - + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java deleted file mode 100644 index 0343beaf03f4..000000000000 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * 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 com.intellij.openapi.vcs.changes.actions; - -import com.intellij.ide.DeleteProvider; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.util.IconUtil; - -public class DeleteUnversionedFilesAction extends DumbAwareAction { - public DeleteUnversionedFilesAction() { - super("Delete", "Delete", IconUtil.getRemoveIcon()); - } - - public void actionPerformed(final AnActionEvent e) { - DeleteProvider deleteProvider = e.getData(PlatformDataKeys.DELETE_ELEMENT_PROVIDER); - if (deleteProvider == null) return; - deleteProvider.deleteElement(e.getDataContext()); - } - - @Override - public void update(AnActionEvent e) { - DeleteProvider deleteProvider = e.getData(PlatformDataKeys.DELETE_ELEMENT_PROVIDER); - e.getPresentation().setEnabled(deleteProvider != null && deleteProvider.canDeleteElement(e.getDataContext())); - } -} \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java index 7dd9d1e7e92b..aea128e0e497 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java @@ -1,29 +1,16 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.ui; import com.intellij.ide.DeleteProvider; +import com.intellij.ide.actions.DeleteAction; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsShowConfirmationOption; -import com.intellij.openapi.vcs.changes.actions.DeleteUnversionedFilesAction; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; +import com.intellij.util.IconUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,6 +18,8 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; +import static com.intellij.openapi.actionSystem.EmptyAction.setupAction; + /** * @author yole */ @@ -105,15 +94,15 @@ public class SelectFilesDialog extends AbstractSelectFilesDialog { protected DefaultActionGroup createToolbarActions() { DefaultActionGroup defaultGroup = super.createToolbarActions(); if (myDeletableFiles) { - AnAction deleteAction = new DeleteUnversionedFilesAction() { + AnAction deleteAction = new DeleteAction(null, null, IconUtil.getRemoveIcon()) { @Override public void actionPerformed(AnActionEvent e) { super.actionPerformed(e); myFileList.refresh(); } }; + setupAction(deleteAction, IdeActions.ACTION_DELETE, getFileList()); defaultGroup.add(deleteAction); - deleteAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), this.getFileList()); } return defaultGroup; }