This commit is contained in:
Vladimir Krivosheev
2016-11-29 16:41:18 +01:00
parent 843e25c886
commit b862e0bf5b
4 changed files with 18 additions and 18 deletions
@@ -31,12 +31,10 @@ import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.JarFileSystem
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.project.rootManager
import com.intellij.util.PlatformUtils
import com.intellij.util.containers.computeOrNull
private val Module.rootManager: ModuleRootManager
get() = ModuleRootManager.getInstance(this)
private class DefaultWebServerRootsProvider : WebServerRootsProvider() {
override fun resolve(path: String, project: Project): PathInfo? {
var effectivePath = path
@@ -98,17 +98,14 @@ public abstract class ModuleAwareProjectConfigurable<T extends UnnamedConfigurab
final Splitter splitter = new Splitter(false, 0.25f);
CollectionListModel<Module> listDataModel = new CollectionListModel<>(modules);
final JBList moduleList = new JBList(listDataModel);
new ListSpeedSearch(moduleList, new Function<Object, String>() {
@Override
public String fun(Object o) {
if (o == null) {
return getProjectConfigurableItemName();
}
else if (o instanceof Module) {
return ((Module)o).getName();
}
return null;
new ListSpeedSearch(moduleList, (Function<Object, String>)o -> {
if (o == null) {
return getProjectConfigurableItemName();
}
else if (o instanceof Module) {
return ((Module)o).getName();
}
return null;
});
moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
moduleList.setCellRenderer(new ModuleListCellRenderer() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.platform.ModuleAttachProcessor;
@@ -22,8 +22,10 @@ import com.intellij.openapi.components.impl.stores.IComponentStore
import com.intellij.openapi.components.impl.stores.IProjectStore
import com.intellij.openapi.components.stateStore
import com.intellij.openapi.module.ModifiableModuleModel
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VirtualFile
@@ -77,10 +79,14 @@ fun isEqualToProjectFileStorePath(project: Project, filePath: String, storePath:
return filePath.equals(store.stateStorageManager.expandMacros(storePath), !SystemInfo.isFileSystemCaseSensitive)
}
inline fun Project.modifyModules(crossinline task: ModifiableModuleModel.() -> Unit) {
inline fun <T> Project.modifyModules(crossinline task: ModifiableModuleModel.() -> T): T {
val model = ModuleManager.getInstance(this).modifiableModel
val result = model.task()
runWriteAction {
model.task()
model.commit()
}
}
return result
}
val Module.rootManager: ModuleRootManager
get() = ModuleRootManager.getInstance(this)