本文整理汇总了Java中com.intellij.openapi.module.ModuleManager类的典型用法代码示例。如果您正苦于以下问题:Java ModuleManager类的具体用法?Java ModuleManager怎么用?Java ModuleManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModuleManager类属于com.intellij.openapi.module包,在下文中一共展示了ModuleManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _getVirtualFile
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
public static VirtualFile _getVirtualFile(Project project, String file) {
VirtualFile result = findFileByFQName(file, project);
if (result == null) {
final Set<VirtualFile> candidates = new HashSet<>();
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
findFileInModule(candidates, module, file);
}
int currWeight = 0;
for (VirtualFile candidate : candidates) {
final int newWeight = weight(candidate, file);
if (result == null || newWeight > currWeight) {
currWeight = newWeight;
result = candidate;
}
}
}
return result;
}
示例2: 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;
}
示例3: getAlreadyOpenedModules
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@NotNull
protected Set<HybrisModuleDescriptor> getAlreadyOpenedModules(@NotNull final Project project) {
Validate.notNull(project);
final HybrisModuleDescriptorFactory hybrisModuleDescriptorFactory = ServiceManager.getService(
HybrisModuleDescriptorFactory.class
);
final Set<HybrisModuleDescriptor> existingModules = new THashSet<HybrisModuleDescriptor>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
try {
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
if (!ArrayUtils.isEmpty(contentRoots)) {
existingModules.add(hybrisModuleDescriptorFactory.createDescriptor(
VfsUtil.virtualToIoFile(contentRoots[0]), this
));
}
} catch (HybrisConfigurationException e) {
LOG.error(e);
}
}
return existingModules;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:DefaultHybrisProjectDescriptor.java
示例4: moveMavenModulesToGroup
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
private void moveMavenModulesToGroup(
final Project project,
final List<Module> mavenModules,
final String[] rootGroup
) {
AccessToken token = null;
final ModifiableModuleModel modifiableModuleModel;
try {
token = ApplicationManager.getApplication().acquireReadActionLock();
modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : mavenModules) {
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.MAVEN.name());
final String[] groupPath = modifiableModuleModel.getModuleGroupPath(module);
modifiableModuleModel.setModuleGroupPath(module, ArrayUtils.addAll(rootGroup, groupPath));
}
} finally {
if (token != null) {
token.finish();
}
}
ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModuleModel::commit));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:DefaultMavenConfigurator.java
示例5: configure
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@Override
public void configure(
final Project project,
final List<HybrisModuleDescriptor> allModules
) {
// todo: remove "UNLOADED" mechanism completely. It is temporary disabled now, so this list should be empty
final List<String> unloadedModuleNames = allModules
.stream()
.filter(e -> e.getImportStatus() == HybrisModuleDescriptor.IMPORT_STATUS.UNLOADED)
.map(HybrisModuleDescriptor::getName)
.collect(Collectors.toList());
final Set<String> unusedModuleNames = allModules
.stream()
.filter(e -> e.getImportStatus() == HybrisModuleDescriptor.IMPORT_STATUS.UNUSED)
.map(HybrisModuleDescriptor::getName)
.collect(Collectors.toSet());
ApplicationManager.getApplication().invokeAndWait(() -> {
ModuleManager.getInstance(project).setUnloadedModules(unloadedModuleNames);
HybrisProjectSettingsComponent.getInstance(project).getState().setUnusedExtensions(unusedModuleNames);
});
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:DefaultLoadedConfigurator.java
示例6: moveGradleModulesToGroup
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
private void moveGradleModulesToGroup(
final Project project,
final List<Module> gradleModules,
final String[] gradleGroup
) {
final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : gradleModules) {
if (module == null) {
// https://youtrack.jetbrains.com/issue/IDEA-177512
continue;
}
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.GRADLE.name());
modifiableModuleModel.setModuleGroupPath(module, gradleGroup);
}
AccessToken token = null;
try {
token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
modifiableModuleModel.commit();
} finally {
if (token != null) {
token.finish();
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:DefaultGradleConfigurator.java
示例7: moveEclipseModulesToGroup
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
private void moveEclipseModulesToGroup(
@NotNull final Project project,
@NotNull final List<Module> eclipseModules,
@Nullable final String[] eclipseGroup
) {
final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : eclipseModules) {
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.ECLIPSE.name());
modifiableModuleModel.setModuleGroupPath(module, eclipseGroup);
}
AccessToken token = null;
try {
token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
modifiableModuleModel.commit();
} finally {
if (token != null) {
token.finish();
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:DefaultEclipseConfigurator.java
示例8: removeOldProjectData
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
private static void removeOldProjectData(@NotNull final Project project) {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : moduleModel.getModules()) {
moduleModel.disposeModule(module);
}
final LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(project).getModifiableModel();
for (Library library : libraryModel.getLibraries()) {
libraryModel.removeLibrary(library);
}
ApplicationManager.getApplication().runWriteAction(() -> {
moduleModel.commit();
libraryModel.commit();
});
final GradleSupport gradleSupport = GradleSupport.getInstance();
if (gradleSupport != null) {
gradleSupport.clearLinkedProjectSettings(project);
}
final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);
for (AntBuildFile antBuildFile : antConfiguration.getBuildFiles()) {
antConfiguration.removeBuildFile(antBuildFile);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:ProjectRefreshAction.java
示例9: fromFQN
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@Nullable
public static ModuleDepDiagramItem fromFQN(@NotNull final String fqn, @NotNull final Project project) {
String moduleName = null;
boolean customExtension = false;
if (fqn.startsWith(MODULE_PREFIX)) {
moduleName = fqn.substring(MODULE_PREFIX.length());
customExtension = false;
} else if (fqn.startsWith(CUSTOM_MODULE_PREFIX)) {
moduleName = fqn.substring(CUSTOM_MODULE_PREFIX.length());
customExtension = true;
}
if (moduleName == null) {
return new ModuleDepDiagramItem(null, false);
}
final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName);
return module == null ? null : new ModuleDepDiagramItem(module, customExtension);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:19,代码来源:ModuleDepDiagramItem.java
示例10: isPotentiallyHybrisProject
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@Override
public boolean isPotentiallyHybrisProject(@NotNull final Project project) {
final Module[] modules = ModuleManager.getInstance(project).getModules();
if (modules.length == 0) {
return false;
}
final ArrayList<String> moduleNames = Arrays.stream(modules)
.map(Module::getName)
.collect(Collectors.toCollection(ArrayList::new));
final Collection<String> acceleratorNames = Arrays.asList("*cockpits", "*core", "*facades", "*storefront");
if (matchAllModuleNames(acceleratorNames, moduleNames)) {
return true;
}
final Collection<String> webservicesNames = Arrays.asList("*hmc", "hmc", "platform");
return matchAllModuleNames(webservicesNames, moduleNames);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:DefaultCommonIdeaService.java
示例11: createLessonContent
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@Override
public PsiDirectory createLessonContent(@NotNull Project project, @NotNull Lesson lesson, @Nullable IdeView view, @NotNull PsiDirectory parentDirectory) {
NewModuleAction newModuleAction = new NewModuleAction();
String courseDirPath = parentDirectory.getVirtualFile().getPath();
Module utilModule = ModuleManager.getInstance(project).findModuleByName(EduIntelliJNames.UTIL);
if (utilModule == null) {
return null;
}
newModuleAction.createModuleFromWizard(project, null, new AbstractProjectWizard("", project, "") {
@Override
public StepSequence getSequence() {
return null;
}
@Override
public ProjectBuilder getProjectBuilder() {
return new EduLessonModuleBuilder(courseDirPath, lesson, utilModule);
}
});
return parentDirectory.findSubdirectory(EduNames.LESSON + lesson.getIndex());
}
示例12: getParameters
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@NotNull
public Parameters getParameters() {
if (parameters == null) {
parameters = new Parameters();
parameters.existingModuleNames = new HashSet<>();
if (isUpdate()) {
Project project = getCurrentProject();
if (project != null) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
parameters.existingModuleNames.add(module.getName());
}
}
}
}
return parameters;
}
示例13: rootsChanged
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@Override
public void rootsChanged( ModuleRootEvent event )
{
Project project = (Project)event.getSource();
if( !shouldProcessRootChanges( project ) )
{
return;
}
boolean processDependencies = true;
if( processDependencies )
{
processModuleDependenciesChange( project );
}
final Module[] modules = ModuleManager.getInstance( project ).getModules();
for( Module ijModule : modules )
{
ManModule manModule = ManProject.getModule( ijModule );
processClasspathChange( manModule, ijModule );
changeSourceRoots( manModule );
}
}
示例14: determineModuleBySyncActionObject
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
@NotNull
private List<Module> determineModuleBySyncActionObject(Object o) {
if (o instanceof Module) {
return Collections.singletonList((Module)o);
}
if (o instanceof Project) {
return Arrays.asList(ModuleManager.getInstance((Project)o).getModules());
}
if (o instanceof VirtualFile) {
final VirtualFile file = (VirtualFile)o;
if (file.isValid()) {
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module == null) {
return Collections.emptyList();
}
return Collections.singletonList(module);
}
}
return Collections.emptyList();
}
示例15: FileTreeModelBuilder
import com.intellij.openapi.module.ModuleManager; //导入依赖的package包/类
public FileTreeModelBuilder(Project project, Marker marker, DependenciesPanel.DependencyPanelSettings settings) {
myProject = project;
myBaseDir = myProject.getBaseDir();
myContentRoots = ProjectRootManager.getInstance(myProject).getContentRoots();
final boolean multiModuleProject = ModuleManager.getInstance(myProject).getModules().length > 1;
myShowModules = settings.UI_SHOW_MODULES && multiModuleProject;
final ProjectViewDirectoryHelper directoryHelper = ProjectViewDirectoryHelper.getInstance(myProject);
myFlattenPackages = directoryHelper.supportsFlattenPackages() && settings.UI_FLATTEN_PACKAGES;
myCompactEmptyMiddlePackages = directoryHelper.supportsHideEmptyMiddlePackages() && settings.UI_COMPACT_EMPTY_MIDDLE_PACKAGES;
myShowFiles = settings.UI_SHOW_FILES;
myShowModuleGroups = settings.UI_SHOW_MODULE_GROUPS && multiModuleProject;
myMarker = marker;
myAddUnmarkedFiles = !settings.UI_FILTER_LEGALS;
myRoot = new RootNode(myProject);
myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
}