project structure: pass selected files to 'delete' action to make sure that IDEA won't try to delete the whole project (IDEA-159125)

This commit is contained in:
nik
2016-08-05 13:42:22 +03:00
parent 89d112ef91
commit 1dc85a9e41
2 changed files with 10 additions and 4 deletions
@@ -21,10 +21,7 @@ import com.intellij.ide.util.treeView.AbstractTreeBuilder;
import com.intellij.ide.util.treeView.AbstractTreeStructure;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
@@ -279,6 +276,10 @@ public class ContentEntryTreeEditor {
@Override
@Nullable
public Object getData(@NonNls final String dataId) {
if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
return myFileSystemTree.getSelectedFiles();
}
if (FileSystemTree.DATA_KEY.is(dataId)) {
return myFileSystemTree;
}
@@ -25,6 +25,11 @@ import javax.swing.*;
import java.util.List;
public interface FileSystemTree extends Disposable {
/**
* If you return a {@link FileSystemTree} instance for this key from a {@link com.intellij.openapi.actionSystem.DataContext}
* you <strong>must</strong> also return {@link #getSelectedFiles()} for {@link com.intellij.openapi.actionSystem.CommonDataKeys#VIRTUAL_FILE_ARRAY} key.
* Otherwise 'Delete' action on your component may delete the whole project.
*/
DataKey<FileSystemTree> DATA_KEY = DataKey.create("FileSystemTree");
JTree getTree();