diff: enable "Clear Read-Only flag" dialog in Diff/MergeApplication

This commit is contained in:
Aleksey Pivovarov
2015-08-27 13:45:05 +03:00
parent bbb2e5953a
commit aff91cc3f3
2 changed files with 7 additions and 5 deletions
@@ -56,6 +56,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.DialogWrapperDialog;
import com.intellij.openapi.ui.WindowWrapper;
import com.intellij.openapi.util.*;
@@ -797,15 +798,16 @@ public class DiffUtil {
@CalledInAwt
public static boolean makeWritable(@Nullable Project project, @NotNull Document document) {
if (document.isWritable()) return true;
if (project == null) return false;
return ReadonlyStatusHandler.ensureDocumentWritable(project, document);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file == null) return false;
return makeWritable(project, file);
}
@CalledInAwt
public static boolean makeWritable(@Nullable Project project, @NotNull VirtualFile file) {
if (file.isWritable()) return true;
if (project == null) return false;
return ReadonlyStatusHandler.ensureFilesWritable(project, file);
if (project == null) project = ProjectManager.getInstance().getDefaultProject();
return !ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(file).hasReadonlyFiles();
}
//
@@ -63,7 +63,7 @@ public abstract class ReadonlyStatusHandler {
return ensureFilesWritable(VfsUtilCore.toVirtualFileArray(files));
}
public static ReadonlyStatusHandler getInstance(Project project) {
public static ReadonlyStatusHandler getInstance(@NotNull Project project) {
return ServiceManager.getService(project, ReadonlyStatusHandler.class);
}