36
36
import java .util .Collections ;
37
37
import java .util .LinkedList ;
38
38
import java .util .List ;
39
+ import java .util .Map ;
39
40
import java .util .Optional ;
40
41
41
42
import javax .swing .JComboBox ;
42
43
import javax .swing .JTable ;
43
44
44
- import cc .arduino .contributions .DownloadableContributionVersionComparator ;
45
45
import cc .arduino .contributions .VersionComparator ;
46
46
import cc .arduino .contributions .libraries .ContributedLibrary ;
47
47
import cc .arduino .contributions .libraries .ContributedLibraryReleases ;
48
48
import cc .arduino .contributions .ui .InstallerTableCell ;
49
- import cc .arduino .utils .ReverseComparator ;
50
49
51
50
@ SuppressWarnings ("serial" )
52
51
public class ContributedLibraryTableCellEditor extends InstallerTableCell {
@@ -67,12 +66,11 @@ public Component getTableCellEditorComponent(JTable table, Object value,
67
66
68
67
editorCell = new ContributedLibraryTableCellJPanel (table , value , true );
69
68
editorCell .installButton
70
- .addActionListener (e -> onInstall (editorValue .getSelected (),
71
- editorValue .getInstalled ()));
69
+ .addActionListener (e -> onInstall (editorValue .getSelected ()));
72
70
editorCell .downgradeButton .addActionListener (e -> {
73
71
JComboBox chooser = editorCell .downgradeChooser ;
74
72
ContributedLibrary lib = (ContributedLibrary ) chooser .getSelectedItem ();
75
- onInstall (lib , editorValue . getInstalled () );
73
+ onInstall (lib );
76
74
});
77
75
editorCell .versionToInstallChooser .addActionListener (e -> {
78
76
editorValue .select ((ContributedLibrary ) editorCell .versionToInstallChooser .getSelectedItem ());
@@ -83,24 +81,24 @@ public Component getTableCellEditorComponent(JTable table, Object value,
83
81
84
82
setEnabled (true );
85
83
86
- final Optional <ContributedLibrary > mayInstalled = editorValue .getInstalled ();
84
+ Map <String , ContributedLibrary > releases = editorValue .getReleases ();
85
+ List <ContributedLibrary > notInstalled = new LinkedList <>(releases .values ());
87
86
88
- List <ContributedLibrary > releases = editorValue .getReleases ();
89
- List <ContributedLibrary > notInstalled = new LinkedList <>(releases );
87
+ final Optional <ContributedLibrary > mayInstalled = editorValue .getInstalled ();
90
88
if (mayInstalled .isPresent ()) {
91
- notInstalled .remove (editorValue . getInstalled () .get ());
89
+ notInstalled .remove (mayInstalled .get ());
92
90
}
93
91
94
- Collections .sort (notInstalled , new ReverseComparator <>(
95
- new DownloadableContributionVersionComparator ()) );
92
+ Collections .sort (notInstalled , VersionComparator :: compareTo );
93
+ Collections . reverse ( notInstalled );
96
94
97
95
editorCell .downgradeChooser .removeAllItems ();
98
96
editorCell .downgradeChooser .addItem (tr ("Select version" ));
99
97
100
98
final List <ContributedLibrary > notInstalledPrevious = new LinkedList <>();
101
99
final List <ContributedLibrary > notInstalledNewer = new LinkedList <>();
102
100
103
- notInstalled .stream (). forEach (input -> {
101
+ notInstalled .forEach (input -> {
104
102
if (!mayInstalled .isPresent ()
105
103
|| VersionComparator .greaterThan (mayInstalled .get (), input )) {
106
104
notInstalledPrevious .add (input );
@@ -142,8 +140,7 @@ protected void onRemove(ContributedLibrary selected) {
142
140
// Empty
143
141
}
144
142
145
- protected void onInstall (ContributedLibrary selected ,
146
- Optional <ContributedLibrary > mayInstalled ) {
143
+ protected void onInstall (ContributedLibrary selected ) {
147
144
// Empty
148
145
}
149
146
0 commit comments