mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-136799 diff: change action title depending on selected file type
This commit is contained in:
@@ -42,8 +42,31 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
|
||||
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
|
||||
String text = getTemplatePresentation().getText();
|
||||
if (files != null && files.length == 1) text += "...";
|
||||
String text = "Compare Files";
|
||||
if (files != null && files.length == 1) {
|
||||
text = "Compare With...";
|
||||
}
|
||||
else if (files != null && files.length == 2) {
|
||||
Type type1 = getType(files[0]);
|
||||
Type type2 = getType(files[1]);
|
||||
|
||||
if (type1 != type2) {
|
||||
text = "Compare";
|
||||
}
|
||||
else {
|
||||
switch (type1) {
|
||||
case FILE:
|
||||
text = "Compare Files";
|
||||
break;
|
||||
case DIRECTORY:
|
||||
text = "Compare Directories";
|
||||
break;
|
||||
case ARCHIEVE:
|
||||
text = "Compare Archieves";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
e.getPresentation().setText(text);
|
||||
}
|
||||
|
||||
@@ -93,7 +116,9 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
private static VirtualFile getOtherFile(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
FileChooserDescriptor descriptor;
|
||||
String key;
|
||||
if (file.isDirectory() || file.getFileType() instanceof ArchiveFileType) {
|
||||
|
||||
Type type = getType(file);
|
||||
if (type == Type.DIRECTORY || type == Type.ARCHIEVE) {
|
||||
descriptor = new FileChooserDescriptor(false, true, true, false, false, false);
|
||||
key = LAST_USED_FOLDER_KEY;
|
||||
}
|
||||
@@ -121,4 +146,14 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
if (project == null) return;
|
||||
PropertiesComponent.getInstance(project).setValue(key, file.getPath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Type getType(@Nullable VirtualFile file) {
|
||||
if (file == null) return Type.FILE;
|
||||
if (file.isDirectory()) return Type.DIRECTORY;
|
||||
if (file.getFileType() instanceof ArchiveFileType) return Type.ARCHIEVE;
|
||||
return Type.FILE;
|
||||
}
|
||||
|
||||
private enum Type {FILE, DIRECTORY, ARCHIEVE}
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ action.NewClass.text=Java Class
|
||||
action.NewFile.text=File
|
||||
action.NewDir.text=Directory/Package
|
||||
action.NewFromTemplate.text=From Template
|
||||
action.CompareTwoFiles.text=Compare Two _Files
|
||||
action.CompareTwoFiles.description=Compare two selected files
|
||||
action.CompareTwoFiles.text=Compare _Files
|
||||
action.CompareTwoFiles.description=Compare two selected files or folders
|
||||
action.CompareFileWithEditor.text=Co_mpare File with Editor
|
||||
action.CompareFileWithEditor.description=Compare selected file with editor
|
||||
action.ShowQuickDocAtPinnedWindowFromTooltip.text=Full documentation in a pinned window
|
||||
|
||||
Reference in New Issue
Block a user