use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class QuickFixes method setLibraryDependencyVersion.
private static void setLibraryDependencyVersion(@NonNls PsContext context, @NotNull String moduleName, @NotNull String dependency, @NotNull String version) {
PsModule module = context.getProject().findModuleByName(moduleName);
if (module instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) module;
androidModule.forEachDeclaredDependency(declaredDependency -> {
if (declaredDependency instanceof PsLibraryDependency) {
setLibraryDependencyVersion((PsLibraryDependency) declaredDependency, dependency, version);
}
});
} else if (module instanceof PsJavaModule) {
PsJavaModule javaModule = (PsJavaModule) module;
javaModule.forEachDeclaredDependency(declaredDependency -> {
if (declaredDependency instanceof PsLibraryDependency) {
setLibraryDependencyVersion((PsLibraryDependency) declaredDependency, dependency, version);
}
});
}
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class DependenciesPerspectiveConfigurable method getConfigurable.
@Override
@Nullable
protected NamedConfigurable<? extends PsModule> getConfigurable(@NotNull PsModule module) {
AbstractDependenciesConfigurable<? extends PsModule> configurable;
if (module instanceof PsAllModulesFakeModule) {
configurable = myExtraTopConfigurables.get(module);
if (configurable == null) {
configurable = new ProjectDependenciesConfigurable(module, getContext(), getExtraTopModules());
configurable.setHistory(myHistory);
myExtraTopConfigurables.put(module, configurable);
}
} else {
String gradlePath = module.getGradlePath();
configurable = myConfigurablesByGradlePath.get(gradlePath);
if (configurable == null) {
if (module instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) module;
configurable = new AndroidModuleDependenciesConfigurable(androidModule, getContext(), getExtraTopModules());
configurable.setHistory(myHistory);
myConfigurablesByGradlePath.put(gradlePath, configurable);
} else if (module instanceof PsJavaModule) {
PsJavaModule javaModule = (PsJavaModule) module;
configurable = new JavaModuleDependenciesConfigurable(javaModule, getContext(), getExtraTopModules());
}
}
}
return configurable;
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class TargetModulesPanel method popupInvoked.
private void popupInvoked(int x, int y) {
TargetAndroidModuleNode node = myHyperlinkSupport.getNodeForLocation(x, y);
if (node != null) {
PsAndroidModule module = node.getFirstModel();
DefaultActionGroup group = new DefaultActionGroup();
group.add(new GoToModuleAction(module.getName(), myContext, myTree));
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu("", group);
popupMenu.getComponent().show(myTree, x, y);
}
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class ModuleDependenciesForm method getModuleDependencies.
@NotNull
private static List<PsModule> getModuleDependencies(@NotNull PsModule module) {
PsProject project = module.getParent();
List<PsModule> dependencies = Lists.newArrayList();
if (module instanceof PsAndroidModule) {
((PsAndroidModule) module).forEachModuleDependency(dependency -> {
String name = dependency.getName();
PsModule found = project.findModuleByName(name);
if (found != null) {
dependencies.add(found);
}
});
}
return dependencies;
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class AddLibraryDependencyDialog method addNewDependencies.
@Override
public void addNewDependencies() {
String library = myLibraryDependenciesForm.getSelectedLibrary();
assert library != null;
AbstractDependencyScopesPanel scopesPanel = getScopesPanel();
List<String> scopesNames = scopesPanel.getSelectedScopeNames();
PsModule module = getModule();
if (module instanceof PsAndroidModule) {
PsNewDependencyScopes newScopes = ((AndroidDependencyScopesPanel) scopesPanel).getNewScopes();
assert newScopes != null;
((PsAndroidModule) module).addLibraryDependency(library, newScopes, scopesNames);
} else if (module instanceof PsJavaModule) {
((PsJavaModule) module).addLibraryDependency(library, scopesNames);
}
}
Aggregations