use of com.android.tools.idea.gradle.project.ModuleToImport in project android by JetBrains.
the class ModuleListModel method computeRequiredModules.
private Multimap<ModuleToImport, ModuleToImport> computeRequiredModules(Set<ModuleToImport> modules) {
Map<String, ModuleToImport> namesToModules = Maps.newHashMapWithExpectedSize(modules.size());
// We only care about modules we are actually going to import.
for (ModuleToImport module : modules) {
namesToModules.put(module.name, module);
}
Multimap<ModuleToImport, ModuleToImport> requiredModules = LinkedListMultimap.create();
Queue<ModuleToImport> queue = Lists.newLinkedList();
for (ModuleToImport module : modules) {
if (Objects.equal(module, myPrimaryModule) || !isUnselected(module, false)) {
queue.add(module);
}
}
while (!queue.isEmpty()) {
ModuleToImport moduleToImport = queue.remove();
for (ModuleToImport dep : Iterables.transform(moduleToImport.getDependencies(), Functions.forMap(namesToModules, null))) {
if (dep != null) {
if (!requiredModules.containsKey(dep)) {
queue.add(dep);
}
requiredModules.put(dep, moduleToImport);
}
}
}
return requiredModules;
}
use of com.android.tools.idea.gradle.project.ModuleToImport in project android by JetBrains.
the class ModuleListModel method checkForDuplicateNames.
private void checkForDuplicateNames() {
Collection<ModuleToImport> modules = getSelectedModules();
ImmutableMultiset<String> names = ImmutableMultiset.copyOf(Iterables.transform(modules, new Function<ModuleToImport, String>() {
@Override
public String apply(@Nullable ModuleToImport input) {
return input == null ? null : getModuleName(input);
}
}));
for (ModuleToImport module : modules) {
ModuleValidationState state = myModules.get(module);
if (state == ModuleValidationState.OK) {
if (names.count(getModuleName(module)) > 1) {
myModules.put(module, ModuleValidationState.DUPLICATE_MODULE_NAME);
}
}
}
}
use of com.android.tools.idea.gradle.project.ModuleToImport in project android by JetBrains.
the class ModuleListModel method revalidate.
private void revalidate(Iterable<ModuleToImport> modules) {
myModules = validateModules(modules);
myRequiredModules = computeRequiredModules(myModules.keySet());
for (ModuleToImport module : myRequiredModules.keySet()) {
myNameOverrides.remove(module);
}
checkForDuplicateNames();
}
use of com.android.tools.idea.gradle.project.ModuleToImport in project android by JetBrains.
the class ModulesTable method updateModuleEditors.
private Collection<ModuleImportSettingsPane> updateModuleEditors() {
isRefreshing = true;
try {
ModuleToImport primary = myListModel.getPrimary();
setModuleNameVisibility(primary != null, myListModel.getAllModules().size() > 1);
if (primary != null) {
apply(myPrimaryModuleSettings, primary);
}
boolean isFirst = true;
Collection<ModuleImportSettingsPane> editors = Lists.newLinkedList();
Set<ModuleToImport> allModules = Sets.newTreeSet(new ModuleComparator(myListModel.getCurrentPath()));
Iterables.addAll(allModules, Iterables.filter(myListModel.getAllModules(), Predicates.not(Predicates.equalTo(myListModel.getPrimary()))));
for (final ModuleToImport module : allModules) {
final ModuleImportSettingsPane pane = createModuleSetupPanel(module, isFirst);
if (pane != null) {
isFirst = false;
editors.add(pane);
}
}
return editors;
} finally {
isRefreshing = false;
}
}
use of com.android.tools.idea.gradle.project.ModuleToImport in project android by JetBrains.
the class ImportSourceLocationStep method applyBackgroundOperationResult.
private void applyBackgroundOperationResult(@NotNull PathValidationResult result) {
assert EventQueue.isDispatchThread();
Collection<ModuleToImport> modules = null;
Project project = myContext.getProject();
try {
if (result.myStatus == PageStatus.OK) {
assert result.myVfile != null && result.myImporter != null;
modules = result.myImporter.findModules(result.myVfile);
Set<String> missingSourceModuleNames = Sets.newTreeSet();
for (ModuleToImport module : modules) {
if (module.location == null || !module.location.exists()) {
missingSourceModuleNames.add(module.name);
}
}
if (!missingSourceModuleNames.isEmpty()) {
result = new PathValidationResult(PageStatus.MISSING_SUBPROJECTS, result.myVfile, result.myImporter, missingSourceModuleNames);
}
}
} catch (IOException e) {
LOG.error(e);
result = PageStatus.INTERNAL_ERROR.result();
}
myValidating = false;
myModulesPanel.setModules(project, result.myVfile, modules);
myModulesScroller.setVisible(myModulesPanel.getComponentCount() > 0);
ModuleImporter.setImporter(myContext, result.myImporter);
updateStepStatus(result);
}
Aggregations