71
71
@ SuppressWarnings ("serial" )
72
72
public class ContributedLibraryTableCell extends InstallerTableCell {
73
73
74
- class Cell {
74
+ private class Cell {
75
75
private final JPanel panel ;
76
76
private final JButton installButton ;
77
77
private final Component installButtonPlaceholder ;
78
- private JComboBox downgradeChooser ;
78
+ private final JComboBox downgradeChooser ;
79
79
private final JComboBox versionToInstallChooser ;
80
80
private final JButton downgradeButton ;
81
81
private final JPanel buttonsPanel ;
@@ -84,18 +84,10 @@ class Cell {
84
84
85
85
public Cell () {
86
86
installButton = new JButton (tr ("Install" ));
87
- installButton
88
- .addActionListener (e -> onInstall (editorValue .getSelected (),
89
- editorValue .getInstalled ()));
90
87
int width = installButton .getPreferredSize ().width ;
91
88
installButtonPlaceholder = Box .createRigidArea (new Dimension (width , 1 ));
92
89
93
90
downgradeButton = new JButton (tr ("Install" ));
94
- downgradeButton .addActionListener (e -> {
95
- ContributedLibrary selected = (ContributedLibrary ) downgradeChooser
96
- .getSelectedItem ();
97
- onInstall (selected , editorValue .getInstalled ());
98
- });
99
91
100
92
downgradeChooser = new JComboBox ();
101
93
downgradeChooser .addItem ("-" );
@@ -110,9 +102,6 @@ public Cell() {
110
102
versionToInstallChooser .addItem ("-" );
111
103
versionToInstallChooser
112
104
.setMaximumSize (versionToInstallChooser .getPreferredSize ());
113
- versionToInstallChooser .addItemListener (e -> editorValue
114
- .select ((ContributedLibrary ) versionToInstallChooser
115
- .getSelectedItem ()));
116
105
117
106
panel = new JPanel ();
118
107
panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
@@ -341,7 +330,19 @@ public Component getTableCellEditorComponent(JTable table, Object value,
341
330
boolean isSelected , int row ,
342
331
int column ) {
343
332
editorValue = (ContributedLibraryReleases ) value ;
333
+
344
334
editorCell = new Cell ();
335
+ editorCell .installButton
336
+ .addActionListener (e -> onInstall (editorValue .getSelected (),
337
+ editorValue .getInstalled ()));
338
+ editorCell .downgradeButton .addActionListener (e -> {
339
+ JComboBox chooser = editorCell .downgradeChooser ;
340
+ ContributedLibrary lib = (ContributedLibrary ) chooser .getSelectedItem ();
341
+ onInstall (lib , editorValue .getInstalled ());
342
+ });
343
+ editorCell .versionToInstallChooser .addItemListener (e -> editorValue
344
+ .select ((ContributedLibrary ) editorCell .versionToInstallChooser
345
+ .getSelectedItem ()));
345
346
346
347
setEnabled (true );
347
348
0 commit comments