private DCTable getDatabaseDriverTable() {
final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog.getDatabaseDrivers();
final TableModel tableModel = new DefaultTableModel(new String[] { "", "Database", "Driver class", "Installed?",
"Used?" }, databaseDrivers.size());
final DCTable table = new DCTable(tableModel);
final Icon validIcon = imageManager.getImageIcon("images/status/valid.png", IconUtils.ICON_SIZE_SMALL);
final Icon invalidIcon = imageManager.getImageIcon("images/status/error.png", IconUtils.ICON_SIZE_SMALL);
final int installedCol = 3;
final int usedCol = 4;
int row = 0;
for (final DatabaseDriverDescriptor dd : databaseDrivers) {
final String driverClassName = dd.getDriverClassName();
final String displayName = dd.getDisplayName();
final Icon driverIcon = imageManager.getImageIcon(DatabaseDriverCatalog.getIconImagePath(dd),
IconUtils.ICON_SIZE_SMALL);
tableModel.setValueAt(driverIcon, row, 0);
tableModel.setValueAt(displayName, row, 1);
tableModel.setValueAt(driverClassName, row, 2);
tableModel.setValueAt("", row, 3);
tableModel.setValueAt("", row, 4);
final DatabaseDriverState state = _databaseDriverCatalog.getState(dd);
if (state == DatabaseDriverState.INSTALLED_WORKING) {
tableModel.setValueAt(validIcon, row, installedCol);
} else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
tableModel.setValueAt(invalidIcon, row, installedCol);
} else if (state == DatabaseDriverState.NOT_INSTALLED) {
final String[] downloadUrls = dd.getDownloadUrls();
if (downloadUrls != null) {
final DCPanel buttonPanel = new DCPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));
final JButton downloadButton = WidgetFactory.createSmallButton("images/actions/download.png");
downloadButton.setToolTipText("Download and install the driver for " + dd.getDisplayName());
downloadButton.addActionListener(createDownloadActionListener(dd));
buttonPanel.add(downloadButton);
tableModel.setValueAt(buttonPanel, row, installedCol);
}
}
if (isUsed(driverClassName)) {
tableModel.setValueAt(validIcon, row, usedCol);
}
row++;
}
table.setAlignment(installedCol, Alignment.CENTER);
table.setAlignment(usedCol, Alignment.CENTER);
table.setRowHeight(IconUtils.ICON_SIZE_SMALL + 4);
table.getColumn(0).setMaxWidth(IconUtils.ICON_SIZE_SMALL + 4);
table.getColumn(installedCol).setMaxWidth(84);
table.getColumn(usedCol).setMaxWidth(70);
table.setColumnControlVisible(false);
return table;
}