mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-22184 angular-ui-router: UnsupportedOperationException when press cmd+d - fix review comments and bug:
IDEA-158003 Compare Files no longer works with files in archives (jar, zip)
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.intellij.openapi.vfs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Irina.Chernushina on 7/4/2016.
|
||||||
|
*/
|
||||||
|
public interface VirtualFileWithoutContent {
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
|||||||
import com.intellij.openapi.actionSystem.Presentation;
|
import com.intellij.openapi.actionSystem.Presentation;
|
||||||
import com.intellij.openapi.project.DumbAware;
|
import com.intellij.openapi.project.DumbAware;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileWithoutContent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -48,6 +50,10 @@ abstract class BaseShowDiffAction extends AnAction implements DumbAware {
|
|||||||
|
|
||||||
protected abstract boolean isAvailable(@NotNull AnActionEvent e);
|
protected abstract boolean isAvailable(@NotNull AnActionEvent e);
|
||||||
|
|
||||||
|
protected static boolean hasContent(VirtualFile file) {
|
||||||
|
return ! (file instanceof VirtualFileWithoutContent);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected abstract DiffRequest getDiffRequest(@NotNull AnActionEvent e);
|
protected abstract DiffRequest getDiffRequest(@NotNull AnActionEvent e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class CompareFileWithEditorAction extends BaseShowDiffAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canCompare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
|
private static boolean canCompare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
|
||||||
return file1.isValid() && file2.isValid() && !file1.equals(file2);
|
return file1.isValid() && file2.isValid() && !file1.equals(file2) && hasContent(file1) && hasContent(file2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -83,20 +83,16 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (files.length == 1) {
|
if (files.length == 1) {
|
||||||
return isValidAndLocal(files[0]);
|
return hasContent(files[0]);
|
||||||
}
|
}
|
||||||
else if (files.length == 2) {
|
else if (files.length == 2) {
|
||||||
return isValidAndLocal(files[0]) && isValidAndLocal(files[1]);
|
return hasContent(files[0]) && hasContent(files[1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidAndLocal(VirtualFile file) {
|
|
||||||
return file.isValid() && file.isInLocalFileSystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
|
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
|
||||||
|
|||||||
+2
-2
@@ -22,8 +22,8 @@ import com.intellij.lang.properties.psi.PropertiesFile;
|
|||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileWithoutContent;
|
||||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||||
import com.intellij.util.Function;
|
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
* @author Alexey
|
* @author Alexey
|
||||||
*/
|
*/
|
||||||
@Presentation(icon = "AllIcons.Nodes.ResourceBundle")
|
@Presentation(icon = "AllIcons.Nodes.ResourceBundle")
|
||||||
public class ResourceBundleAsVirtualFile extends VirtualFile {
|
public class ResourceBundleAsVirtualFile extends VirtualFile implements VirtualFileWithoutContent {
|
||||||
private final ResourceBundle myResourceBundle;
|
private final ResourceBundle myResourceBundle;
|
||||||
|
|
||||||
public ResourceBundleAsVirtualFile(@NotNull final ResourceBundle resourceBundle) {
|
public ResourceBundleAsVirtualFile(@NotNull final ResourceBundle resourceBundle) {
|
||||||
|
|||||||
Reference in New Issue
Block a user