1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Removed ContributedLibraryTableCell.Cell dependency from upper editorValue field

This commit is contained in:
Cristian Maglie 2015-12-24 17:17:51 +01:00
parent 268ae81759
commit ed30cd7b58

View File

@ -71,11 +71,11 @@ import processing.app.Base;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ContributedLibraryTableCell extends InstallerTableCell { public class ContributedLibraryTableCell extends InstallerTableCell {
class Cell { private class Cell {
private final JPanel panel; private final JPanel panel;
private final JButton installButton; private final JButton installButton;
private final Component installButtonPlaceholder; private final Component installButtonPlaceholder;
private JComboBox downgradeChooser; private final JComboBox downgradeChooser;
private final JComboBox versionToInstallChooser; private final JComboBox versionToInstallChooser;
private final JButton downgradeButton; private final JButton downgradeButton;
private final JPanel buttonsPanel; private final JPanel buttonsPanel;
@ -84,18 +84,10 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
public Cell() { public Cell() {
installButton = new JButton(tr("Install")); installButton = new JButton(tr("Install"));
installButton
.addActionListener(e -> onInstall(editorValue.getSelected(),
editorValue.getInstalled()));
int width = installButton.getPreferredSize().width; int width = installButton.getPreferredSize().width;
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1)); installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
downgradeButton = new JButton(tr("Install")); downgradeButton = new JButton(tr("Install"));
downgradeButton.addActionListener(e -> {
ContributedLibrary selected = (ContributedLibrary) downgradeChooser
.getSelectedItem();
onInstall(selected, editorValue.getInstalled());
});
downgradeChooser = new JComboBox(); downgradeChooser = new JComboBox();
downgradeChooser.addItem("-"); downgradeChooser.addItem("-");
@ -110,9 +102,6 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
versionToInstallChooser.addItem("-"); versionToInstallChooser.addItem("-");
versionToInstallChooser versionToInstallChooser
.setMaximumSize(versionToInstallChooser.getPreferredSize()); .setMaximumSize(versionToInstallChooser.getPreferredSize());
versionToInstallChooser.addItemListener(e -> editorValue
.select((ContributedLibrary) versionToInstallChooser
.getSelectedItem()));
panel = new JPanel(); panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
@ -341,7 +330,19 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
boolean isSelected, int row, boolean isSelected, int row,
int column) { int column) {
editorValue = (ContributedLibraryReleases) value; editorValue = (ContributedLibraryReleases) value;
editorCell = new Cell(); editorCell = new Cell();
editorCell.installButton
.addActionListener(e -> onInstall(editorValue.getSelected(),
editorValue.getInstalled()));
editorCell.downgradeButton.addActionListener(e -> {
JComboBox chooser = editorCell.downgradeChooser;
ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem();
onInstall(lib, editorValue.getInstalled());
});
editorCell.versionToInstallChooser.addItemListener(e -> editorValue
.select((ContributedLibrary) editorCell.versionToInstallChooser
.getSelectedItem()));
setEnabled(true); setEnabled(true);