Search in sources :

Example 1 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class PlatformComponentsPanel method updatePlatformItems.

private void updatePlatformItems() {
    myPlatformDetailsRootNode.removeAllChildren();
    myPlatformSummaryRootNode.removeAllChildren();
    myStates.clear();
    List<AndroidVersion> versions = Lists.newArrayList(myCurrentPackages.keySet());
    versions = Lists.reverse(versions);
    for (AndroidVersion version : versions) {
        Set<UpdaterTreeNode> versionNodes = Sets.newHashSet();
        UpdaterTreeNode marker = new ParentTreeNode(version);
        myPlatformDetailsRootNode.add(marker);
        boolean obsolete = false;
        for (UpdatablePackage info : myCurrentPackages.get(version)) {
            RepoPackage pkg = info.getRepresentative();
            PackageNodeModel model = new PackageNodeModel(info);
            myStates.add(model);
            UpdaterTreeNode node = new DetailsTreeNode(model, myModificationListener, myConfigurable);
            marker.add(node);
            versionNodes.add(node);
            if (pkg.obsolete() && pkg.getTypeDetails() instanceof DetailsTypes.PlatformDetailsType) {
                obsolete = true;
            }
        }
        if (!obsolete) {
            SummaryTreeNode node = SummaryTreeNode.createNode(version, versionNodes);
            if (node != null) {
                myPlatformSummaryRootNode.add(node);
            }
        }
    }
    refreshModified();
    SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformDetailTable);
    SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformSummaryTable);
    myPlatformDetailTable.updateUI();
    myPlatformSummaryTable.updateUI();
    TreeUtil.expandAll(myPlatformDetailTable.getTree());
    TreeUtil.expandAll(myPlatformSummaryTable.getTree());
}
Also used : DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidVersion(com.android.sdklib.AndroidVersion) UpdatablePackage(com.android.repository.api.UpdatablePackage) RepoPackage(com.android.repository.api.RepoPackage)

Example 2 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class UnresolvedDependenciesReporter method report.

private void report(@NotNull String dependency, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String group = "Unresolved Android dependencies";
    GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString(dependency);
    RepoPackage constraintPackage = null;
    if (coordinate != null) {
        ProgressIndicator indicator = new StudioLoggerProgressIndicator(getClass());
        reloadRemoteSdkWithModalProgress();
        Collection<RemotePackage> remotePackages = getRemotePackages(indicator);
        constraintPackage = findBestPackageMatching(coordinate, remotePackages);
    }
    List<NotificationHyperlink> quickFixes = new ArrayList<>();
    if (dependency.startsWith("com.android.support.constraint:constraint-layout:") && !canGetConstraintLayoutFromSdkManager(module)) {
        quickFixes.add(new FixAndroidGradlePluginVersionHyperlink());
    } else if (constraintPackage != null) {
        quickFixes.add(new InstallArtifactHyperlink(constraintPackage.getPath()));
    } else if (dependency.startsWith("com.android.support")) {
        quickFixes.add(new InstallRepositoryHyperlink(ANDROID));
    } else if (dependency.startsWith("com.google.android")) {
        quickFixes.add(new InstallRepositoryHyperlink(GOOGLE));
    } else {
        group = "Unresolved dependencies";
        Project project = module.getProject();
        if (isOfflineBuildModeEnabled(project)) {
            quickFixes.add(new DisableOfflineModeHyperlink());
        }
    }
    String text = "Failed to resolve: " + dependency;
    SyncMessage message;
    if (buildFile != null) {
        PositionInFile position = findDependencyPosition(dependency, buildFile);
        message = new SyncMessage(module.getProject(), group, ERROR, position, text);
        String hyperlinkText = position.line > -1 ? "Show in File" : "Open File";
        quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), hyperlinkText, position.line, position.column));
    } else {
        message = new SyncMessage(group, ERROR, NonNavigatable.INSTANCE, text);
    }
    if (IdeInfo.getInstance().isAndroidStudio()) {
        if (coordinate != null) {
            quickFixes.add(new ShowDependencyInProjectStructureHyperlink(module, coordinate));
        }
    }
    message.add(quickFixes);
    getSyncMessages(module).report(message);
}
Also used : GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) ArrayList(java.util.ArrayList) PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) StringUtil.unquoteString(com.intellij.openapi.util.text.StringUtil.unquoteString) SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) Project(com.intellij.openapi.project.Project) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) RemotePackage(com.android.repository.api.RemotePackage) RepoPackage(com.android.repository.api.RepoPackage)

Example 3 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class FormFactorApiComboBox method addPackages.

private void addPackages(@NotNull Collection<? extends RepoPackage> packages, int minSdkLevel) {
    Iterable<? extends RepoPackage> filter = Iterables.filter(packages, FormFactorUtils.getMinSdkPackageFilter(myFormFactor, minSdkLevel));
    List<RepoPackage> sorted = Lists.newArrayList(filter);
    Collections.sort(sorted, (repoPackage, other) -> FormFactorUtils.getAndroidVersion(repoPackage).compareTo(FormFactorUtils.getAndroidVersion(other)));
    int existingApiLevel = -1;
    int prevInsertedApiLevel = -1;
    int index = -1;
    for (RepoPackage info : sorted) {
        int apiLevel = FormFactorUtils.getFeatureLevel(info);
        while (apiLevel > existingApiLevel) {
            existingApiLevel = ++index < getItemCount() ? getItemAt(index).myApiLevel : Integer.MAX_VALUE;
        }
        if (apiLevel != existingApiLevel && apiLevel != prevInsertedApiLevel) {
            insertItemAt(new AndroidTargetComboBoxItem(info), index++);
            prevInsertedApiLevel = apiLevel;
        }
    }
}
Also used : RepoPackage(com.android.repository.api.RepoPackage)

Example 4 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class UpdatablePackage method isUpdateFor.

@Override
public boolean isUpdateFor(UpdatableExternalComponent c) {
    if (c == null) {
        return false;
    }
    Object otherKey = c.getKey();
    if (!(otherKey instanceof RepoPackage)) {
        return false;
    }
    RepoPackage otherPackage = (RepoPackage) otherKey;
    return myPackage.getPath().equals(otherPackage.getPath()) && myPackage.getVersion().compareTo(otherPackage.getVersion()) > 0;
}
Also used : RepoPackage(com.android.repository.api.RepoPackage)

Example 5 with RepoPackage

use of com.android.repository.api.RepoPackage in project android by JetBrains.

the class AndroidVersionsInfo method addPackages.

private void addPackages(@NotNull FormFactor myFormFactor, @NotNull List<VersionItem> versionItemList, @NotNull Collection<? extends RepoPackage> packages, int minSdkLevel) {
    List<RepoPackage> sorted = packages.stream().filter(repoPackage -> repoPackage != null && filterPkgDesc(repoPackage, myFormFactor, minSdkLevel)).collect(Collectors.toList());
    Collections.sort(sorted, (repoPackage, other) -> getAndroidVersion(repoPackage).compareTo(getAndroidVersion(other)));
    int existingApiLevel = -1;
    int prevInsertedApiLevel = -1;
    int index = -1;
    for (RepoPackage info : sorted) {
        int apiLevel = getFeatureLevel(info);
        while (apiLevel > existingApiLevel) {
            existingApiLevel = ++index < versionItemList.size() ? versionItemList.get(index).myApiLevel : Integer.MAX_VALUE;
        }
        if (apiLevel != existingApiLevel && apiLevel != prevInsertedApiLevel) {
            versionItemList.add(index++, new VersionItem(info));
            prevInsertedApiLevel = apiLevel;
        }
    }
}
Also used : java.util(java.util) SdkConstants(com.android.SdkConstants) ModalityState(com.intellij.openapi.application.ModalityState) RemotePackage(com.android.repository.api.RemotePackage) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidTargetHash(com.android.sdklib.AndroidTargetHash) AndroidTargetManager(com.android.sdklib.repository.targets.AndroidTargetManager) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) FormFactor(com.android.tools.idea.npw.FormFactor) RepoPackage(com.android.repository.api.RepoPackage) AndroidVersion(com.android.sdklib.AndroidVersion) TemplateMetadata(com.android.tools.idea.templates.TemplateMetadata) AndroidSdkUtils(org.jetbrains.android.sdk.AndroidSdkUtils) TemplateUtils(com.android.tools.idea.templates.TemplateUtils) Collectors(java.util.stream.Collectors) IdDisplay(com.android.sdklib.repository.IdDisplay) Sets(com.google.common.collect.Sets) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) IAndroidTarget(com.android.sdklib.IAndroidTarget) Nullable(org.jetbrains.annotations.Nullable) SdkVersionInfo(com.android.sdklib.SdkVersionInfo) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) TypeDetails(com.android.repository.impl.meta.TypeDetails) ApplicationManager(com.intellij.openapi.application.ApplicationManager) RepoManager(com.android.repository.api.RepoManager) SystemImage(com.android.sdklib.repository.targets.SystemImage) NotNull(org.jetbrains.annotations.NotNull) RepoPackage(com.android.repository.api.RepoPackage)

Aggregations

RepoPackage (com.android.repository.api.RepoPackage)8 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 RemotePackage (com.android.repository.api.RemotePackage)2 UpdatablePackage (com.android.repository.api.UpdatablePackage)2 AndroidVersion (com.android.sdklib.AndroidVersion)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)2 NotNull (org.jetbrains.annotations.NotNull)2 SdkConstants (com.android.SdkConstants)1 RepoManager (com.android.repository.api.RepoManager)1 TypeDetails (com.android.repository.impl.meta.TypeDetails)1 AndroidTargetHash (com.android.sdklib.AndroidTargetHash)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 SdkVersionInfo (com.android.sdklib.SdkVersionInfo)1 IdDisplay (com.android.sdklib.repository.IdDisplay)1 AndroidTargetManager (com.android.sdklib.repository.targets.AndroidTargetManager)1 SystemImage (com.android.sdklib.repository.targets.SystemImage)1 GradleDependencyManager (com.android.tools.idea.gradle.dependencies.GradleDependencyManager)1