Skip to content

Commit c94368e

Browse files
committed
Rename ContributeLibrary and ContributeLibraryReleases
the classes have been renamed as: ContributedLibrary -> ContributedLibraryRelease ContributedLibraryReleases -> ContributedLibrary The reason is that a ContributedLibrary will have a name and a list of releases, each one containing the relative metadata. The changes to reflect that will be made in the next commits.
1 parent 95a5189 commit c94368e

23 files changed

+373
-373
lines changed

app/src/cc/arduino/contributions/libraries/filters/UpdatableLibraryPredicate.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
import java.util.function.Predicate;
3434

3535
import cc.arduino.contributions.VersionComparator;
36-
import cc.arduino.contributions.libraries.ContributedLibrary;
36+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
3737
import cc.arduino.contributions.libraries.LibrariesIndexer;
3838
import processing.app.BaseNoGui;
3939

40-
public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary> {
40+
public class UpdatableLibraryPredicate implements Predicate<ContributedLibraryRelease> {
4141

4242
LibrariesIndexer librariesIndexer;
4343

@@ -50,13 +50,13 @@ public UpdatableLibraryPredicate(LibrariesIndexer indexer) {
5050
}
5151

5252
@Override
53-
public boolean test(ContributedLibrary lib) {
53+
public boolean test(ContributedLibraryRelease lib) {
5454
if (!lib.isLibraryInstalled()) {
5555
return false;
5656
}
5757
String libraryName = lib.getName();
58-
List<ContributedLibrary> libraries = librariesIndexer.getIndex().find(libraryName);
59-
ContributedLibrary latest = libraries.stream().reduce(VersionComparator::max).get();
58+
List<ContributedLibraryRelease> libraries = librariesIndexer.getIndex().find(libraryName);
59+
ContributedLibraryRelease latest = libraries.stream().reduce(VersionComparator::max).get();
6060
return !latest.isLibraryInstalled();
6161
}
6262
}

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryReleasesComparator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
package cc.arduino.contributions.libraries.ui;
3131

32+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
3233
import cc.arduino.contributions.libraries.ContributedLibrary;
33-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
3434

3535
import java.util.Comparator;
3636

37-
public class ContributedLibraryReleasesComparator implements Comparator<ContributedLibraryReleases> {
37+
public class ContributedLibraryReleasesComparator implements Comparator<ContributedLibrary> {
3838

3939
private final String firstType;
4040

@@ -43,9 +43,9 @@ public ContributedLibraryReleasesComparator(String firstType) {
4343
}
4444

4545
@Override
46-
public int compare(ContributedLibraryReleases o1, ContributedLibraryReleases o2) {
47-
ContributedLibrary lib1 = o1.getLatest();
48-
ContributedLibrary lib2 = o2.getLatest();
46+
public int compare(ContributedLibrary o1, ContributedLibrary o2) {
47+
ContributedLibraryRelease lib1 = o1.getLatest();
48+
ContributedLibraryRelease lib2 = o2.getLatest();
4949

5050
if (lib1.getTypes() == null || lib2.getTypes() == null) {
5151
return compareName(lib1, lib2);
@@ -62,7 +62,7 @@ public int compare(ContributedLibraryReleases o1, ContributedLibraryReleases o2)
6262
return compareName(lib1, lib2);
6363
}
6464

65-
private int compareName(ContributedLibrary lib1, ContributedLibrary lib2) {
65+
private int compareName(ContributedLibraryRelease lib1, ContributedLibraryRelease lib2) {
6666
return lib1.getName().compareToIgnoreCase(lib2.getName());
6767
}
6868

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343

4444
import cc.arduino.contributions.DownloadableContributionVersionComparator;
4545
import cc.arduino.contributions.VersionComparator;
46+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
4647
import cc.arduino.contributions.libraries.ContributedLibrary;
47-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
4848
import cc.arduino.contributions.ui.InstallerTableCell;
4949
import cc.arduino.utils.ReverseComparator;
5050

5151
@SuppressWarnings("serial")
5252
public class ContributedLibraryTableCellEditor extends InstallerTableCell {
5353

54-
private ContributedLibraryReleases editorValue;
54+
private ContributedLibrary editorValue;
5555
private ContributedLibraryTableCellJPanel editorCell;
5656

5757
@Override
@@ -63,30 +63,30 @@ public Object getCellEditorValue() {
6363
public Component getTableCellEditorComponent(JTable table, Object value,
6464
boolean isSelected, int row,
6565
int column) {
66-
editorValue = (ContributedLibraryReleases) value;
66+
editorValue = (ContributedLibrary) value;
6767

6868
editorCell = new ContributedLibraryTableCellJPanel(table, value, true);
6969
editorCell.installButton
7070
.addActionListener(e -> onInstall(editorValue.getSelected(),
7171
editorValue.getInstalled()));
7272
editorCell.downgradeButton.addActionListener(e -> {
7373
JComboBox chooser = editorCell.downgradeChooser;
74-
ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem();
74+
ContributedLibraryRelease lib = (ContributedLibraryRelease) chooser.getSelectedItem();
7575
onInstall(lib, editorValue.getInstalled());
7676
});
7777
editorCell.versionToInstallChooser.addActionListener(e -> {
78-
editorValue.select((ContributedLibrary) editorCell.versionToInstallChooser.getSelectedItem());
78+
editorValue.select((ContributedLibraryRelease) editorCell.versionToInstallChooser.getSelectedItem());
7979
if (editorCell.versionToInstallChooser.getSelectedIndex() != 0) {
8080
InstallerTableCell.dropdownSelected(true);
8181
}
8282
});
8383

8484
setEnabled(true);
8585

86-
final Optional<ContributedLibrary> mayInstalled = editorValue.getInstalled();
86+
final Optional<ContributedLibraryRelease> mayInstalled = editorValue.getInstalled();
8787

88-
List<ContributedLibrary> releases = editorValue.getReleases();
89-
List<ContributedLibrary> notInstalled = new LinkedList<>(releases);
88+
List<ContributedLibraryRelease> releases = editorValue.getReleases();
89+
List<ContributedLibraryRelease> notInstalled = new LinkedList<>(releases);
9090
if (mayInstalled.isPresent()) {
9191
notInstalled.remove(editorValue.getInstalled().get());
9292
}
@@ -97,8 +97,8 @@ public Component getTableCellEditorComponent(JTable table, Object value,
9797
editorCell.downgradeChooser.removeAllItems();
9898
editorCell.downgradeChooser.addItem(tr("Select version"));
9999

100-
final List<ContributedLibrary> notInstalledPrevious = new LinkedList<>();
101-
final List<ContributedLibrary> notInstalledNewer = new LinkedList<>();
100+
final List<ContributedLibraryRelease> notInstalledPrevious = new LinkedList<>();
101+
final List<ContributedLibraryRelease> notInstalledNewer = new LinkedList<>();
102102

103103
notInstalled.stream().forEach(input -> {
104104
if (!mayInstalled.isPresent()
@@ -139,12 +139,12 @@ public void setStatus(String status) {
139139
editorCell.statusLabel.setText(status);
140140
}
141141

142-
protected void onRemove(ContributedLibrary selected) {
142+
protected void onRemove(ContributedLibraryRelease selected) {
143143
// Empty
144144
}
145145

146-
protected void onInstall(ContributedLibrary selected,
147-
Optional<ContributedLibrary> mayInstalled) {
146+
protected void onInstall(ContributedLibraryRelease selected,
147+
Optional<ContributedLibraryRelease> mayInstalled) {
148148
// Empty
149149
}
150150

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import javax.swing.text.html.StyleSheet;
1616

1717
import cc.arduino.contributions.DownloadableContributionVersionComparator;
18+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
1819
import cc.arduino.contributions.libraries.ContributedLibrary;
19-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
2020
import cc.arduino.contributions.ui.InstallerTableCell;
2121
import processing.app.Base;
2222
import processing.app.PreferencesData;
@@ -113,17 +113,17 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
113113

114114
add(Box.createVerticalStrut(15));
115115

116-
ContributedLibraryReleases releases = (ContributedLibraryReleases) value;
116+
ContributedLibrary releases = (ContributedLibrary) value;
117117

118118
// FIXME: happens on macosx, don't know why
119119
if (releases == null)
120120
return;
121121

122-
ContributedLibrary selected = releases.getSelected();
122+
ContributedLibraryRelease selected = releases.getSelected();
123123
TitledBorder titledBorder = BorderFactory.createTitledBorder(selected.getName());
124124
titledBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
125125
setBorder(titledBorder);
126-
Optional<ContributedLibrary> mayInstalled = releases.getInstalled();
126+
Optional<ContributedLibraryRelease> mayInstalled = releases.getInstalled();
127127

128128
boolean installable, upgradable;
129129
if (!mayInstalled.isPresent()) {

app/src/cc/arduino/contributions/libraries/ui/DropdownAllLibraries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929

3030
package cc.arduino.contributions.libraries.ui;
3131

32-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
32+
import cc.arduino.contributions.libraries.ContributedLibrary;
3333
import cc.arduino.contributions.ui.DropdownItem;
3434

3535
import java.util.function.Predicate;
3636

3737
import static processing.app.I18n.tr;
3838

39-
public class DropdownAllLibraries implements DropdownItem<ContributedLibraryReleases> {
39+
public class DropdownAllLibraries implements DropdownItem<ContributedLibrary> {
4040

4141
public String toString() {
4242
return tr("All");
4343
}
4444

4545
@Override
46-
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
46+
public Predicate<ContributedLibrary> getFilterPredicate() {
4747
return x -> true;
4848
}
4949

app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@
3333

3434
import java.util.function.Predicate;
3535

36-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
36+
import cc.arduino.contributions.libraries.ContributedLibrary;
3737
import cc.arduino.contributions.ui.DropdownItem;
3838

39-
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibraryReleases> {
39+
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibrary> {
4040

4141
public String toString() {
4242
return tr("Installed");
4343
}
4444

4545
@Override
46-
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
47-
return new Predicate<ContributedLibraryReleases>() {
46+
public Predicate<ContributedLibrary> getFilterPredicate() {
47+
return new Predicate<ContributedLibrary>() {
4848
@Override
49-
public boolean test(ContributedLibraryReleases t) {
49+
public boolean test(ContributedLibrary t) {
5050
return t.getInstalled().isPresent();
5151
}
5252
};

app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929

3030
package cc.arduino.contributions.libraries.ui;
3131

32+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
3233
import cc.arduino.contributions.libraries.ContributedLibrary;
33-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
3434
import cc.arduino.contributions.ui.DropdownItem;
3535

3636
import java.util.function.Predicate;
3737

3838
import static processing.app.I18n.tr;
3939

40-
public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibraryReleases> {
40+
public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibrary> {
4141

4242
private final String category;
4343

@@ -50,11 +50,11 @@ public String toString() {
5050
}
5151

5252
@Override
53-
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
54-
return new Predicate<ContributedLibraryReleases>() {
53+
public Predicate<ContributedLibrary> getFilterPredicate() {
54+
return new Predicate<ContributedLibrary>() {
5555
@Override
56-
public boolean test(ContributedLibraryReleases rel) {
57-
ContributedLibrary lib = rel.getLatest();
56+
public boolean test(ContributedLibrary rel) {
57+
ContributedLibraryRelease lib = rel.getLatest();
5858
return category.equals(lib.getCategory());
5959
}
6060
};

app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929

3030
package cc.arduino.contributions.libraries.ui;
3131

32-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
32+
import cc.arduino.contributions.libraries.ContributedLibrary;
3333
import cc.arduino.contributions.ui.DropdownItem;
3434

3535
import java.util.List;
3636
import java.util.function.Predicate;
3737

3838
import static processing.app.I18n.tr;
3939

40-
public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibraryReleases> {
40+
public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibrary> {
4141

4242
private final String type;
4343

@@ -50,10 +50,10 @@ public String toString() {
5050
}
5151

5252
@Override
53-
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
54-
return new Predicate<ContributedLibraryReleases>() {
53+
public Predicate<ContributedLibrary> getFilterPredicate() {
54+
return new Predicate<ContributedLibrary>() {
5555
@Override
56-
public boolean test(ContributedLibraryReleases lib) {
56+
public boolean test(ContributedLibrary lib) {
5757
List<String> types = lib.getLatest().getTypes();
5858
return types != null && types.contains(type);
5959
}

app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@
2929

3030
package cc.arduino.contributions.libraries.ui;
3131

32+
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
3233
import cc.arduino.contributions.libraries.ContributedLibrary;
33-
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
3434
import cc.arduino.contributions.ui.DropdownItem;
3535

3636
import java.util.Optional;
3737
import java.util.function.Predicate;
3838

3939
import static processing.app.I18n.tr;
4040

41-
public class DropdownUpdatableLibrariesItem implements DropdownItem<ContributedLibraryReleases> {
41+
public class DropdownUpdatableLibrariesItem implements DropdownItem<ContributedLibrary> {
4242

4343
@Override
44-
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
45-
return new Predicate<ContributedLibraryReleases>() {
44+
public Predicate<ContributedLibrary> getFilterPredicate() {
45+
return new Predicate<ContributedLibrary>() {
4646
@Override
47-
public boolean test(ContributedLibraryReleases lib) {
48-
Optional<ContributedLibrary> mayInstalled = lib.getInstalled();
47+
public boolean test(ContributedLibrary lib) {
48+
Optional<ContributedLibraryRelease> mayInstalled = lib.getInstalled();
4949
if (!mayInstalled.isPresent()) {
5050
return false;
5151
}

0 commit comments

Comments
 (0)