Search in sources :

Example 31 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class CompileQrcAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    assert vFiles != null;
    Module module = e.getData(LangDataKeys.MODULE);
    String path = QtFileType.findQtTool(module, "pyrcc4");
    if (path == null) {
        path = QtFileType.findQtTool(module, "pyside-rcc");
    }
    if (path == null) {
        Messages.showErrorDialog(project, "Could not find pyrcc4 or pyside-rcc for selected Python interpreter", "Compile .qrc file");
        return;
    }
    CompileQrcDialog dialog = new CompileQrcDialog(project, vFiles);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return;
    }
    GeneralCommandLine cmdLine = new GeneralCommandLine(path, "-o", dialog.getOutputPath());
    for (VirtualFile vFile : vFiles) {
        cmdLine.addParameter(vFile.getPath());
    }
    try {
        ProcessHandler process = new OSProcessHandler(cmdLine);
        ProcessTerminatedListener.attach(process);
        new RunContentExecutor(project, process).withTitle("Compile .qrc").run();
    } catch (ExecutionException ex) {
        Messages.showErrorDialog(project, "Error running " + path + ": " + ex.getMessage(), "Compile .qrc file");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) RunContentExecutor(com.intellij.execution.RunContentExecutor) Module(com.intellij.openapi.module.Module) ExecutionException(com.intellij.execution.ExecutionException)

Example 32 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class PyDirectoryIconProvider method isSpecialDirectory.

private static boolean isSpecialDirectory(@NotNull PsiDirectory directory) {
    final VirtualFile vFile = directory.getVirtualFile();
    if (FileIndexFacade.getInstance(directory.getProject()).isExcludedFile(vFile)) {
        return true;
    }
    final Module module = ModuleUtilCore.findModuleForPsiElement(directory);
    return module == null || PyUtil.getSourceRoots(module).contains(vFile);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Module(com.intellij.openapi.module.Module)

Example 33 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class RestLanguageSubstitutor method getLanguage.

@Override
public Language getLanguage(@NotNull final VirtualFile vFile, @NotNull final Project project) {
    final Module module = ModuleUtilCore.findModuleForFile(vFile, project);
    if (module == null)
        return null;
    boolean txtIsRst = ReSTService.getInstance(module).txtIsRst();
    if (txtIsRst)
        return RestLanguage.INSTANCE;
    return null;
}
Also used : Module(com.intellij.openapi.module.Module)

Example 34 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class RestPythonUtil method updateSphinxQuickStartRequiredAction.

public static Presentation updateSphinxQuickStartRequiredAction(final AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project != null) {
        Module module = e.getData(LangDataKeys.MODULE);
        if (module == null) {
            Module[] modules = ModuleManager.getInstance(project).getModules();
            module = modules.length == 0 ? null : modules[0];
        }
        if (module != null) {
            final Sdk sdk = PythonSdkType.findPythonSdk(module);
            if (sdk != null) {
                final List<PyPackage> packages = PyPackageManager.getInstance(sdk).getPackages();
                final PyPackage sphinx = packages != null ? PyPackageUtil.findPackage(packages, "Sphinx") : null;
                presentation.setEnabled(sphinx != null);
            }
        }
    }
    return presentation;
}
Also used : Project(com.intellij.openapi.project.Project) PyPackage(com.jetbrains.python.packaging.PyPackage) Sdk(com.intellij.openapi.projectRoots.Sdk) Presentation(com.intellij.openapi.actionSystem.Presentation) Module(com.intellij.openapi.module.Module)

Example 35 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class SphinxConfigurationProducer method createConfigurationByElement.

protected RunnerAndConfigurationSettings createConfigurationByElement(final Location location, final ConfigurationContext context) {
    PsiElement element = location.getPsiElement();
    if (!(element instanceof PsiDirectory))
        return null;
    mySourceFile = (PsiDirectory) element;
    boolean hasRstFile = false;
    boolean hasConf = false;
    for (PsiFile file : mySourceFile.getFiles()) {
        if ("conf.py".equals(file.getName()))
            hasConf = true;
        if (file instanceof RestFile) {
            hasRstFile = true;
        }
    }
    if (!hasRstFile || !hasConf)
        return null;
    final Project project = mySourceFile.getProject();
    RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
    SphinxRunConfiguration configuration = (SphinxRunConfiguration) settings.getConfiguration();
    final VirtualFile vFile = mySourceFile.getVirtualFile();
    configuration.setInputFile(vFile.getPath());
    configuration.setName(((PsiDirectory) element).getName());
    if (configuration.getTask().isEmpty())
        configuration.setTask("html");
    final VirtualFile parent = vFile.getParent();
    if (parent != null) {
        configuration.setWorkingDirectory(parent.getPath());
    }
    configuration.setName(configuration.suggestedName());
    Module module = ModuleUtil.findModuleForPsiElement(element);
    if (module != null) {
        configuration.setUseModuleSdk(true);
        configuration.setModule(module);
    }
    return settings;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) RestFile(com.jetbrains.rest.RestFile) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) PsiElement(com.intellij.psi.PsiElement)

Aggregations

Module (com.intellij.openapi.module.Module)1911 VirtualFile (com.intellij.openapi.vfs.VirtualFile)585 Project (com.intellij.openapi.project.Project)381 NotNull (org.jetbrains.annotations.NotNull)331 Nullable (org.jetbrains.annotations.Nullable)268 File (java.io.File)185 PsiFile (com.intellij.psi.PsiFile)147 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)134 ArrayList (java.util.ArrayList)118 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)112 Sdk (com.intellij.openapi.projectRoots.Sdk)95 PsiElement (com.intellij.psi.PsiElement)89 PsiDirectory (com.intellij.psi.PsiDirectory)77 ModuleManager (com.intellij.openapi.module.ModuleManager)65 PsiClass (com.intellij.psi.PsiClass)65 IOException (java.io.IOException)61 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)57 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)57 List (java.util.List)57 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)51