diff: enable "Clear Read-Only flag" dialog in Diff/MergeApplication
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 27 Aug 2015 10:22:33 +0000 (13:22 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 27 Aug 2015 10:45:05 +0000 (13:45 +0300)
platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java
platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java

index 7eba1ed668b7f56411c2a983f01ddcc67229e662..8a7b65eb2ce11a8e3b39f509b6feee6127681b06 100644 (file)
@@ -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();
   }
 
   //
index c5bd39e7a905572cea155c56c4e94fc09d30f433..987681a4fd35da9e2b97f2e851299c3f5c69a9fc 100644 (file)
@@ -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);
   }