当前位置: 首页>>代码示例>>Java>>正文


Java ModuleManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.module.ModuleManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleManager.getInstance方法的具体用法?Java ModuleManager.getInstance怎么用?Java ModuleManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.module.ModuleManager的用法示例。


在下文中一共展示了ModuleManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAndroidSdkPath

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public static String getAndroidSdkPath(Project project) {
    ModuleManager manager = ModuleManager.getInstance(project);
    String androidSdkPath = null;

    for (Module module : manager.getModules()) {
        if (androidSdkPath != null) {
            break;
        }
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

        if (sdk != null && sdk.getHomePath() != null) {
            File file = new File(sdk.getHomePath());
            String[] contents = file.list();

            if (contents != null) {
                for (String path : contents) {
                    if (path.equals("build-tools")) {
                        androidSdkPath = sdk.getHomePath();
                        break;
                    }
                }
            }
        }
    }
    return androidSdkPath;
}
 
开发者ID:andreyfomenkov,项目名称:green-cat,代码行数:27,代码来源:Utils.java

示例2: syncSucceeded

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
@Override
public void syncSucceeded(@NotNull Project project) {
  disposeOnTearDown(project);
  // Verify that project was imported correctly.
  assertEquals(myProjectName, project.getName());
  assertEquals(myProjectRootDir.getPath(), project.getBasePath());

  // Verify that '.idea' directory was created.
  File ideaProjectDir = new File(myProjectRootDir, Project.DIRECTORY_STORE_FOLDER);
  assertTrue(ideaProjectDir.isDirectory());

  // Verify that module was created.
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  Module[] modules = moduleManager.getModules();
  assertEquals(1, modules.length);
  assertEquals(myModule.getName(), modules[0].getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GradleProjectImporterTest.java

示例3: findPathOfSdkMissingOrEmptyAddonsFolder

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
@Nullable
private static File findPathOfSdkMissingOrEmptyAddonsFolder(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
    if (moduleSdk != null && isAndroidSdk(moduleSdk)) {
      String homePath = moduleSdk.getHomePath();
      if (homePath != null) {
        File sdkHomeDirPath = new File(FileUtil.toSystemDependentName(homePath));
        File addonsDir = new File(sdkHomeDirPath, SdkConstants.FD_ADDONS);
        if (!addonsDir.isDirectory() || FileUtil.notNullize(addonsDir.listFiles()).length == 0) {
          return sdkHomeDirPath;
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FailedToParseSdkErrorHandler.java

示例4: calculateRoots

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private void calculateRoots() {
  final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  // assertion for read access inside
  final Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
    public Module[] compute() {
      return moduleManager.getModules();
    }
  });

  final TreeSet<VirtualFile> checkSet = new TreeSet<VirtualFile>(FilePathComparator.getInstance());
  myRoots = new HashSet<VirtualFile>();
  myRoots.addAll(myInitialRoots);
  checkSet.addAll(myInitialRoots);
  for (Module module : modules) {
    final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
    for (VirtualFile file : files) {
      final VirtualFile floor = checkSet.floor(file);
      if (floor != null) {
        myModulesSet.put(file, module.getName());
        myRoots.add(file);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:VcsStructureChooser.java

示例5: configureProject

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, final Ref<Module> moduleRef) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  if (modules.length == 0) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        String moduleName = baseDir.getName().replace(":", "");     // correct module name when opening root of drive as project (RUBY-5181)
        String imlName = baseDir.getPath() + "/.idea/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
        ModuleTypeManager instance = ModuleTypeManager.getInstance();
        String id = instance == null ? "unknown" : instance.getDefaultModuleType().getId();
        final Module module = moduleManager.newModule(imlName, id);
        ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
        ModifiableRootModel rootModel = rootManager.getModifiableModel();
        if (rootModel.getContentRoots().length == 0) {
          rootModel.addContentEntry(baseDir);
        }
        rootModel.inheritSdk();
        rootModel.commit();
        moduleRef.set(module);
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PlatformProjectConfigurator.java

示例6: generateSources

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public void generateSources() {
  BuildMode buildMode = BuildMode.SOURCE_GEN;
  setProjectBuildMode(buildMode);

  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  List<String> tasks = findTasksToExecute(moduleManager.getModules(), buildMode, TestCompileType.NONE);

  executeTasks(tasks);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GradleInvoker.java

示例7: removeGenModule

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private static void removeGenModule(@NotNull final ModifiableRootModel model, @NotNull Ref<Boolean> modelChangedFlag) {
  final String genModuleName = getGenModuleName(model.getModule());
  final Project project = model.getProject();
  final ModuleManager moduleManager = ModuleManager.getInstance(project);

  final Module genModule = moduleManager.findModuleByName(genModuleName);
  if (genModule == null) {
    return;
  }

  for (OrderEntry entry : model.getOrderEntries()) {
    if (entry instanceof ModuleOrderEntry &&
        genModuleName.equals(((ModuleOrderEntry)entry).getModuleName())) {
      model.removeOrderEntry(entry);
      modelChangedFlag.set(true);
    }
  }
  final VirtualFile moduleFile = genModule.getModuleFile();
  moduleManager.disposeModule(genModule);

  if (moduleFile != null) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            try {
              moduleFile.delete(project);
            }
            catch (IOException e) {
              LOG.error(e);
            }
          }
        });
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AndroidCompileUtil.java

示例8: findGradleProjectModule

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
/**
 * @see #isGradleProjectModule(Module)
 */
@Nullable
public static Module findGradleProjectModule(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  Module[] modules = moduleManager.getModules();
  if (modules.length == 1) {
    return modules[0];
  }
  for (Module module : modules) {
    if (isGradleProjectModule(module)) {
      return module;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:Projects.java

示例9: isUniqueModuleName

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private boolean isUniqueModuleName(@NotNull String moduleName) {
  if (myProject == null) {
    return true;
  }
  // Check our modules
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  for (Module m : moduleManager.getModules()) {
    if (m.getName().equalsIgnoreCase(moduleName)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ConfigureAndroidModuleStep.java

示例10: isIdeaAndroidProject

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
/**
 * Indicates whether the give project is a legacy IDEA Android project (which is deprecated in Android Studio.)
 *
 * @param project the given project.
 * @return {@code true} if the given project is a legacy IDEA Android project; {@code false} otherwise.
 */
public static boolean isIdeaAndroidProject(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    if (AndroidFacet.getInstance(module) != null && !isBuildWithGradle(module)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:Projects.java

示例11: delete

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private void delete(@NotNull Module module) {
  if (module.isDisposed()) {
    return;
  }
  ModuleManager moduleManager = ModuleManager.getInstance(module.getProject());
  ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
  try {
    modifiableModel.disposeModule(module);
  }
  finally {
    modifiableModel.commit();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AndroidProjectStructureConfigurable.java

示例12: testComputeModuleName

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public void testComputeModuleName() throws Exception {
  ModuleManager manager = ModuleManager.getInstance(getProject());
  myStep = new ConfigureAndroidModuleStep(myState, getProject(), null, TemplateWizardStep.NONE);
  Module module = manager.getModules()[0];
  assertEquals("app", module.getName());

  myState.myHidden.add(ATTR_PROJECT_LOCATION);
  myState.put(ATTR_IS_LIBRARY_MODULE, true);
  // "Lib" and "lib2" already exist
  assertEquals("lib3", myStep.computeModuleName());

  myState.put(ATTR_IS_LIBRARY_MODULE, false);
  // "app" already exists
  assertEquals("app2", myStep.computeModuleName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ConfigureAndroidModuleStepTest.java

示例13: rebuild

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public void rebuild() {
  BuildMode buildMode = BuildMode.REBUILD;
  setProjectBuildMode(buildMode);
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  List<String> tasks = findTasksToExecute(moduleManager.getModules(), buildMode, TestCompileType.NONE);
  executeTasks(tasks);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:GradleInvoker.java

示例14: isBuildWithGradle

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
/**
 * Indicates whether Gradle is used to build this project.
 * Note: {@link #isGradleProject(Project)} indicates whether a project has a IdeaAndroidProject model.
 * That method should be preferred in almost all cases. Use this method only if you explicitly need to check whether the model was
 * generated by Gradle (this will exclude models generated by other build systems.)
 */
public static boolean isBuildWithGradle(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    if (isBuildWithGradle(module)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:Projects.java

示例15: cleanProject

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public void cleanProject() {
  setProjectBuildMode(BuildMode.CLEAN);

  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  // "Clean" also generates sources.
  List<String> tasks = findTasksToExecute(moduleManager.getModules(), BuildMode.SOURCE_GEN, TestCompileType.NONE);
  tasks.add(0, GradleBuilds.CLEAN_TASK_NAME);
  executeTasks(tasks);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GradleInvoker.java


注:本文中的com.intellij.openapi.module.ModuleManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。