Search in sources :

Example 6 with ArchiveFileType

use of com.intellij.ide.highlighter.ArchiveFileType in project intellij-community by JetBrains.

the class DiffContentFactoryImpl method createBinaryImpl.

@NotNull
private static DiffContent createBinaryImpl(@Nullable Project project, @NotNull byte[] content, @NotNull FileType type, @NotNull String fileName, @Nullable VirtualFile highlightFile) throws IOException {
    // workaround - our JarFileSystem and decompilers can't process non-local files
    boolean useTemporalFile = type instanceof ArchiveFileType || BinaryFileTypeDecompilers.INSTANCE.forFileType(type) != null;
    VirtualFile file;
    if (useTemporalFile) {
        file = createTemporalFile(project, "tmp", fileName, content);
    } else {
        file = new BinaryLightVirtualFile(fileName, type, content);
        file.setWritable(false);
    }
    return new FileContentImpl(project, file, highlightFile);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) BinaryLightVirtualFile(com.intellij.testFramework.BinaryLightVirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) BinaryLightVirtualFile(com.intellij.testFramework.BinaryLightVirtualFile) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ArchiveFileType

use of com.intellij.ide.highlighter.ArchiveFileType in project intellij-community by JetBrains.

the class CompositeDiffTool method chooseTool.

@Nullable
private DiffTool chooseTool(DiffRequest data) {
    final DiffContent[] contents = data.getContents();
    if (contents.length == 2) {
        final FileType type1 = contents[0].getContentType();
        final FileType type2 = contents[1].getContentType();
        if (type1 == type2 && type1 instanceof UIBasedFileType) {
            return BinaryDiffTool.INSTANCE;
        }
        //todo[kb] register or not this instance in common diff tools ?
        if (type1 == type2 && type1 instanceof ArchiveFileType) {
            return ArchiveDiffTool.INSTANCE;
        }
    }
    for (DiffTool tool : myTools) {
        if (tool.canShow(data))
            return tool;
    }
    return null;
}
Also used : UIBasedFileType(com.intellij.openapi.fileTypes.UIBasedFileType) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) FileType(com.intellij.openapi.fileTypes.FileType) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) UIBasedFileType(com.intellij.openapi.fileTypes.UIBasedFileType) DiffTool(com.intellij.openapi.diff.DiffTool) DiffContent(com.intellij.openapi.diff.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with ArchiveFileType

use of com.intellij.ide.highlighter.ArchiveFileType in project intellij-community by JetBrains.

the class ArchiveDiffTool method canShow.

@Override
public boolean canShow(DiffRequest request) {
    final DiffContent[] contents = request.getContents();
    final DialogWrapper instance = DialogWrapper.findInstance(IdeFocusManager.getInstance(request.getProject()).getFocusOwner());
    if (instance != null && instance.isModal())
        return false;
    if (contents.length == 2) {
        final VirtualFile file1 = contents[0].getFile();
        final VirtualFile file2 = contents[1].getFile();
        if (file1 != null && file2 != null) {
            final FileType type1 = contents[0].getContentType();
            final FileType type2 = contents[1].getContentType();
            return type1 == type2 && type1 instanceof ArchiveFileType;
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) FileType(com.intellij.openapi.fileTypes.FileType) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 9 with ArchiveFileType

use of com.intellij.ide.highlighter.ArchiveFileType in project intellij-community by JetBrains.

the class CompareFiles method getDiffRequest.

@Nullable
private static DiffRequest getDiffRequest(Project project, VirtualFile[] files) {
    if (files == null || files.length != 2)
        return null;
    if (files[0].isDirectory() || files[1].isDirectory() || files[0].getFileType() instanceof ArchiveFileType || files[1].getFileType() instanceof ArchiveFileType) {
        return null;
    }
    String title = DiffBundle.message("diff.element.qualified.name.vs.element.qualified.name.dialog.title", getVirtualFileContentTitle(files[0]), getVirtualFileContentTitle(files[1]));
    SimpleDiffRequest diffRequest = DiffContentFactory.compareVirtualFiles(project, files[0], files[1], title);
    if (diffRequest == null)
        return null;
    diffRequest.setContentTitles(getVirtualFileContentTitle(files[0]), getVirtualFileContentTitle(files[1]));
    return diffRequest;
}
Also used : ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) SimpleDiffRequest(com.intellij.openapi.diff.SimpleDiffRequest) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with ArchiveFileType

use of com.intellij.ide.highlighter.ArchiveFileType in project android by JetBrains.

the class AndroidSdkUtils method checkSdkRoots.

public static boolean checkSdkRoots(@NotNull Sdk sdk, @NotNull IAndroidTarget target, boolean forMaven) {
    String homePath = sdk.getHomePath();
    if (homePath == null) {
        return false;
    }
    AndroidSdks androidSdks = AndroidSdks.getInstance();
    AndroidSdkAdditionalData sdkAdditionalData = androidSdks.getAndroidSdkAdditionalData(sdk);
    Sdk javaSdk = sdkAdditionalData != null ? sdkAdditionalData.getJavaSdk() : null;
    if (javaSdk == null) {
        return false;
    }
    Set<VirtualFile> filesInSdk = Sets.newHashSet(sdk.getRootProvider().getFiles(CLASSES));
    List<VirtualFile> platformAndAddOnJars = androidSdks.getPlatformAndAddOnJars(target);
    for (VirtualFile file : platformAndAddOnJars) {
        if (filesInSdk.contains(file) == forMaven) {
            return false;
        }
    }
    boolean containsJarFromJdk = false;
    for (VirtualFile file : javaSdk.getRootProvider().getFiles(CLASSES)) {
        if (file.getFileType() instanceof ArchiveFileType && filesInSdk.contains(file)) {
            containsJarFromJdk = true;
        }
    }
    return containsJarFromJdk == forMaven;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) ModuleRootModificationUtil.setModuleSdk(com.intellij.openapi.roots.ModuleRootModificationUtil.setModuleSdk) Sdk(com.intellij.openapi.projectRoots.Sdk)

Aggregations

ArchiveFileType (com.intellij.ide.highlighter.ArchiveFileType)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Nullable (org.jetbrains.annotations.Nullable)4 FileType (com.intellij.openapi.fileTypes.FileType)2 Module (com.intellij.openapi.module.Module)2 Library (com.intellij.openapi.roots.libraries.Library)2 HashSet (java.util.HashSet)2 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)1 DiffContent (com.intellij.openapi.diff.DiffContent)1 DiffTool (com.intellij.openapi.diff.DiffTool)1 SimpleDiffRequest (com.intellij.openapi.diff.SimpleDiffRequest)1 UIBasedFileType (com.intellij.openapi.fileTypes.UIBasedFileType)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ModuleRootModificationUtil.setModuleSdk (com.intellij.openapi.roots.ModuleRootModificationUtil.setModuleSdk)1 OrderRootType (com.intellij.openapi.roots.OrderRootType)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 JarFileSystem (com.intellij.openapi.vfs.JarFileSystem)1 PsiDirectory (com.intellij.psi.PsiDirectory)1