|
37 | 37 | import java.util.LinkedList; |
38 | 38 | import java.util.List; |
39 | 39 | import java.util.Optional; |
40 | | -import java.util.stream.Collectors; |
41 | 40 |
|
42 | 41 | import javax.swing.JComboBox; |
43 | 42 | import javax.swing.JTable; |
44 | 43 |
|
45 | 44 | import cc.arduino.contributions.DownloadableContributionVersionComparator; |
46 | 45 | import cc.arduino.contributions.VersionComparator; |
47 | | -import cc.arduino.contributions.filters.BuiltInPredicate; |
48 | 46 | import cc.arduino.contributions.libraries.ContributedLibrary; |
49 | 47 | import cc.arduino.contributions.libraries.ContributedLibraryReleases; |
50 | 48 | import cc.arduino.contributions.ui.InstallerTableCell; |
@@ -88,50 +86,44 @@ public Component getTableCellEditorComponent(JTable table, Object value, |
88 | 86 | final Optional<ContributedLibrary> mayInstalled = editorValue.getInstalled(); |
89 | 87 |
|
90 | 88 | List<ContributedLibrary> releases = editorValue.getReleases(); |
91 | | - List<ContributedLibrary> uninstalledReleases = releases.stream() |
92 | | - .filter(l -> !l.isLibraryInstalled()).collect(Collectors.toList()); |
93 | | - |
94 | | - List<ContributedLibrary> installedBuiltIn = releases.stream() |
95 | | - .filter(l -> !l.isLibraryInstalled()).filter(new BuiltInPredicate()) |
96 | | - .collect(Collectors.toList()); |
97 | | - |
98 | | - if (mayInstalled.isPresent() && !installedBuiltIn.contains(mayInstalled.get())) { |
99 | | - uninstalledReleases.addAll(installedBuiltIn); |
| 89 | + List<ContributedLibrary> notInstalled = new LinkedList<>(releases); |
| 90 | + if (mayInstalled.isPresent()) { |
| 91 | + notInstalled.remove(editorValue.getInstalled().get()); |
100 | 92 | } |
101 | 93 |
|
102 | | - Collections.sort(uninstalledReleases, new ReverseComparator<>( |
| 94 | + Collections.sort(notInstalled, new ReverseComparator<>( |
103 | 95 | new DownloadableContributionVersionComparator())); |
104 | 96 |
|
105 | 97 | editorCell.downgradeChooser.removeAllItems(); |
106 | 98 | editorCell.downgradeChooser.addItem(tr("Select version")); |
107 | 99 |
|
108 | | - final List<ContributedLibrary> uninstalledPreviousReleases = new LinkedList<>(); |
109 | | - final List<ContributedLibrary> uninstalledNewerReleases = new LinkedList<>(); |
| 100 | + final List<ContributedLibrary> notInstalledPrevious = new LinkedList<>(); |
| 101 | + final List<ContributedLibrary> notIInstalledNewer = new LinkedList<>(); |
110 | 102 |
|
111 | | - uninstalledReleases.stream().forEach(input -> { |
| 103 | + notInstalled.stream().forEach(input -> { |
112 | 104 | if (!mayInstalled.isPresent() |
113 | 105 | || VersionComparator.greaterThan(mayInstalled.get(), input)) { |
114 | | - uninstalledPreviousReleases.add(input); |
| 106 | + notInstalledPrevious.add(input); |
115 | 107 | } else { |
116 | | - uninstalledNewerReleases.add(input); |
| 108 | + notIInstalledNewer.add(input); |
117 | 109 | } |
118 | 110 | }); |
119 | | - uninstalledNewerReleases.forEach(editorCell.downgradeChooser::addItem); |
120 | | - uninstalledPreviousReleases.forEach(editorCell.downgradeChooser::addItem); |
| 111 | + notIInstalledNewer.forEach(editorCell.downgradeChooser::addItem); |
| 112 | + notInstalledPrevious.forEach(editorCell.downgradeChooser::addItem); |
121 | 113 |
|
122 | 114 | editorCell.downgradeChooser |
123 | 115 | .setVisible(mayInstalled.isPresent() |
124 | | - && (!uninstalledPreviousReleases.isEmpty() |
125 | | - || uninstalledNewerReleases.size() > 1)); |
| 116 | + && (!notInstalledPrevious.isEmpty() |
| 117 | + || notIInstalledNewer.size() > 1)); |
126 | 118 | editorCell.downgradeButton |
127 | 119 | .setVisible(mayInstalled.isPresent() |
128 | | - && (!uninstalledPreviousReleases.isEmpty() |
129 | | - || uninstalledNewerReleases.size() > 1)); |
| 120 | + && (!notInstalledPrevious.isEmpty() |
| 121 | + || notIInstalledNewer.size() > 1)); |
130 | 122 |
|
131 | 123 | editorCell.versionToInstallChooser.removeAllItems(); |
132 | | - uninstalledReleases.forEach(editorCell.versionToInstallChooser::addItem); |
| 124 | + notInstalled.forEach(editorCell.versionToInstallChooser::addItem); |
133 | 125 | editorCell.versionToInstallChooser |
134 | | - .setVisible(!mayInstalled.isPresent() && uninstalledReleases.size() > 1); |
| 126 | + .setVisible(!mayInstalled.isPresent() && notInstalled.size() > 1); |
135 | 127 |
|
136 | 128 | editorCell.setBackground(new Color(218, 227, 227)); // #dae3e3 |
137 | 129 | return editorCell; |
|
0 commit comments