7171@ SuppressWarnings ("serial" )
7272public class ContributedLibraryTableCell extends InstallerTableCell {
7373
74- class Cell {
74+ private class Cell {
7575 private final JPanel panel ;
7676 private final JButton installButton ;
7777 private final Component installButtonPlaceholder ;
78- private JComboBox downgradeChooser ;
78+ private final JComboBox downgradeChooser ;
7979 private final JComboBox versionToInstallChooser ;
8080 private final JButton downgradeButton ;
8181 private final JPanel buttonsPanel ;
@@ -84,18 +84,10 @@ class Cell {
8484
8585 public Cell () {
8686 installButton = new JButton (tr ("Install" ));
87- installButton
88- .addActionListener (e -> onInstall (editorValue .getSelected (),
89- editorValue .getInstalled ()));
9087 int width = installButton .getPreferredSize ().width ;
9188 installButtonPlaceholder = Box .createRigidArea (new Dimension (width , 1 ));
9289
9390 downgradeButton = new JButton (tr ("Install" ));
94- downgradeButton .addActionListener (e -> {
95- ContributedLibrary selected = (ContributedLibrary ) downgradeChooser
96- .getSelectedItem ();
97- onInstall (selected , editorValue .getInstalled ());
98- });
9991
10092 downgradeChooser = new JComboBox ();
10193 downgradeChooser .addItem ("-" );
@@ -110,9 +102,6 @@ public Cell() {
110102 versionToInstallChooser .addItem ("-" );
111103 versionToInstallChooser
112104 .setMaximumSize (versionToInstallChooser .getPreferredSize ());
113- versionToInstallChooser .addItemListener (e -> editorValue
114- .select ((ContributedLibrary ) versionToInstallChooser
115- .getSelectedItem ()));
116105
117106 panel = new JPanel ();
118107 panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
@@ -341,7 +330,19 @@ public Component getTableCellEditorComponent(JTable table, Object value,
341330 boolean isSelected , int row ,
342331 int column ) {
343332 editorValue = (ContributedLibraryReleases ) value ;
333+
344334 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 ()));
345346
346347 setEnabled (true );
347348
0 commit comments