Factored out TableCell setEnable() code

This commit is contained in:
Cristian Maglie 2015-12-28 13:24:03 +01:00
parent c1387ed316
commit 015f658d1e
6 changed files with 16 additions and 16 deletions

View File

@ -239,5 +239,9 @@ public class ContributedLibraryTableCell {
return description; return description;
} }
public void setButtonsVisible(boolean enabled) {
installButton.setEnabled(enabled);
buttonsPanel.setVisible(enabled);
inactiveButtonsPanel.setVisible(!enabled);
}
} }

View File

@ -141,9 +141,7 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
@Override @Override
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
editorCell.installButton.setEnabled(enabled); editorCell.setButtonsVisible(enabled);
editorCell.buttonsPanel.setVisible(enabled);
editorCell.inactiveButtonsPanel.setVisible(!enabled);
} }
public void setStatus(String status) { public void setStatus(String status) {

View File

@ -44,10 +44,7 @@ public class ContributedLibraryTableCellRenderer implements TableCellRenderer {
int column) { int column) {
ContributedLibraryTableCell cell = new ContributedLibraryTableCell(); ContributedLibraryTableCell cell = new ContributedLibraryTableCell();
cell.installButton.setEnabled(false); cell.setButtonsVisible(false);
cell.buttonsPanel.setVisible(false);
cell.inactiveButtonsPanel.setVisible(true);
cell.update(table, value, isSelected, row, false); cell.update(table, value, isSelected, row, false);
if (row % 2 == 0) { if (row % 2 == 0) {

View File

@ -278,4 +278,11 @@ public class ContributedPlatformTableCell {
return description; return description;
} }
public void setButtonsVisible(boolean enabled) {
installButton.setEnabled(enabled);
removeButton.setEnabled(enabled);
buttonsPanel.setVisible(enabled);
inactiveButtonsPanel.setVisible(!enabled);
}
} }

View File

@ -138,10 +138,7 @@ public class ContributedPlatformTableCellEditor extends InstallerTableCell {
@Override @Override
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
editorCell.installButton.setEnabled(enabled); editorCell.setButtonsVisible(enabled);
editorCell.removeButton.setEnabled(enabled);
editorCell.buttonsPanel.setVisible(enabled);
editorCell.inactiveButtonsPanel.setVisible(!enabled);
} }
public void setStatus(String status) { public void setStatus(String status) {

View File

@ -43,10 +43,7 @@ public class ContributedPlatformTableCellRenderer implements TableCellRenderer {
boolean hasFocus, int row, boolean hasFocus, int row,
int column) { int column) {
ContributedPlatformTableCell cell = new ContributedPlatformTableCell(); ContributedPlatformTableCell cell = new ContributedPlatformTableCell();
cell.installButton.setEnabled(false); cell.setButtonsVisible(false);
cell.removeButton.setEnabled(false);
cell.buttonsPanel.setVisible(false);
cell.inactiveButtonsPanel.setVisible(true);
cell.update(table, value, isSelected, row, false); cell.update(table, value, isSelected, row, false);
if (row % 2 == 0) { if (row % 2 == 0) {