Search in sources :

Example 6 with Module

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

the class GrSelectModuleAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return;
    GroovyConsoleUtil.selectModuleAndRun(project, module -> {
        final Module existingModule = myProjectConsole.getSelectedModule(myFile);
        if (module.equals(existingModule))
            return;
        final GroovyConsole existingConsole = myFile.getUserData(GroovyConsole.GROOVY_CONSOLE);
        if (existingConsole != null)
            existingConsole.stop();
        myProjectConsole.setFileModule(myFile, module);
        myFile.putUserData(GroovyConsole.GROOVY_CONSOLE, null);
        ProjectView.getInstance(project).refresh();
    }, e.getDataContext());
}
Also used : Project(com.intellij.openapi.project.Project) GroovyConsole(org.jetbrains.plugins.groovy.console.GroovyConsole) Module(com.intellij.openapi.module.Module)

Example 7 with Module

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

the class GrSelectModuleAction method update.

@Override
public void update(AnActionEvent e) {
    if (myProjectConsole.isProjectConsole(myFile)) {
        final Module module = myProjectConsole.getSelectedModule(myFile);
        e.getPresentation().setText(getText(module));
    } else {
        e.getPresentation().setVisible(false);
    }
}
Also used : Module(com.intellij.openapi.module.Module)

Example 8 with Module

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

the class MavenProjectImporter method formatModules.

private static String formatModules(final Collection<Module> modules) {
    StringBuilder res = new StringBuilder();
    int i = 0;
    for (Module module : modules) {
        res.append('\'').append(module.getName()).append("'\n");
        if (++i > 20)
            break;
    }
    if (i > 20) {
        res.append("\n ... and other ").append(modules.size() - 20).append(" modules");
    }
    return res.toString();
}
Also used : Module(com.intellij.openapi.module.Module)

Example 9 with Module

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

the class MavenRootModelAdapter method addModuleDependency.

public void addModuleDependency(@NotNull String moduleName, @NotNull DependencyScope scope, boolean testJar) {
    Module m = findModuleByName(moduleName);
    ModuleOrderEntry e;
    if (m != null) {
        e = myRootModel.addModuleOrderEntry(m);
    } else {
        AccessToken accessToken = ReadAction.start();
        try {
            e = myRootModel.addInvalidModuleEntry(moduleName);
        } finally {
            accessToken.finish();
        }
    }
    e.setScope(scope);
    if (testJar) {
        ((ModuleOrderEntryImpl) e).setProductionOnTestDependency(true);
    }
    if (myOrderEntriesBeforeJdk.contains(moduleName)) {
        moveLastOrderEntryBeforeJdk();
    }
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) Module(com.intellij.openapi.module.Module) ModuleOrderEntryImpl(com.intellij.openapi.roots.impl.ModuleOrderEntryImpl)

Example 10 with Module

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

the class MavenProjectImporter method ensureModuleCreated.

private boolean ensureModuleCreated(MavenProject project) {
    if (myMavenProjectToModule.get(project) != null)
        return false;
    final String path = myMavenProjectToModulePath.get(project);
    // for some reason newModule opens the existing iml file, so we
    // have to remove it beforehand.
    deleteExistingImlFile(path);
    final Module module = myModuleModel.newModule(path, project.getModuleType().getId());
    myMavenProjectToModule.put(project, module);
    myCreatedModules.add(module);
    return true;
}
Also used : Module(com.intellij.openapi.module.Module)

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