mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-154156 disable FileChooser actions when FileChooser is not in context
This commit is contained in:
+11
-4
@@ -20,6 +20,7 @@ import com.intellij.ide.actions.DeleteAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.fileChooser.ex.FileChooserKeys;
|
||||
|
||||
public class FileDeleteAction extends DeleteAction {
|
||||
@@ -34,13 +35,19 @@ public class FileDeleteAction extends DeleteAction {
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
Presentation presentation = event.getPresentation();
|
||||
final Boolean available = event.getData(FileChooserKeys.DELETE_ACTION_AVAILABLE);
|
||||
if (available != null && !available) {
|
||||
presentation.setEnabled(false);
|
||||
presentation.setVisible(false);
|
||||
FileSystemTree tree = event.getData(FileSystemTree.DATA_KEY);
|
||||
if (tree == null) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final Boolean available = event.getData(FileChooserKeys.DELETE_ACTION_AVAILABLE);
|
||||
if (available != null && !available) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
presentation.setEnabledAndVisible(true);
|
||||
super.update(event);
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -19,11 +19,18 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.fileChooser.FileSystemTree;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public final class ShowHiddensAction extends ToggleAction implements DumbAware {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
FileSystemTree tree = e.getData(FileSystemTree.DATA_KEY);
|
||||
e.getPresentation().setEnabled(tree != null);
|
||||
}
|
||||
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
final FileSystemTree fileSystemTree = e.getData(FileSystemTree.DATA_KEY);
|
||||
return fileSystemTree != null && fileSystemTree.areHiddensShown();
|
||||
|
||||
Reference in New Issue
Block a user