//order.setHeaderValue("#");
//order.setCellRenderer(new OrderTableCellRenderer());
//table_columns.add(order);
TableColumnExt file_name = new TableColumnExt();
file_name.setIdentifier(UIConstants.DOWNLOAD_LIST_FILE_NAME_COLUMN_ID);
file_name.setModelIndex(DownloadTableModel.FILE_NAME);
file_name.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_FILE_NAME_COLUMN_ID));
file_name.setHeaderValue("File name");
file_name.setCellRenderer(new FileNameTableCellRenderer());
file_name.setComparator(new GeneralComparator("getSharingName"));
table_columns.add(file_name);
TableColumnExt file_size = new TableColumnExt();
file_size.setIdentifier(UIConstants.DOWNLOAD_LIST_SIZE_COLUMN_ID);
file_size.setModelIndex(DownloadTableModel.FILE_SIZE);
file_size.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_SIZE_COLUMN_ID));
file_size.setHeaderValue("Size");
file_size.setCellRenderer(new FileSizeTableCellRenderer());
file_size.setComparator(new GeneralComparator("getFileSize"));
table_columns.add(file_size);
TableColumnExt transferred = new TableColumnExt();
transferred.setIdentifier(UIConstants.DOWNLOAD_LIST_TRANSFERRED_COLUMN_ID);
transferred.setModelIndex(DownloadTableModel.TRANSFERRED);
transferred.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_TRANSFERRED_COLUMN_ID));
transferred.setHeaderValue("Transferred");
transferred.setCellRenderer(new TransferredTableCellRenderer());
transferred.setComparator(new GeneralComparator("getTransferredBytes"));
table_columns.add(transferred);
TableColumnExt download_speed = new TableColumnExt();
download_speed.setIdentifier(UIConstants.DOWNLOAD_LIST_DOWNLOAD_SPEED_COLUMN_ID);
download_speed.setModelIndex(DownloadTableModel.DOWNLOAD_SPEED);
download_speed.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_DOWNLOAD_SPEED_COLUMN_ID));
download_speed.setHeaderValue("Down speed");
download_speed.setCellRenderer(new DownloadSpeedTableCellRenderer());
download_speed.setComparator(new GeneralComparator("getSpeed"));
table_columns.add(download_speed);
TableColumnExt upload_speed = new TableColumnExt();
upload_speed.setIdentifier(UIConstants.DOWNLOAD_LIST_UPLOAD_SPEED_COLUMN_ID);
upload_speed.setModelIndex(DownloadTableModel.UPLOAD_SPEED);
upload_speed.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_UPLOAD_SPEED_COLUMN_ID));
upload_speed.setHeaderValue("Up speed");
upload_speed.setCellRenderer(new UploadSpeedTableCellRenderer());
upload_speed.setComparator(new Comparator() {
public int compare(Object o1, Object o2) {
Float u_speed1 = null;
Float u_speed2 = null;
try {
DownloadSession d_session1 = (DownloadSession)o1;
DownloadSession d_session2 = (DownloadSession)o2;
UploadSession u_session1 = null;
UploadSession u_session2 = null;
if(_upload_manager.hasUpload(d_session1.getFileHash()))
u_session1 = _upload_manager.getUpload(d_session1.getFileHash());
if(_upload_manager.hasUpload(d_session2.getFileHash()))
u_session2 = _upload_manager.getUpload(d_session2.getFileHash());
u_speed1 = new Float((u_session1!=null)?u_session1.getSpeed():0.0f);
u_speed2 = new Float((u_session2!=null)?u_session2.getSpeed():0.0f);
}catch(Throwable cause) {
cause.printStackTrace();
}
return Misc.compareAllObjects(u_speed1, u_speed2, "floatValue", true);
}
});
table_columns.add(upload_speed);
TableColumnExt pieces = new TableColumnExt();
pieces.setIdentifier(UIConstants.DOWNLOAD_LIST_PROGRESS_COLUMN_ID);
pieces.setModelIndex(DownloadTableModel.PIECES);
pieces.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_PROGRESS_COLUMN_ID));
pieces.setHeaderValue("Pieces");
pieces.setCellRenderer(new PiecesTableCellRenderer());
pieces.setComparator(new GeneralComparator("getPercentCompleted"));
table_columns.add(pieces);
TableColumnExt done = new TableColumnExt();
done.setIdentifier(UIConstants.DOWNLOAD_LIST_COMPLETED_COLUMN_ID);
done.setModelIndex(DownloadTableModel.DONE);
done.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_COMPLETED_COLUMN_ID));
done.setHeaderValue("Done");
done.setCellRenderer(new DoneTableCellRenderer());
done.setComparator(new GeneralComparator("getPercentCompleted"));
table_columns.add(done);
TableColumnExt progress_bar = new TableColumnExt();
progress_bar.setIdentifier(UIConstants.DOWNLOAD_LIST_PROGRESS_BAR_COLUMN_ID);
progress_bar.setModelIndex(DownloadTableModel.PROGRESS_BAR);
progress_bar.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_PROGRESS_BAR_COLUMN_ID));
progress_bar.setHeaderValue("Progress");
progress_bar.setCellRenderer(new ProgressBarTableCellRenderer());
progress_bar.setComparator(new GeneralComparator("getPercentCompleted"));
table_columns.add(progress_bar);
TableColumnExt complete_sources = new TableColumnExt();
complete_sources.setIdentifier(UIConstants.DOWNLOAD_LIST_COMPLETE_SOURCES_COLUMN_ID);
complete_sources.setModelIndex(DownloadTableModel.COMPLETE_SOURCES);
complete_sources.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_COMPLETE_SOURCES_COLUMN_ID));
complete_sources.setVisible(true);
complete_sources.setHeaderValue("Complete sources");
complete_sources.setCellRenderer(new CompletedSourcesTableCellRenderer());
complete_sources.setComparator(new GeneralComparator("getCompletedSources"));
table_columns.add(complete_sources);
TableColumnExt partial_sources = new TableColumnExt();
partial_sources.setIdentifier(UIConstants.DOWNLOAD_LIST_PARTIAL_SOURCES_COLUMN_ID);
partial_sources.setModelIndex(DownloadTableModel.PARTIAL_SOURCES);
partial_sources.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_PARTIAL_SOURCES_COLUMN_ID));
partial_sources.setVisible(true);
partial_sources.setHeaderValue("Partial sources");
partial_sources.setCellRenderer(new PartialSourcesTableCellRenderer());
partial_sources.setComparator(new GeneralComparator("getPartialSources"));
table_columns.add(partial_sources);
TableColumnExt eta = new TableColumnExt();
eta.setIdentifier(UIConstants.DOWNLOAD_LIST_REMAINING_COLUMN_ID);
eta.setModelIndex(DownloadTableModel.ETA);
eta.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_REMAINING_COLUMN_ID));
eta.setHeaderValue("ETA");
eta.setCellRenderer(new ETATableCellRenderer());
eta.setComparator(new GeneralComparator("getETA"));
table_columns.add(eta);
TableColumnExt status = new TableColumnExt();
status.setIdentifier(UIConstants.DOWNLOAD_LIST_STATUS_COLUMN_ID);
status.setModelIndex(DownloadTableModel.STATUS);
status.setVisible(_pref.isColumnVisible(UIConstants.DOWNLOAD_LIST_STATUS_COLUMN_ID));
status.setHeaderValue("Status");
status.setCellRenderer(new StatusTableCellRenderer());
status.setComparator(new GeneralComparator("getStatus"));
table_columns.add(status);
super.buildColumns(new DownloadTableModel());