Search in sources :

Example 11 with PsModule

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

Example 12 with PsModule

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();
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) Ref(com.intellij.openapi.util.Ref) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) PsArtifactDependencySpec(com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec) PsLibraryAndroidDependency(com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency) UnknownHostException(java.net.UnknownHostException) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with PsModule

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);
            }
        });
    }
}
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)

Aggregations

PsModule (com.android.tools.idea.gradle.structure.model.PsModule)13 PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)5 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)3 NotNull (org.jetbrains.annotations.NotNull)3 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)2 PsProject (com.android.tools.idea.gradle.structure.model.PsProject)2 PsJavaModule (com.android.tools.idea.gradle.structure.model.java.PsJavaModule)2 List (java.util.List)2 ModuleDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel)1 PsContext (com.android.tools.idea.gradle.structure.configurables.PsContext)1 AndroidDependencyScopesPanel (com.android.tools.idea.gradle.structure.dependencies.android.AndroidDependencyScopesPanel)1 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)1 PsLibraryDependency (com.android.tools.idea.gradle.structure.model.PsLibraryDependency)1 PsParsedDependencies (com.android.tools.idea.gradle.structure.model.PsParsedDependencies)1 PsLibraryAndroidDependency (com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency)1 PsNewDependencyScopes (com.android.tools.idea.gradle.structure.model.android.dependency.PsNewDependencyScopes)1 Splitter (com.google.common.base.Splitter)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Module (com.intellij.openapi.module.Module)1 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)1