use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.
the class GroovySdkForProjectFromSourcesStep method updateDataModel.
@Override
public void updateDataModel() {
super.updateDataModel();
List<ModuleDescriptor> modules = new ArrayList<>();
for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedSourceRoot>emptyList());
descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
modules.add(descriptor);
}
myProjectDescriptor.setModules(modules);
}
use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.
the class CreateFromSourcesMode method addSteps.
public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
final ProjectFromSourcesBuilderImpl projectBuilder = new ProjectFromSourcesBuilderImpl(context, modulesProvider);
myProjectBuilder = projectBuilder;
final Icon icon = context.getStepIcon();
if (context.isCreatingNewProject()) {
addStep(sequence, new ProjectNameStep(context, this), specific);
}
addStep(sequence, new RootsDetectionStep(projectBuilder, context, sequence, icon, "reference.dialogs.new.project.fromCode.source"), specific);
Set<String> detectorTypes = new HashSet<>();
for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
detectorTypes.add(detector.getDetectorId());
for (ModuleWizardStep step : detector.createWizardSteps(projectBuilder, projectBuilder.getProjectDescriptor(detector), icon)) {
sequence.addSpecificStep(detector.getDetectorId(), step);
}
}
if (FrameworkDetectionStep.isEnabled()) {
FrameworkDetectionStep frameworkDetectionStep = new FrameworkDetectionStep(icon, projectBuilder) {
public List<ModuleDescriptor> getModuleDescriptors() {
final List<ModuleDescriptor> moduleDescriptors = new ArrayList<>();
for (ProjectDescriptor descriptor : projectBuilder.getSelectedDescriptors()) {
moduleDescriptors.addAll(descriptor.getModules());
}
return moduleDescriptors;
}
};
projectBuilder.addConfigurationUpdater(frameworkDetectionStep);
sequence.addCommonFinishingStep(frameworkDetectionStep, detectorTypes);
}
}
use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.
the class CloudGitChooseAccountStepImpl method updateDataModel.
@Override
public void updateDataModel() {
super.updateDataModel();
final MultiMap<CloudGitProjectRoot, DetectedSourceRoot> project2sourceRoots = new MultiMap<>();
new RootIterator() {
CloudGitProjectRoot lastProjectRoot = null;
@Override
protected void processProjectRoot(CloudGitProjectRoot root) {
lastProjectRoot = root;
project2sourceRoots.put(lastProjectRoot, new ArrayList<>());
}
@Override
protected void processJavaSourceRoot(DetectedSourceRoot root) {
project2sourceRoots.putValue(lastProjectRoot, root);
}
}.iterate();
List<ModuleDescriptor> modules = new ArrayList<>(myProjectDescriptor.getModules());
for (Map.Entry<CloudGitProjectRoot, Collection<DetectedSourceRoot>> project2sourceRootsEntry : project2sourceRoots.entrySet()) {
final CloudGitProjectRoot projectRoot = project2sourceRootsEntry.getKey();
final File directory = projectRoot.getDirectory();
ModuleDescriptor moduleDescriptor = new ModuleDescriptor(directory, StdModuleTypes.JAVA, project2sourceRootsEntry.getValue());
final String applicationName = projectRoot.getApplicationName();
moduleDescriptor.addConfigurationUpdater(new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull final Module module, @NotNull ModifiableRootModel rootModel) {
final MessageBusConnection connection = module.getProject().getMessageBus().connect();
connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {
@Override
public void moduleAdded(@NotNull Project project, @NotNull Module addedModule) {
if (addedModule == module) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> onModuleAdded(module));
connection.disconnect();
}
}
});
}
private void onModuleAdded(Module module) {
createRunConfiguration(module, applicationName);
GitInit.refreshAndConfigureVcsMappings(module.getProject(), projectRoot.getRepositoryRoot(), directory.getAbsolutePath());
}
});
modules.add(moduleDescriptor);
}
myProjectDescriptor.setModules(modules);
}
use of com.intellij.ide.util.importProject.ModuleDescriptor in project android by JetBrains.
the class AndroidProjectStructureDetector method setupProjectStructure.
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
final List<File> existingRoots = new ArrayList<File>();
for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
if (detector != this) {
for (DetectedProjectRoot root : builder.getProjectRoots(detector)) {
existingRoots.add(root.getDirectory());
}
}
}
final List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
final File dir = root.getDirectory();
boolean javaSrcRootInside = false;
for (File javaSourceRoot : existingRoots) {
if (FileUtil.isAncestor(dir, javaSourceRoot, false)) {
javaSrcRootInside = true;
}
}
if (!javaSrcRootInside) {
modules.add(new ModuleDescriptor(root.getDirectory(), JavaModuleType.getModuleType(), Collections.<DetectedSourceRoot>emptyList()));
}
}
projectDescriptor.setModules(modules);
}
use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-elixir by KronicDeth.
the class ElixirProjectStructureDetector method setupProjectStructure.
/**
* This detector just for import non-organization project which not like mix-project
* So that it's no need to detect directories such as libs, deps, tests etc
*
* And mix-project will imported by the MixProjectImportBuilder.java
* */
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
if (!roots.isEmpty() && !builder.hasRootsFromOtherDetectors(this)) {
List<ModuleDescriptor> modules = projectDescriptor.getModules();
if (modules.isEmpty()) {
modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
modules.add(new ModuleDescriptor(root.getDirectory(), ElixirModuleType.getInstance(), ContainerUtil.<DetectedSourceRoot>emptyList()));
}
projectDescriptor.setModules(modules);
}
}
}
Aggregations