Search in sources :

Example 1 with PsModule

use of com.android.tools.idea.gradle.structure.model.PsModule 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 PsModule

use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.

the class BasePerspectiveConfigurable method putNavigationPath.

public void putNavigationPath(@NotNull Place place, @NotNull String moduleName, @NotNull String dependency) {
    place.putPath(getNavigationPathName(), moduleName);
    PsModule module = findModule(moduleName);
    assert module != null;
    MyNode node = findNodeByObject(myRoot, module);
    assert node != null;
    NamedConfigurable configurable = node.getConfigurable();
    assert configurable instanceof BaseNamedConfigurable;
    BaseNamedConfigurable dependenciesConfigurable = (BaseNamedConfigurable) configurable;
    dependenciesConfigurable.putNavigationPath(place, dependency);
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable)

Example 3 with PsModule

use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.

the class BasePerspectiveConfigurable method queryPlace.

@Override
public void queryPlace(@NotNull Place place) {
    NamedConfigurable selectedConfigurable = getSelectedConfigurable();
    if (selectedConfigurable instanceof BaseNamedConfigurable) {
        PsModule module = ((BaseNamedConfigurable) selectedConfigurable).getEditableObject();
        String moduleName = module.getName();
        place.putPath(getNavigationPathName(), moduleName);
        queryFurther(selectedConfigurable, place);
        return;
    }
    place.putPath(getNavigationPathName(), "");
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable)

Example 4 with PsModule

use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.

the class PsModuleCellRenderer method customizeCellRenderer.

@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof MasterDetailsComponent.MyNode) {
        MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode) value;
        NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable == null) {
            return;
        }
        setIcon(namedConfigurable.getIcon(expanded));
        setToolTipText(null);
        setFont(getTreeFont());
        SimpleTextAttributes textAttributes = REGULAR_ATTRIBUTES;
        if (node.isDisplayInBold()) {
            textAttributes = REGULAR_BOLD_ATTRIBUTES;
        } else if (namedConfigurable instanceof BaseNamedConfigurable) {
            PsModule module = ((BaseNamedConfigurable) namedConfigurable).getEditableObject();
            List<PsIssue> issues = myContext.getAnalyzerDaemon().getIssues().findIssues(module, IssuesByTypeAndTextComparator.INSTANCE);
            setToolTipText(getTooltipText(issues, true));
            if (!issues.isEmpty()) {
                PsIssue issue = issues.get(0);
                Color waveColor = issue.getSeverity().getColor();
                textAttributes = textAttributes.derive(STYLE_WAVED, null, null, waveColor);
            }
        }
        append(node.getDisplayName(), textAttributes);
    }
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) List(java.util.List) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue)

Example 5 with PsModule

use of com.android.tools.idea.gradle.structure.model.PsModule in project android by JetBrains.

the class ChooseModuleDialog method doOKAction.

@Override
protected void doOKAction() {
    super.doOKAction();
    PsModule selectedModule = getSelectedModule();
    assert selectedModule != null;
    myOnOkTask.accept(selectedModule);
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule)

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