Search in sources :

Example 1 with UpdatablePackage

use of com.android.repository.api.UpdatablePackage 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 UpdatablePackage

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

the class ToolComponentsPanel method setPackages.

public void setPackages(@NotNull Set<UpdatablePackage> toolsPackages) {
    myMultiVersionPackages.clear();
    myToolsPackages.clear();
    for (UpdatablePackage p : toolsPackages) {
        String prefix = p.getRepresentative().getPath();
        int lastSegmentIndex = prefix.lastIndexOf(';');
        boolean found = false;
        if (lastSegmentIndex > 0) {
            prefix = prefix.substring(0, lastSegmentIndex);
            if (prefix.equals(PatchInstallerUtil.PATCHER_PATH_PREFIX)) {
                // We don't want to show the patcher in the UI
                continue;
            }
            if (MULTI_VERSION_PREFIXES.contains(prefix) || p.getRepresentative().getTypeDetails() instanceof DetailsTypes.MavenType) {
                myMultiVersionPackages.put(prefix, p);
                found = true;
            }
        }
        if (!found) {
            myToolsPackages.add(p);
        }
    }
    updateToolsItems();
}
Also used : DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) UpdatablePackage(com.android.repository.api.UpdatablePackage)

Example 3 with UpdatablePackage

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

the class InstallableComponent method getPackagesToInstall.

/**
   * Gets the packages that this component would actually install (the required packages that aren't already installed
   * or have an update available, if we're installing updates).
   */
@NotNull
public Collection<UpdatablePackage> getPackagesToInstall() {
    List<UpdatablePackage> result = Lists.newArrayList();
    Map<String, UpdatablePackage> consolidatedPackages = getRepositoryPackages().getConsolidatedPkgs();
    for (String path : getRequiredSdkPackages()) {
        UpdatablePackage p = consolidatedPackages.get(path);
        if (p != null && p.hasRemote() && (!p.hasLocal() || (myInstallUpdates && p.isUpdate()))) {
            result.add(p);
        }
    }
    return result;
}
Also used : UpdatablePackage(com.android.repository.api.UpdatablePackage) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with UpdatablePackage

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

the class ToolComponentsPanel method updateToolsItems.

private void updateToolsItems() {
    myToolsDetailsRootNode.removeAllChildren();
    myToolsSummaryRootNode.removeAllChildren();
    myStates.clear();
    ParentTreeNode mavenSummaryParent = new ParentTreeNode("Support Repository");
    ParentTreeNode mavenDetailsParent = new ParentTreeNode("Support Repository");
    for (String prefix : myMultiVersionPackages.keySet()) {
        Collection<UpdatablePackage> versions = myMultiVersionPackages.get(prefix);
        Set<DetailsTreeNode> detailsNodes = new TreeSet<>();
        boolean isMaven = false;
        for (UpdatablePackage info : versions) {
            RepoPackage representative = info.getRepresentative();
            if (representative.getTypeDetails() instanceof DetailsTypes.MavenType) {
                isMaven = true;
            }
            PackageNodeModel model = new PackageNodeModel(info);
            myStates.add(model);
            detailsNodes.add(new DetailsTreeNode(model, myModificationListener, myConfigurable));
        }
        MultiVersionTreeNode summaryNode = new MultiVersionTreeNode(detailsNodes);
        if (isMaven) {
            mavenSummaryParent.add(summaryNode);
        } else {
            myToolsSummaryRootNode.add(summaryNode);
        }
        UpdaterTreeNode multiVersionParent = new ParentTreeNode(summaryNode.getDisplayName());
        detailsNodes.forEach(multiVersionParent::add);
        if (isMaven) {
            mavenDetailsParent.add(multiVersionParent);
        } else {
            myToolsDetailsRootNode.add(multiVersionParent);
        }
    }
    for (UpdatablePackage info : myToolsPackages) {
        PackageNodeModel holder = new PackageNodeModel(info);
        myStates.add(holder);
        UpdaterTreeNode node = new DetailsTreeNode(holder, myModificationListener, myConfigurable);
        boolean isMaven = info.getPath().endsWith(RepoPackage.PATH_SEPARATOR + MavenInstallListener.MAVEN_DIR_NAME);
        if (isMaven) {
            mavenDetailsParent.add(node);
        } else {
            myToolsDetailsRootNode.add(node);
        }
        if (!info.getRepresentative().obsolete()) {
            UpdaterTreeNode summaryNode = new DetailsTreeNode(holder, myModificationListener, myConfigurable);
            if (isMaven) {
                mavenSummaryParent.add(summaryNode);
            } else {
                myToolsSummaryRootNode.add(summaryNode);
            }
        }
    }
    if (mavenSummaryParent.getChildCount() > 0) {
        myToolsSummaryRootNode.add(mavenSummaryParent);
        myToolsDetailsRootNode.add(mavenDetailsParent);
    }
    refreshModified();
    SdkUpdaterConfigPanel.resizeColumnsToFit(myToolsDetailTable);
    SdkUpdaterConfigPanel.resizeColumnsToFit(myToolsSummaryTable);
    myToolsDetailTable.updateUI();
    myToolsSummaryTable.updateUI();
    TreeUtil.expandAll(myToolsDetailTable.getTree());
    TreeUtil.expandAll(myToolsSummaryTable.getTree());
}
Also used : UpdatablePackage(com.android.repository.api.UpdatablePackage) RepoPackage(com.android.repository.api.RepoPackage)

Aggregations

UpdatablePackage (com.android.repository.api.UpdatablePackage)4 RepoPackage (com.android.repository.api.RepoPackage)2 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 NotNull (org.jetbrains.annotations.NotNull)1