Skip to content

Added basic "deprecation" support for platforms #11508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public class ContributedPlatformReleases {
public final List<ContributedPlatform> releases;
public final List<String> versions;
public ContributedPlatform selected = null;
public boolean deprecated;

public ContributedPlatformReleases(ContributedPlatform platform) {
packager = platform.getParentPackage();
arch = platform.getArchitecture();
releases = new LinkedList<>();
versions = new LinkedList<>();
deprecated = platform.isDeprecated();
add(platform);
}

Expand All @@ -65,7 +67,9 @@ public void add(ContributedPlatform platform) {
if (version != null) {
versions.add(version);
}
selected = getLatest();
ContributedPlatform latest = getLatest();
selected = latest;
deprecated = latest.isDeprecated();
}

public ContributedPlatform getInstalled() {
Expand All @@ -89,6 +93,10 @@ public ContributedPlatform getSelected() {
return selected;
}

public boolean isDeprecated() {
return deprecated;
}

public void select(ContributedPlatform value) {
for (ContributedPlatform plat : releases) {
if (plat == value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ void update(JTable parentTable, Object value, boolean hasBuiltInRelease) {
+ format(tr("version <b>{0}</b>"), installed.getParsedVersion())
+ " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
}
if (releases.isDeprecated()) {
desc += " <strong><font color=\"#C03030\">DEPRECATED</font></strong>";
}
desc += "<br />";

desc += tr("Boards included in this package:") + "<br />";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import processing.app.BaseNoGui;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -73,6 +74,18 @@ private void updateContributions() {
addContribution(platform);
}
}
Collections.sort(contributions, (x,y)-> {
if (x.isDeprecated() != y.isDeprecated()) {
return x.isDeprecated() ? 1 : -1;
}
ContributedPlatform x1 = x.getLatest();
ContributedPlatform y1 = y.getLatest();
int category = (x1.getCategory().equals("Arduino") ? -1 : 0) + (y1.getCategory().equals("Arduino") ? 1 : 0);
if (category != 0) {
return category;
}
return x1.getName().compareToIgnoreCase(y1.getName());
});
fireTableDataChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@

package cc.arduino.contributions.packages;

import cc.arduino.contributions.DownloadableContribution;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.File;
import java.util.*;
import cc.arduino.contributions.DownloadableContribution;

public class ContributedPlatform extends DownloadableContribution {

Expand All @@ -45,21 +52,26 @@ public class ContributedPlatform extends DownloadableContribution {
private String category;
private String architecture;
private String checksum;
private ArrayList<ContributedToolReference> toolsDependencies = new ArrayList<ContributedToolReference>();
private ArrayList<ContributedBoard> boards = new ArrayList<ContributedBoard>();
private ArrayList<ContributedToolReference> toolsDependencies = new ArrayList<>();
private ArrayList<ContributedBoard> boards = new ArrayList<>();
private ContributedHelp help;
private boolean installed;
private File installedFolder;
private boolean builtIn;
private Map<ContributedToolReference, ContributedTool> resolvedToolReferences;
private ContributedPackage parentPackage;
private boolean deprecated;

@Override
public String getUrl() { return url; }

@Override
public String getVersion() { return version; }

@Override
public long getSize() { return size; }

@Override
public String getArchiveFileName() { return archiveFileName; }

public String getName() { return name; }
Expand Down Expand Up @@ -146,6 +158,14 @@ public void setParentPackage(ContributedPackage parentPackage) {
this.parentPackage = parentPackage;
}

public boolean isDeprecated() {
return deprecated;
}

public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}

@Override
public String toString() {
return getParsedVersion();
Expand Down