Search in sources :

Example 1 with WrappingVirtualFile

use of com.intellij.openapi.vfs.WrappingVirtualFile in project intellij-community by JetBrains.

the class ProjectStructureSelectInTarget method canSelect.

@Override
public boolean canSelect(final SelectInContext context) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
    final VirtualFile file = context.getVirtualFile();
    if (file instanceof WrappingVirtualFile) {
        final Object o = ((WrappingVirtualFile) file).getWrappedObject(context.getProject());
        return o instanceof Facet;
    }
    return fileIndex.isInContent(file) || fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file) || StdFileTypes.IDEA_MODULE.equals(file.getFileType()) && findModuleByModuleFile(context.getProject(), file) != null;
}
Also used : WrappingVirtualFile(com.intellij.openapi.vfs.WrappingVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) WrappingVirtualFile(com.intellij.openapi.vfs.WrappingVirtualFile)

Example 2 with WrappingVirtualFile

use of com.intellij.openapi.vfs.WrappingVirtualFile in project intellij-community by JetBrains.

the class ProjectStructureSelectInTarget method selectIn.

@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
    final Project project = context.getProject();
    final VirtualFile file = context.getVirtualFile();
    final Module module;
    final Facet facet;
    if (file instanceof WrappingVirtualFile) {
        final Object o = ((WrappingVirtualFile) file).getWrappedObject(project);
        facet = o instanceof Facet ? (Facet) o : null;
        module = facet == null ? null : facet.getModule();
    } else {
        Module moduleByIml = file.getFileType().equals(StdFileTypes.IDEA_MODULE) ? findModuleByModuleFile(project, file) : null;
        final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
        module = moduleByIml != null ? moduleByIml : fileIndex.getModuleForFile(file);
        facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
    }
    if (module != null || facet != null) {
        ApplicationManager.getApplication().invokeLater(() -> {
            if (facet != null) {
                ModulesConfigurator.showFacetSettingsDialog(facet, null);
            } else {
                ProjectSettingsService.getInstance(project).openModuleSettings(module);
            }
        });
        return;
    }
    final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, project);
    if (orderEntry != null) {
        ApplicationManager.getApplication().invokeLater(() -> ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry));
    }
}
Also used : WrappingVirtualFile(com.intellij.openapi.vfs.WrappingVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OrderEntry(com.intellij.openapi.roots.OrderEntry) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) WrappingVirtualFile(com.intellij.openapi.vfs.WrappingVirtualFile) Module(com.intellij.openapi.module.Module)

Aggregations

ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 WrappingVirtualFile (com.intellij.openapi.vfs.WrappingVirtualFile)2 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1