Minor: do configuration in one place
This commit is contained in:
@@ -91,31 +91,24 @@ public class KotlinJavaModuleConfigurator extends KotlinWithLibraryConfigurator
|
|||||||
ConfigureKotlinInProjectUtils.getNonConfiguredModules(project, this):
|
ConfigureKotlinInProjectUtils.getNonConfiguredModules(project, this):
|
||||||
Arrays.asList(ModuleManager.getInstance(project).getModules());
|
Arrays.asList(ModuleManager.getInstance(project).getModules());
|
||||||
|
|
||||||
|
List<Module> modulesToConfigure = nonConfiguredModules;
|
||||||
|
String copyLibIntoPath = null;
|
||||||
|
|
||||||
if (nonConfiguredModules.size() > 1 || showPathPanelForJava) {
|
if (nonConfiguredModules.size() > 1 || showPathPanelForJava) {
|
||||||
List<Module> modulesToConfigure;
|
CreateJavaLibraryDialogWithModules dialog = new CreateJavaLibraryDialogWithModules(
|
||||||
String copyLibIntoPath;
|
project, nonConfiguredModules, defaultPath, showPathPanelForJava);
|
||||||
|
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
CreateJavaLibraryDialogWithModules dialog = new CreateJavaLibraryDialogWithModules(
|
|
||||||
project, nonConfiguredModules, defaultPath, showPathPanelForJava);
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
if (!dialog.isOK()) return;
|
if (!dialog.isOK()) return;
|
||||||
modulesToConfigure = dialog.getModulesToConfigure();
|
|
||||||
copyLibIntoPath = dialog.getCopyIntoPath();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
modulesToConfigure = nonConfiguredModules;
|
|
||||||
copyLibIntoPath = defaultPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Module module : modulesToConfigure) {
|
modulesToConfigure = dialog.getModulesToConfigure();
|
||||||
configureModuleWithLibrary(module, defaultPath, copyLibIntoPath);
|
copyLibIntoPath = dialog.getCopyIntoPath();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (Module module : nonConfiguredModules) {
|
for (Module module : modulesToConfigure) {
|
||||||
configureModuleWithLibrary(module, defaultPath, null);
|
configureModuleWithLibrary(module, defaultPath, copyLibIntoPath);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.configuration;
|
package org.jetbrains.jet.plugin.configuration;
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.module.ModuleManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.OrderRootType;
|
import com.intellij.openapi.roots.OrderRootType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -28,6 +30,7 @@ import org.jetbrains.jet.plugin.project.ProjectStructureUtil;
|
|||||||
import org.jetbrains.jet.utils.PathUtil;
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
||||||
@@ -97,26 +100,36 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
|||||||
boolean showPathToJarPanel = needToChooseJarPath(project);
|
boolean showPathToJarPanel = needToChooseJarPath(project);
|
||||||
boolean showPathToJsFilePanel = needToChooseJsFilePath(project);
|
boolean showPathToJsFilePanel = needToChooseJsFilePath(project);
|
||||||
|
|
||||||
List<Module> nonConfiguredModules = ConfigureKotlinInProjectUtils.getNonConfiguredModules(project, this);
|
List<Module> nonConfiguredModules =
|
||||||
|
!ApplicationManager.getApplication().isUnitTestMode() ?
|
||||||
|
ConfigureKotlinInProjectUtils.getNonConfiguredModules(project, this) :
|
||||||
|
Arrays.asList(ModuleManager.getInstance(project).getModules());
|
||||||
|
|
||||||
|
List<Module> modulesToConfigure = nonConfiguredModules;
|
||||||
|
String copyLibraryIntoPath = null;
|
||||||
|
String jsFilesIntoPath = null;
|
||||||
|
|
||||||
if (nonConfiguredModules.size() > 1 || showPathToJarPanel || showPathToJsFilePanel) {
|
if (nonConfiguredModules.size() > 1 || showPathToJarPanel || showPathToJsFilePanel) {
|
||||||
CreateJavaScriptLibraryDialogWithModules dialog =
|
CreateJavaScriptLibraryDialogWithModules dialog =
|
||||||
new CreateJavaScriptLibraryDialogWithModules(project, nonConfiguredModules,
|
new CreateJavaScriptLibraryDialogWithModules(project, nonConfiguredModules,
|
||||||
defaultPathToJar, defaultPathToJsFile,
|
defaultPathToJar, defaultPathToJsFile,
|
||||||
showPathToJarPanel, showPathToJsFilePanel);
|
showPathToJarPanel, showPathToJsFilePanel);
|
||||||
dialog.show();
|
|
||||||
if (!dialog.isOK()) return;
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
for (Module module : dialog.getModulesToConfigure()) {
|
dialog.show();
|
||||||
configureModuleWithLibrary(module, defaultPathToJar, dialog.getCopyLibraryIntoPath());
|
if (!dialog.isOK()) return;
|
||||||
}
|
}
|
||||||
configureModuleWithJsFile(defaultPathToJsFile, dialog.getCopyJsIntoPath());
|
|
||||||
|
modulesToConfigure = dialog.getModulesToConfigure();
|
||||||
|
copyLibraryIntoPath = dialog.getCopyLibraryIntoPath();
|
||||||
|
jsFilesIntoPath = dialog.getCopyJsIntoPath();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (Module module : nonConfiguredModules) {
|
for (Module module : modulesToConfigure) {
|
||||||
configureModuleWithLibrary(module, defaultPathToJar, null);
|
configureModuleWithLibrary(module, defaultPathToJar, copyLibraryIntoPath);
|
||||||
}
|
|
||||||
configureModuleWithJsFile(defaultPathToJsFile, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureModuleWithJsFile(defaultPathToJsFile, jsFilesIntoPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isJsFilePresent(@NotNull String dir) {
|
public static boolean isJsFilePresent(@NotNull String dir) {
|
||||||
|
|||||||
Reference in New Issue
Block a user