Search in sources :

Example 1 with PsAndroidModule

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);
            }
        });
    }
}
Also used : PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) List(java.util.List) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsContext(com.android.tools.idea.gradle.structure.configurables.PsContext) NonNls(org.jetbrains.annotations.NonNls) PsLibraryDependency(com.android.tools.idea.gradle.structure.model.PsLibraryDependency) PsArtifactDependencySpec(com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NotNull(org.jetbrains.annotations.NotNull) Splitter(com.google.common.base.Splitter) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) PsLibraryDependency(com.android.tools.idea.gradle.structure.model.PsLibraryDependency)

Example 2 with PsAndroidModule

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;
}
Also used : PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) AndroidModuleDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.AndroidModuleDependenciesConfigurable) JavaModuleDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.java.dependencies.JavaModuleDependenciesConfigurable) PsAllModulesFakeModule(com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule) ProjectDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.ProjectDependenciesConfigurable) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PsAndroidModule

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);
    }
}
Also used : PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) TargetAndroidModuleNode(com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.treeview.TargetAndroidModuleNode)

Example 4 with PsAndroidModule

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;
}
Also used : PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PsAndroidModule

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);
    }
}
Also used : PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsNewDependencyScopes(com.android.tools.idea.gradle.structure.model.android.dependency.PsNewDependencyScopes) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) AndroidDependencyScopesPanel(com.android.tools.idea.gradle.structure.dependencies.android.AndroidDependencyScopesPanel)

Aggregations

PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)8 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)5 PsJavaModule (com.android.tools.idea.gradle.structure.model.java.PsJavaModule)4 NotNull (org.jetbrains.annotations.NotNull)3 PsContext (com.android.tools.idea.gradle.structure.configurables.PsContext)2 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)2 PsProject (com.android.tools.idea.gradle.structure.model.PsProject)2 Ref (com.intellij.openapi.util.Ref)2 Nullable (org.jetbrains.annotations.Nullable)2 PsAllModulesFakeModule (com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule)1 AndroidModuleDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.AndroidModuleDependenciesConfigurable)1 ProjectDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.ProjectDependenciesConfigurable)1 TargetAndroidModuleNode (com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.treeview.TargetAndroidModuleNode)1 JavaModuleDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.java.dependencies.JavaModuleDependenciesConfigurable)1 AvailableLibraryUpdate (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdate)1 AvailableLibraryUpdates (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdates)1 PsAndroidModuleAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsAndroidModuleAnalyzer)1 PsJavaModuleAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsJavaModuleAnalyzer)1 PsModelAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsModelAnalyzer)1 AndroidDependencyScopesPanel (com.android.tools.idea.gradle.structure.dependencies.android.AndroidDependencyScopesPanel)1