Skip to content

Commit 015f658

Browse files
committed
Factored out TableCell setEnable() code
1 parent c1387ed commit 015f658

6 files changed

+16
-16
lines changed

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,9 @@ private static JTextPane makeNewDescription(JPanel panel) {
239239
return description;
240240
}
241241

242-
242+
public void setButtonsVisible(boolean enabled) {
243+
installButton.setEnabled(enabled);
244+
buttonsPanel.setVisible(enabled);
245+
inactiveButtonsPanel.setVisible(!enabled);
246+
}
243247
}

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,
141141

142142
@Override
143143
public void setEnabled(boolean enabled) {
144-
editorCell.installButton.setEnabled(enabled);
145-
editorCell.buttonsPanel.setVisible(enabled);
146-
editorCell.inactiveButtonsPanel.setVisible(!enabled);
144+
editorCell.setButtonsVisible(enabled);
147145
}
148146

149147
public void setStatus(String status) {

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
4444
int column) {
4545

4646
ContributedLibraryTableCell cell = new ContributedLibraryTableCell();
47-
cell.installButton.setEnabled(false);
48-
cell.buttonsPanel.setVisible(false);
49-
cell.inactiveButtonsPanel.setVisible(true);
50-
47+
cell.setButtonsVisible(false);
5148
cell.update(table, value, isSelected, row, false);
5249

5350
if (row % 2 == 0) {

app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,11 @@ private static JTextPane makeNewDescription(JPanel panel) {
278278
return description;
279279
}
280280

281+
public void setButtonsVisible(boolean enabled) {
282+
installButton.setEnabled(enabled);
283+
removeButton.setEnabled(enabled);
284+
buttonsPanel.setVisible(enabled);
285+
inactiveButtonsPanel.setVisible(!enabled);
286+
}
287+
281288
}

app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,
138138

139139
@Override
140140
public void setEnabled(boolean enabled) {
141-
editorCell.installButton.setEnabled(enabled);
142-
editorCell.removeButton.setEnabled(enabled);
143-
editorCell.buttonsPanel.setVisible(enabled);
144-
editorCell.inactiveButtonsPanel.setVisible(!enabled);
141+
editorCell.setButtonsVisible(enabled);
145142
}
146143

147144
public void setStatus(String status) {

app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
4343
boolean hasFocus, int row,
4444
int column) {
4545
ContributedPlatformTableCell cell = new ContributedPlatformTableCell();
46-
cell.installButton.setEnabled(false);
47-
cell.removeButton.setEnabled(false);
48-
cell.buttonsPanel.setVisible(false);
49-
cell.inactiveButtonsPanel.setVisible(true);
46+
cell.setButtonsVisible(false);
5047

5148
cell.update(table, value, isSelected, row, false);
5249
if (row % 2 == 0) {

0 commit comments

Comments
 (0)