mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup database NavBar popup
This commit is contained in:
@@ -19,7 +19,6 @@ import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.intellij.images.thumbnail.ThumbnailManager;
|
||||
@@ -44,14 +43,13 @@ public final class ShowThumbnailsAction extends AnAction {
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
final boolean isEnabled = file != null && file.isDirectory();
|
||||
if (e.getPlace().equals(ActionPlaces.PROJECT_VIEW_POPUP)) {
|
||||
e.getPresentation().setVisible(isEnabled);
|
||||
boolean enabled = file != null && file.isDirectory();
|
||||
if (ActionPlaces.isPopupPlace(e.getPlace())) {
|
||||
e.getPresentation().setEnabledAndVisible(enabled);
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setEnabled(isEnabled);
|
||||
e.getPresentation().setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-4
@@ -17,17 +17,27 @@
|
||||
package com.intellij.history.integration.ui.actions;
|
||||
|
||||
import com.intellij.ide.actions.NonTrivialActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public class LocalHistoryGroup extends NonTrivialActionGroup implements DumbAware {
|
||||
public void update(AnActionEvent event) {
|
||||
if (event.getData(CommonDataKeys.PROJECT) == null) {
|
||||
event.getPresentation().setEnabledAndVisible(false);
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
PsiElement element = e.getData(CommonDataKeys.PSI_ELEMENT);
|
||||
if (project == null ||
|
||||
ActionPlaces.isPopupPlace(e.getPlace()) && (
|
||||
file != null && !file.isInLocalFileSystem() || file == null && element != null)) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
else {
|
||||
super.update(event);
|
||||
super.update(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DeleteAction extends AnAction implements DumbAware {
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
|
||||
if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) {
|
||||
if (ActionPlaces.isPopupPlace(e.getPlace())) {
|
||||
presentation.setText(IdeBundle.message("action.delete.ellipsis"));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -27,7 +27,10 @@ import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.escapeMnemonics;
|
||||
import static com.intellij.openapi.util.text.StringUtil.firstLast;
|
||||
@@ -35,26 +38,29 @@ import static com.intellij.openapi.util.text.StringUtil.firstLast;
|
||||
public class SynchronizeCurrentFileAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
VirtualFile[] files = getFiles(e);
|
||||
|
||||
if (getEventProject(e) == null || files == null || files.length == 0) {
|
||||
List<VirtualFile> files = getFiles(e).take(2).toList();
|
||||
if (e.getProject() == null || files.isEmpty()) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
e.getPresentation().setEnabledAndVisible(true);
|
||||
e.getPresentation().setText(getMessage(files));
|
||||
else {
|
||||
e.getPresentation().setEnabledAndVisible(true);
|
||||
e.getPresentation().setText(getMessage(files));
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMessage(VirtualFile[] files) {
|
||||
return files.length == 1 ? IdeBundle.message("action.synchronize.file", escapeMnemonics(firstLast(files[0].getName(), 20)))
|
||||
: IdeBundle.message("action.synchronize.selected.files");
|
||||
@NotNull
|
||||
private static String getMessage(@NotNull List<VirtualFile> files) {
|
||||
VirtualFile theOnlyOne = files.size() == 1 ? files.get(0) : null;
|
||||
return theOnlyOne != null ?
|
||||
IdeBundle.message("action.synchronize.file", escapeMnemonics(firstLast(theOnlyOne.getName(), 20))) :
|
||||
IdeBundle.message("action.synchronize.selected.files");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = getEventProject(e);
|
||||
final VirtualFile[] files = getFiles(e);
|
||||
if (project == null || files == null || files.length == 0) return;
|
||||
Project project = getEventProject(e);
|
||||
List<VirtualFile> files = getFiles(e).toList();
|
||||
if (project == null || files.isEmpty()) return;
|
||||
|
||||
for (VirtualFile file : files) {
|
||||
if (file.isDirectory()) file.getChildren();
|
||||
@@ -67,7 +73,7 @@ public class SynchronizeCurrentFileAction extends AnAction implements DumbAware
|
||||
RefreshQueue.getInstance().refresh(true, true, () -> postRefresh(project, files), files);
|
||||
}
|
||||
|
||||
private static void postRefresh(Project project, VirtualFile[] files) {
|
||||
private static void postRefresh(Project project, List<VirtualFile> files) {
|
||||
VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
|
||||
for (VirtualFile f : files) {
|
||||
if (f.isDirectory()) {
|
||||
@@ -84,8 +90,9 @@ public class SynchronizeCurrentFileAction extends AnAction implements DumbAware
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile[] getFiles(AnActionEvent e) {
|
||||
return e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
@NotNull
|
||||
private static JBIterable<VirtualFile> getFiles(AnActionEvent e) {
|
||||
return JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY))
|
||||
.filter(o -> o.isInLocalFileSystem());
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class ApplyPatchAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
if (isProjectOrScopeView(e.getPlace())) {
|
||||
if (ActionPlaces.isPopupPlace(e.getPlace())) {
|
||||
VirtualFile vFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
e.getPresentation().setEnabledAndVisible(project != null && isPatchFile(vFile));
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class ApplyPatchAction extends DumbAwareAction {
|
||||
|
||||
VirtualFile vFile = null;
|
||||
final String place = e.getPlace();
|
||||
if (isProjectOrScopeView(place) || ActionPlaces.MAIN_MENU.equals(place)) {
|
||||
if (ActionPlaces.isPopupPlace(e.getPlace()) || ActionPlaces.MAIN_MENU.equals(place)) {
|
||||
vFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
}
|
||||
if (isPatchFile(vFile)) {
|
||||
@@ -109,10 +109,6 @@ public class ApplyPatchAction extends DumbAwareAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isProjectOrScopeView(@NotNull String place) {
|
||||
return place.equals(ActionPlaces.PROJECT_VIEW_POPUP) || place.equals(ActionPlaces.SCOPE_VIEW_POPUP);
|
||||
}
|
||||
|
||||
// used by TeamCity plugin
|
||||
public static void showApplyPatch(@NotNull final Project project, @NotNull final VirtualFile file) {
|
||||
final ApplyPatchDifferentiatedDialog dialog = new ApplyPatchDifferentiatedDialog(
|
||||
|
||||
Reference in New Issue
Block a user