本文整理汇总了Java中com.intellij.openapi.roots.ModifiableRootModel.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java ModifiableRootModel.dispose方法的具体用法?Java ModifiableRootModel.dispose怎么用?Java ModifiableRootModel.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModifiableRootModel
的用法示例。
在下文中一共展示了ModifiableRootModel.dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static void removeModule(@NotNull final Module moduleToRemove,
@Nullable ModifiableRootModel modifiableRootModelToRemove,
@NotNull Collection<ModifiableRootModel> otherModuleRootModels,
@NotNull final ModifiableModuleModel moduleModel) {
// remove all dependencies on the module that is about to be removed
for (final ModifiableRootModel modifiableRootModel : otherModuleRootModels) {
final OrderEntry[] orderEntries = modifiableRootModel.getOrderEntries();
for (final OrderEntry orderEntry : orderEntries) {
if (orderEntry instanceof ModuleOrderEntry && orderEntry.isValid()) {
final Module orderEntryModule = ((ModuleOrderEntry)orderEntry).getModule();
if (orderEntryModule != null && orderEntryModule.equals(moduleToRemove)) {
modifiableRootModel.removeOrderEntry(orderEntry);
}
}
}
}
// destroyProcess editor
if (modifiableRootModelToRemove != null) {
modifiableRootModelToRemove.dispose();
}
// destroyProcess module
moduleModel.disposeModule(moduleToRemove);
}
示例2: disposeModels
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static void disposeModels(@NotNull Collection<ModifiableRootModel> models) {
for (ModifiableRootModel model : models) {
if (!model.isDisposed()) {
model.dispose();
}
}
}
示例3: updateProjectFolders
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static void updateProjectFolders(final Project project, final boolean updateTargetFoldersOnly) {
final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
final MavenImportingSettings settings = manager.getImportingSettings();
AccessToken accessToken = WriteAction.start();
try {
List<ModifiableRootModel> rootModels = new ArrayList<ModifiableRootModel>();
for (Module each : ModuleManager.getInstance(project).getModules()) {
MavenProject mavenProject = manager.findProject(each);
if (mavenProject == null) continue;
MavenRootModelAdapter a = new MavenRootModelAdapter(mavenProject, each, new IdeModifiableModelsProviderImpl(project));
new MavenFoldersImporter(mavenProject, settings, a).config(updateTargetFoldersOnly);
ModifiableRootModel model = a.getRootModel();
if (model.isChanged()) {
rootModels.add(model);
}
else {
model.dispose();
}
}
if (!rootModels.isEmpty()) {
ModifiableRootModel[] modelsArray = rootModels.toArray(new ModifiableRootModel[rootModels.size()]);
if (modelsArray.length > 0) {
ModifiableModelCommitter.multiCommit(modelsArray, ModuleManager.getInstance(modelsArray[0].getProject()).getModifiableModel());
}
}
}
finally {
accessToken.finish();
}
}
示例4: excludeOutputFolders
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void excludeOutputFolders(@NotNull AndroidFacet facet) {
IdeaAndroidProject androidProject = facet.getIdeaAndroidProject();
if (androidProject == null) {
return;
}
File buildFolderPath = androidProject.getDelegate().getBuildFolder();
if (!buildFolderPath.isDirectory()) {
return;
}
Module module = facet.getModule();
if (module.getProject().isDisposed()) {
return;
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
try {
ContentEntry[] contentEntries = rootModel.getContentEntries();
ContentEntry parent = findParentContentEntry(buildFolderPath, contentEntries);
if (parent == null) {
rootModel.dispose();
return;
}
File[] outputFolderPaths = notNullize(buildFolderPath.listFiles());
if (outputFolderPaths.length == 0) {
rootModel.dispose();
return;
}
for (File outputFolderPath : outputFolderPaths) {
if (!androidProject.shouldManuallyExclude(outputFolderPath)) {
continue;
}
boolean alreadyExcluded = false;
for (VirtualFile excluded : parent.getExcludeFolderFiles()) {
if (filesEqual(outputFolderPath, virtualToIoFile(excluded))) {
alreadyExcluded = true;
break;
}
}
if (!alreadyExcluded) {
parent.addExcludeFolder(pathToIdeaUrl(outputFolderPath));
}
}
}
finally {
if (!rootModel.isDisposed()) {
rootModel.commit();
}
}
}