mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed WI-6879 Don't invoke 'Mark as plain text' action in dispatch thread or wrap it with progress(ui freeeze)
This commit is contained in:
+13
-8
@@ -52,20 +52,25 @@ public class EnforcedPlainTextFileTypeManager extends PersistentFileSetManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void markAsPlainText(VirtualFile file) {
|
||||
if (addFile(file)) {
|
||||
updateIndex(file);
|
||||
public void markAsPlainText(VirtualFile... files) {
|
||||
for (VirtualFile file : files) {
|
||||
if (addFile(file)) {
|
||||
FileBasedIndex.getInstance().requestReindex(file);
|
||||
}
|
||||
}
|
||||
fireRootsChanged();
|
||||
}
|
||||
|
||||
public void unmarkPlainText(VirtualFile file) {
|
||||
if (removeFile(file)) {
|
||||
updateIndex(file);
|
||||
public void unmarkPlainText(VirtualFile... files) {
|
||||
for (VirtualFile file : files) {
|
||||
if (removeFile(file)) {
|
||||
FileBasedIndex.getInstance().requestReindex(file);
|
||||
}
|
||||
}
|
||||
fireRootsChanged();
|
||||
}
|
||||
|
||||
private static void updateIndex(VirtualFile file) {
|
||||
FileBasedIndex.getInstance().requestReindex(file);
|
||||
private static void fireRootsChanged() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
+7
-6
@@ -21,7 +21,9 @@ import com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
@@ -32,16 +34,15 @@ public class MarkAsOriginalTypeAction extends AnAction {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final VirtualFile[] selectedFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
|
||||
if (selectedFiles == null || selectedFiles.length == 0) return;
|
||||
Collection<VirtualFile> filesToUnmark = new ArrayList<VirtualFile>();
|
||||
for (VirtualFile file : selectedFiles) {
|
||||
if (file != null && !file.isDirectory()) {
|
||||
unmarkPlainText(file);
|
||||
filesToUnmark.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void unmarkPlainText(@NotNull VirtualFile file) {
|
||||
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
|
||||
if (typeManager != null) typeManager.unmarkPlainText(file);
|
||||
assert typeManager != null;
|
||||
typeManager.unmarkPlainText(filesToUnmark.toArray(new VirtualFile[filesToUnmark.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-7
@@ -21,6 +21,9 @@ import com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
@@ -30,16 +33,18 @@ public class MarkAsPlainTextAction extends AnAction {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final VirtualFile[] selectedFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
|
||||
if (selectedFiles == null || selectedFiles.length == 0) return;
|
||||
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
|
||||
assert typeManager != null;
|
||||
Collection<VirtualFile> filesToMark = new ArrayList<VirtualFile>();
|
||||
for (VirtualFile file : selectedFiles) {
|
||||
if (file != null && !file.isDirectory()) {
|
||||
markAsPlainText(file);
|
||||
if (file != null &&
|
||||
!file.isDirectory() &&
|
||||
EnforcedPlainTextFileTypeManager.isApplicableFor(file) &&
|
||||
!typeManager.isMarkedAsPlainText(file)) {
|
||||
filesToMark.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void markAsPlainText(@NotNull VirtualFile file) {
|
||||
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
|
||||
if (typeManager != null && !typeManager.isMarkedAsPlainText(file)) typeManager.markAsPlainText(file);
|
||||
typeManager.markAsPlainText(filesToMark.toArray(new VirtualFile[filesToMark.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user