本文整理匯總了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();
}