mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Factored out ContributedLibraryTableCell.update(...) method
This commit is contained in:
parent
71eb3c3ab2
commit
91f18dff24
@ -29,16 +29,17 @@ import processing.app.Base;
|
|||||||
|
|
||||||
public class ContributedLibraryTableCell extends JPanel {
|
public class ContributedLibraryTableCell extends JPanel {
|
||||||
|
|
||||||
protected final JButton installButton;
|
final JButton installButton;
|
||||||
protected final Component installButtonPlaceholder;
|
final Component installButtonPlaceholder;
|
||||||
protected final JComboBox downgradeChooser;
|
final JComboBox downgradeChooser;
|
||||||
protected final JComboBox versionToInstallChooser;
|
final JComboBox versionToInstallChooser;
|
||||||
protected final JButton downgradeButton;
|
final JButton downgradeButton;
|
||||||
protected final JPanel buttonsPanel;
|
final JPanel buttonsPanel;
|
||||||
protected final JPanel inactiveButtonsPanel;
|
final JPanel inactiveButtonsPanel;
|
||||||
protected final JLabel statusLabel;
|
final JLabel statusLabel;
|
||||||
|
|
||||||
public ContributedLibraryTableCell() {
|
public ContributedLibraryTableCell(JTable parentTable, Object value,
|
||||||
|
boolean isSelected) {
|
||||||
super();
|
super();
|
||||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
@ -99,11 +100,8 @@ public class ContributedLibraryTableCell extends JPanel {
|
|||||||
add(inactiveButtonsPanel);
|
add(inactiveButtonsPanel);
|
||||||
|
|
||||||
add(Box.createVerticalStrut(15));
|
add(Box.createVerticalStrut(15));
|
||||||
}
|
|
||||||
|
|
||||||
void update(JTable parentTable, Object value, boolean isSelected) {
|
|
||||||
ContributedLibraryReleases releases = (ContributedLibraryReleases) value;
|
ContributedLibraryReleases releases = (ContributedLibraryReleases) value;
|
||||||
|
|
||||||
JTextPane description = makeNewDescription();
|
JTextPane description = makeNewDescription();
|
||||||
|
|
||||||
// FIXME: happens on macosx, don't know why
|
// FIXME: happens on macosx, don't know why
|
||||||
@ -193,9 +191,9 @@ public class ContributedLibraryTableCell extends JPanel {
|
|||||||
|
|
||||||
// See:
|
// See:
|
||||||
// http://stackoverflow.com/questions/3081210/how-to-set-jtextarea-to-have-height-that-matches-the-size-of-a-text-it-contains
|
// http://stackoverflow.com/questions/3081210/how-to-set-jtextarea-to-have-height-that-matches-the-size-of-a-text-it-contains
|
||||||
int width = parentTable.getBounds().width;
|
InstallerTableCell
|
||||||
InstallerTableCell.setJTextPaneDimensionToFitContainedText(description,
|
.setJTextPaneDimensionToFitContainedText(description,
|
||||||
width);
|
parentTable.getBounds().width);
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
setBackground(parentTable.getSelectionBackground());
|
setBackground(parentTable.getSelectionBackground());
|
||||||
|
@ -67,7 +67,7 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
|
|||||||
int column) {
|
int column) {
|
||||||
editorValue = (ContributedLibraryReleases) value;
|
editorValue = (ContributedLibraryReleases) value;
|
||||||
|
|
||||||
editorCell = new ContributedLibraryTableCell();
|
editorCell = new ContributedLibraryTableCell(table, value, true);
|
||||||
editorCell.installButton
|
editorCell.installButton
|
||||||
.addActionListener(e -> onInstall(editorValue.getSelected(),
|
.addActionListener(e -> onInstall(editorValue.getSelected(),
|
||||||
editorValue.getInstalled()));
|
editorValue.getInstalled()));
|
||||||
@ -134,7 +134,6 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
|
|||||||
editorCell.versionToInstallChooser
|
editorCell.versionToInstallChooser
|
||||||
.setVisible(installed == null && uninstalledReleases.size() > 1);
|
.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||||
|
|
||||||
editorCell.update(table, value, true);
|
|
||||||
editorCell.setBackground(new Color(218, 227, 227)); // #dae3e3
|
editorCell.setBackground(new Color(218, 227, 227)); // #dae3e3
|
||||||
return editorCell;
|
return editorCell;
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,9 @@ public class ContributedLibraryTableCellRenderer implements TableCellRenderer {
|
|||||||
boolean isSelected,
|
boolean isSelected,
|
||||||
boolean hasFocus, int row,
|
boolean hasFocus, int row,
|
||||||
int column) {
|
int column) {
|
||||||
|
ContributedLibraryTableCell cell = new ContributedLibraryTableCell(table,
|
||||||
ContributedLibraryTableCell cell = new ContributedLibraryTableCell();
|
value, isSelected);
|
||||||
cell.setButtonsVisible(false);
|
cell.setButtonsVisible(false);
|
||||||
cell.update(table, value, isSelected);
|
|
||||||
|
|
||||||
if (row % 2 == 0) {
|
if (row % 2 == 0) {
|
||||||
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
|
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
|
||||||
@ -53,8 +52,7 @@ public class ContributedLibraryTableCellRenderer implements TableCellRenderer {
|
|||||||
cell.setBackground(new Color(255, 255, 255));
|
cell.setBackground(new Color(255, 255, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
int height = new Double(cell.getPreferredSize().getHeight())
|
int height = new Double(cell.getPreferredSize().getHeight()).intValue();
|
||||||
.intValue();
|
|
||||||
if (table.getRowHeight(row) < height) {
|
if (table.getRowHeight(row) < height) {
|
||||||
table.setRowHeight(row, height);
|
table.setRowHeight(row, height);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user