use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.
the class BasePerspectiveConfigurable method updateSelection.
@Override
protected void updateSelection(@Nullable NamedConfigurable configurable) {
super.updateSelection(configurable);
if (configurable instanceof BaseNamedConfigurable) {
BaseNamedConfigurable baseConfigurable = (BaseNamedConfigurable) configurable;
PsModule module = baseConfigurable.getEditableObject();
if (!mySelectModuleQuietly) {
myContext.setSelectedModule(module.getName(), this);
} else {
mySelectModuleQuietly = false;
}
}
myHistory.pushQueryPlace();
}
use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.
the class AddLibraryDependencyDialog method doValidate.
@Override
@Nullable
protected ValidationInfo doValidate() {
List<Exception> searchErrors = myLibraryDependenciesForm.getSearchErrors();
if (!searchErrors.isEmpty()) {
StringBuilder buffer = new StringBuilder();
searchErrors.forEach(e -> buffer.append(getErrorMessage(e)).append("\n"));
return new ValidationInfo(buffer.toString(), myLibraryDependenciesForm.getPreferredFocusedComponent());
}
String selectedLibrary = myLibraryDependenciesForm.getSelectedLibrary();
if (isEmpty(selectedLibrary)) {
return new ValidationInfo("Please specify the library to add as dependency", myLibraryDependenciesForm.getPreferredFocusedComponent());
}
PsArtifactDependencySpec spec = PsArtifactDependencySpec.create(selectedLibrary);
PsModule module = getModule();
if (spec != null && module instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) module;
Ref<Boolean> found = new Ref<>(false);
androidModule.forEachDeclaredDependency(dependency -> {
if (dependency instanceof PsLibraryAndroidDependency) {
PsLibraryAndroidDependency libraryDependency = (PsLibraryAndroidDependency) dependency;
PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
if (Objects.equals(spec.group, resolvedSpec.group) && Objects.equals(spec.name, resolvedSpec.name)) {
found.set(true);
}
}
});
if (found.get()) {
String msg = String.format("Library '%1$s' is already a dependency", spec.name);
return new ValidationInfo(msg, myLibraryDependenciesForm.getPreferredFocusedComponent());
}
}
return getScopesPanel().validateInput();
}
use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.
the class ModuleDependencyNode method setUp.
private void setUp(@NotNull PsModuleAndroidDependency moduleDependency) {
myName = moduleDependency.toText(PLAIN_TEXT);
PsAndroidModule dependentModule = moduleDependency.getParent();
PsProject project = dependentModule.getParent();
PsModule referred = project.findModuleByGradlePath(moduleDependency.getGradlePath());
if (referred instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) referred;
androidModule.forEachDependency(dependency -> {
if (!dependency.isDeclared()) {
return;
}
String moduleVariant = moduleDependency.getConfigurationName();
if (!dependency.isIn(ARTIFACT_MAIN, moduleVariant)) {
return;
}
AbstractPsModelNode<?> child = AbstractDependencyNode.createNode(this, dependency);
if (child != null) {
myChildren.add(child);
}
});
}
}
Aggregations