use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class ColumnCS_Discarded method refresh.
@Override
public void refresh(TableCell cell) {
ClientStatsDataSource ds = (ClientStatsDataSource) cell.getDataSource();
if (ds == null) {
return;
}
long val = ds.bytesDiscarded;
TableColumn column = cell.getTableColumn();
if (column != null) {
String network = column.getUserDataString("network");
if (network != null) {
Map<String, Object> map = ds.perNetworkStats.get(network);
if (map != null) {
val = MapUtils.getMapLong(map, "bytesDiscarded", 0);
} else {
val = 0;
}
}
}
if (cell.setSortValue(val) || !cell.isValid()) {
cell.setText(DisplayFormatters.formatByteCountToKiBEtc(val));
}
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method initColumns.
private void initColumns(Core core) {
synchronized (SBC_SearchResultsView.class) {
if (columnsAdded) {
return;
}
columnsAdded = true;
}
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultType.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultType(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultName.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultName(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultActions.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultActions(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultSize.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultSize(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultSeedsPeers.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultSeedsPeers(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultRatings.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultRatings(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultAge.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultAge(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultRank.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultRank(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultCategory.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultCategory(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchResultSite.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchResultSite(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultHash.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultHash(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultExisting.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultExisting(column);
}
});
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class TableRowPainted method swt_paintCell.
private boolean swt_paintCell(GC gc, Rectangle cellBounds, TableCellSWTBase cell, Color shadowColor) {
// Only called from swt_PaintGC, so we can assume GC, cell are valid
if (cellBounds == null) {
return false;
}
boolean gcChanged = false;
try {
gc.setTextAntialias(SWT.DEFAULT);
TableViewSWT<?> view = (TableViewSWT<?>) getView();
TableColumnCore column = (TableColumnCore) cell.getTableColumn();
view.invokePaintListeners(gc, this, column, cellBounds);
int fontStyle = getFontStyle();
Font oldFont = null;
if (fontStyle == SWT.BOLD) {
oldFont = gc.getFont();
gc.setFont(FontUtils.getAnyFontBold(gc));
gcChanged = true;
} else if (fontStyle == SWT.ITALIC) {
oldFont = gc.getFont();
gc.setFont(FontUtils.getAnyFontItalic(gc));
gcChanged = true;
}
if (!cell.isUpToDate()) {
// System.out.println("R " + rowIndex + ":" + iColumnNo);
cell.refresh(true, true);
// return;
}
String text = cell.getText();
Color fg = cell.getForegroundSWT();
if (fg != null) {
gcChanged = true;
if (isSelected()) {
shadowColor = fg;
} else {
gc.setForeground(fg);
}
}
Color bg = cell.getBackgroundSWT();
if (bg != null) {
gcChanged = true;
gc.setBackground(bg);
}
// }
if (cell.needsPainting()) {
Image graphicSWT = cell.getGraphicSWT();
if (graphicSWT != null && !graphicSWT.isDisposed()) {
Rectangle imageBounds = graphicSWT.getBounds();
Rectangle graphicBounds = new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height);
if (cell.getFillCell()) {
if (!graphicBounds.isEmpty()) {
gc.setAdvanced(true);
// System.out.println(imageBounds + ";" + graphicBounds);
gc.drawImage(graphicSWT, 0, 0, imageBounds.width, imageBounds.height, graphicBounds.x, graphicBounds.y, graphicBounds.width, graphicBounds.height);
}
} else {
if (imageBounds.width < graphicBounds.width) {
int alignment = column.getAlignment();
if ((alignment & TableColumn.ALIGN_CENTER) > 0) {
graphicBounds.x += (graphicBounds.width - imageBounds.width) / 2;
} else if ((alignment & TableColumn.ALIGN_TRAIL) > 0) {
graphicBounds.x = (graphicBounds.x + graphicBounds.width) - imageBounds.width;
}
}
if (imageBounds.height < graphicBounds.height) {
graphicBounds.y += (graphicBounds.height - imageBounds.height) / 2;
}
gc.drawImage(graphicSWT, graphicBounds.x, graphicBounds.y);
}
}
cell.doPaint(gc);
gcChanged = true;
}
if (text.length() > 0) {
int ofsx = 0;
Image image = cell.getIcon();
Rectangle imageBounds = null;
if (image != null && !image.isDisposed()) {
imageBounds = image.getBounds();
int ofs = imageBounds.width;
ofsx += ofs;
cellBounds.x += ofs;
cellBounds.width -= ofs;
}
// System.out.println("PS " + getIndex() + ";" + cellBounds + ";" + cell.getText());
int style = TableColumnSWTUtils.convertColumnAlignmentToSWT(column.getAlignment());
if (cellBounds.height > 20) {
style |= SWT.WRAP;
}
int textOpacity = cell.getTextAlpha();
// textOpacity = 130;
if (textOpacity < 255) {
// gc.setTextAntialias(SWT.ON);
gc.setAlpha(textOpacity);
gcChanged = true;
} else if (textOpacity > 255) {
boolean is_italic = (gc.getFont().getFontData()[0].getStyle() & SWT.ITALIC) != 0;
if (is_italic) {
gc.setFont(FontUtils.getAnyFontBoldItalic(gc));
} else {
gc.setFont(FontUtils.getAnyFontBold(gc));
}
// gc.setTextAntialias(SWT.ON);
// gc.setAlpha(textOpacity & 255);
gcChanged = true;
}
// put some padding on text
ofsx += 6;
cellBounds.x += 3;
cellBounds.width -= 6;
cellBounds.y += 2;
cellBounds.height -= 4;
if (!cellBounds.isEmpty()) {
GCStringPrinter sp = new GCStringPrinter(gc, text, cellBounds, true, cellBounds.height > 20, style);
boolean fit;
if (shadowColor != null) {
Color oldFG = gc.getForeground();
gc.setForeground(shadowColor);
cellBounds.x += 1;
cellBounds.y += 1;
int alpha = gc.getAlpha();
gc.setAlpha(0x40);
sp.printString(gc, cellBounds, style);
gc.setAlpha(alpha);
gc.setForeground(oldFG);
cellBounds.x -= 1;
cellBounds.y -= 1;
fit = sp.printString2(gc, cellBounds, style);
} else {
fit = sp.printString();
}
if (fit) {
cell.setDefaultToolTip(null);
} else {
cell.setDefaultToolTip(text);
}
Point psize = sp.getCalculatedPreferredSize();
psize.x += ofsx;
TableColumn tableColumn = cell.getTableColumn();
if (tableColumn != null && tableColumn.getPreferredWidth() < psize.x) {
tableColumn.setPreferredWidth(psize.x);
}
if (imageBounds != null) {
int drawToY = cellBounds.y + (cellBounds.height / 2) - (imageBounds.height / 2);
boolean hack_adv = Constants.isWindows8OrHigher && gc.getAdvanced();
if (hack_adv) {
// problem with icon transparency on win8
gc.setAdvanced(false);
}
if ((style & SWT.RIGHT) != 0) {
Point size = sp.getCalculatedSize();
size.x += ofsx;
int drawToX = cellBounds.x + cellBounds.width - size.x;
gc.drawImage(image, drawToX, drawToY);
} else {
if (imageBounds.height > cellBounds.height) {
float pct = cellBounds.height / (float) imageBounds.height;
gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, cellBounds.x - imageBounds.width - 3, cellBounds.y, (int) (imageBounds.width * pct), (int) (imageBounds.height * pct));
} else {
gc.drawImage(image, cellBounds.x - imageBounds.width - 3, drawToY);
}
}
if (hack_adv) {
gc.setAdvanced(true);
}
}
} else {
cell.setDefaultToolTip(null);
}
}
cell.clearVisuallyChangedSinceRefresh();
if (oldFont != null) {
gc.setFont(oldFont);
}
} catch (Exception e) {
Debug.out(cell.getTableID() + ":" + cell.getTableColumn().getName(), e);
}
return gcChanged;
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class TableViewPainted method setupHeaderArea.
private void setupHeaderArea(final Canvas cHeaderArea) {
cHeaderArea.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paintHeader(e);
}
});
Listener l = new Listener() {
boolean mouseDown = false;
TableColumnCore columnSizing;
int columnSizingStart = 0;
@Override
public void handleEvent(Event e) {
switch(e.type) {
case SWT.MouseDown:
{
if (e.button != 1) {
return;
}
mouseDown = true;
columnSizing = null;
int x = -clientArea.x;
TableColumnCore[] visibleColumns = getVisibleColumns();
for (TableColumnCore column : visibleColumns) {
int w = column.getWidth();
x += w;
if (e.x >= x - 3 && e.x <= x + 3) {
columnSizing = column;
columnSizingStart = e.x;
break;
}
}
break;
}
case SWT.MouseUp:
{
if (e.button != 1) {
return;
}
if (mouseDown && columnSizing == null) {
TableColumnCore column = getTableColumnByOffset(e.x);
if (column != null) {
setSortColumn(column, true);
}
}
columnSizing = null;
mouseDown = false;
break;
}
case SWT.MouseMove:
{
if (columnSizing != null) {
int diff = (e.x - columnSizingStart);
columnSizing.setWidthPX(columnSizing.getWidth() + diff);
columnSizingStart = e.x;
} else {
int cursorID = SWT.CURSOR_HAND;
int x = -clientArea.x;
TableColumnCore[] visibleColumns = getVisibleColumns();
for (TableColumnCore column : visibleColumns) {
int w = column.getWidth();
x += w;
if (e.x >= x - 3 && e.x <= x + 3) {
cursorID = SWT.CURSOR_SIZEWE;
break;
}
}
cHeaderArea.setCursor(e.display.getSystemCursor(cursorID));
TableColumnCore column = getTableColumnByOffset(e.x);
if (column == null || TableTooltips.tooltips_disabled) {
cHeaderArea.setToolTipText(null);
} else {
String info = MessageText.getString(column.getTitleLanguageKey() + ".info", (String) null);
if (column.showOnlyImage()) {
String tt = MessageText.getString(column.getTitleLanguageKey());
if (info != null) {
tt += "\n" + info;
}
cHeaderArea.setToolTipText(tt);
} else {
cHeaderArea.setToolTipText(info);
}
}
}
}
}
}
};
cHeaderArea.addListener(SWT.MouseDown, l);
cHeaderArea.addListener(SWT.MouseUp, l);
cHeaderArea.addListener(SWT.MouseMove, l);
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
final DragSource ds = new DragSource(cHeaderArea, DND.DROP_MOVE);
ds.setTransfer(types);
ds.addDragListener(new DragSourceListener() {
private String eventData;
@Override
public void dragStart(DragSourceEvent event) {
Cursor cursor = cHeaderArea.getCursor();
if (cursor != null && cursor.equals(event.display.getSystemCursor(SWT.CURSOR_SIZEWE))) {
event.doit = false;
return;
}
cHeaderArea.setCursor(null);
TableColumnCore tc = getTableColumnByOffset(event.x);
isHeaderDragging = tc != null;
if (isHeaderDragging) {
eventData = tc.getName();
}
// System.out.println("drag " + eventData);
}
@Override
public void dragSetData(DragSourceEvent event) {
event.data = eventData;
}
@Override
public void dragFinished(DragSourceEvent event) {
isHeaderDragging = false;
eventData = null;
}
});
final DropTarget dt = new DropTarget(cHeaderArea, DND.DROP_MOVE);
dt.setTransfer(types);
dt.addDropListener(new DropTargetListener() {
@Override
public void dropAccept(DropTargetEvent event) {
}
@Override
public void drop(final DropTargetEvent event) {
if (event.data instanceof String) {
TableColumn tcOrig = getTableColumn((String) event.data);
Point pt = cTable.toControl(event.x, event.y);
TableColumn tcDest = getTableColumnByOffset(pt.x);
if (tcDest == null) {
TableColumnCore[] visibleColumns = getVisibleColumns();
if (visibleColumns != null && visibleColumns.length > 0) {
tcDest = visibleColumns[visibleColumns.length - 1];
}
}
if (tcOrig != null && tcDest != null) {
int destPos = tcDest.getPosition();
int origPos = tcOrig.getPosition();
final boolean moveRight = destPos > origPos;
TableColumnCore[] visibleColumns = getVisibleColumns();
((TableColumnCore) tcOrig).setPositionNoShift(destPos);
// System.out.println("Move " + origPos + " Right? " + moveRight + " of " + destPos);
Arrays.sort(visibleColumns, new Comparator<TableColumnCore>() {
@Override
public int compare(TableColumnCore o1, TableColumnCore o2) {
if (o1 == o2) {
return 0;
}
int diff = o1.getPosition() - o2.getPosition();
if (diff == 0) {
int i = o1.getName().equals(event.data) ? -1 : 1;
if (moveRight) {
i *= -1;
}
return i;
}
return diff;
}
});
for (int i = 0; i < visibleColumns.length; i++) {
TableColumnCore tc = visibleColumns[i];
tc.setPositionNoShift(i);
}
setColumnsOrdered(visibleColumns);
TableStructureEventDispatcher.getInstance(tableID).tableStructureChanged(false, getDataSourceType());
}
}
}
@Override
public void dragOver(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void dragEnter(DropTargetEvent event) {
}
});
cHeaderArea.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
Utils.disposeSWTObjects(new Object[] { ds, dt, fontHeader, fontHeaderSmall });
}
});
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class TableColumnCreator method initCoreColumns.
/**
* @since 3.1.1.1
*/
public static void initCoreColumns() {
// short variable names to reduce wrapping
final Map<String, cInfo> c = new LightHashMap(50);
final Class tc = TableColumn.class;
c.put(RankItem.COLUMN_ID, new cInfo(RankItem.class, RankItem.DATASOURCE_TYPE));
c.put(NameItem.COLUMN_ID, new cInfo(NameItem.class, NameItem.DATASOURCE_TYPE));
c.put(SizeItem.COLUMN_ID, new cInfo(SizeItem.class, SizeItem.DATASOURCE_TYPE));
c.put(ColumnSizeWithDND.COLUMN_ID, new cInfo(ColumnSizeWithDND.class, ColumnSizeWithDND.DATASOURCE_TYPE));
c.put(DoneItem.COLUMN_ID, new cInfo(DoneItem.class, DoneItem.DATASOURCE_TYPE));
c.put(ColumnDoneWithDND.COLUMN_ID, new cInfo(ColumnDoneWithDND.class, ColumnDoneWithDND.DATASOURCE_TYPE));
c.put(StatusItem.COLUMN_ID, new cInfo(StatusItem.class, StatusItem.DATASOURCE_TYPE));
c.put(ETAItem.COLUMN_ID, new cInfo(ETAItem.class, ETAItem.DATASOURCE_TYPE));
c.put(HealthItem.COLUMN_ID, new cInfo(HealthItem.class, HealthItem.DATASOURCE_TYPE));
c.put(CommentIconItem.COLUMN_ID, new cInfo(CommentIconItem.class, CommentIconItem.DATASOURCE_TYPE));
c.put(DownItem.COLUMN_ID, new cInfo(DownItem.class, DownItem.DATASOURCE_TYPE));
c.put(SeedsItem.COLUMN_ID, new cInfo(SeedsItem.class, SeedsItem.DATASOURCE_TYPE));
c.put(PeersItem.COLUMN_ID, new cInfo(PeersItem.class, PeersItem.DATASOURCE_TYPE));
c.put(DownSpeedItem.COLUMN_ID, new cInfo(DownSpeedItem.class, DownSpeedItem.DATASOURCE_TYPE));
c.put(UpSpeedItem.COLUMN_ID, new cInfo(UpSpeedItem.class, UpSpeedItem.DATASOURCE_TYPE));
c.put(UpSpeedLimitItem.COLUMN_ID, new cInfo(UpSpeedLimitItem.class, UpSpeedLimitItem.DATASOURCE_TYPE));
c.put(TrackerStatusItem.COLUMN_ID, new cInfo(TrackerStatusItem.class, TrackerStatusItem.DATASOURCE_TYPE));
c.put(CompletedItem.COLUMN_ID, new cInfo(CompletedItem.class, CompletedItem.DATASOURCE_TYPE));
c.put(ShareRatioItem.COLUMN_ID, new cInfo(ShareRatioItem.class, ShareRatioItem.DATASOURCE_TYPE));
c.put(ShareRatioProgressItem.COLUMN_ID, new cInfo(ShareRatioProgressItem.class, ShareRatioProgressItem.DATASOURCE_TYPE));
c.put(UpItem.COLUMN_ID, new cInfo(UpItem.class, UpItem.DATASOURCE_TYPE));
c.put(RemainingItem.COLUMN_ID, new cInfo(RemainingItem.class, RemainingItem.DATASOURCE_TYPE));
c.put(PiecesItem.COLUMN_ID, new cInfo(PiecesItem.class, PiecesItem.DATASOURCE_TYPE));
c.put(CompletionItem.COLUMN_ID, new cInfo(CompletionItem.class, CompletionItem.DATASOURCE_TYPE));
c.put(CommentItem.COLUMN_ID, new cInfo(CommentItem.class, CommentItem.DATASOURCE_TYPE));
c.put(MaxUploadsItem.COLUMN_ID, new cInfo(MaxUploadsItem.class, MaxUploadsItem.DATASOURCE_TYPE));
c.put(TotalSpeedItem.COLUMN_ID, new cInfo(TotalSpeedItem.class, TotalSpeedItem.DATASOURCE_TYPE));
c.put(FilesDoneItem.COLUMN_ID, new cInfo(FilesDoneItem.class, FilesDoneItem.DATASOURCE_TYPE));
c.put(FilesLinkedItem.COLUMN_ID, new cInfo(FilesLinkedItem.class, FilesLinkedItem.DATASOURCE_TYPE));
c.put(FileExtensionItem.COLUMN_ID, new cInfo(FileExtensionItem.class, FileExtensionItem.DATASOURCE_TYPE));
c.put(SavePathItem.COLUMN_ID, new cInfo(SavePathItem.class, SavePathItem.DATASOURCE_TYPE));
c.put(TorrentPathItem.COLUMN_ID, new cInfo(TorrentPathItem.class, TorrentPathItem.DATASOURCE_TYPE));
c.put(CategoryItem.COLUMN_ID, new cInfo(CategoryItem.class, CategoryItem.DATASOURCE_TYPE));
c.put(TagsItem.COLUMN_ID, new cInfo(TagsItem.class, TagsItem.DATASOURCE_TYPE));
c.put(TagColorsItem.COLUMN_ID, new cInfo(TagColorsItem.class, TagColorsItem.DATASOURCE_TYPE));
c.put(TagAddedToDateItem.COLUMN_ID, new cInfo(TagAddedToDateItem.class, TagAddedToDateItem.DATASOURCE_TYPE));
c.put(NetworksItem.COLUMN_ID, new cInfo(NetworksItem.class, NetworksItem.DATASOURCE_TYPE));
c.put(PeerSourcesItem.COLUMN_ID, new cInfo(PeerSourcesItem.class, PeerSourcesItem.DATASOURCE_TYPE));
c.put(AvailabilityItem.COLUMN_ID, new cInfo(AvailabilityItem.class, AvailabilityItem.DATASOURCE_TYPE));
c.put(AvgAvailItem.COLUMN_ID, new cInfo(AvgAvailItem.class, AvgAvailItem.DATASOURCE_TYPE));
c.put(SecondsSeedingItem.COLUMN_ID, new cInfo(SecondsSeedingItem.class, SecondsSeedingItem.DATASOURCE_TYPE));
c.put(SecondsDownloadingItem.COLUMN_ID, new cInfo(SecondsDownloadingItem.class, SecondsDownloadingItem.DATASOURCE_TYPE));
c.put(TimeSinceDownloadItem.COLUMN_ID, new cInfo(TimeSinceDownloadItem.class, TimeSinceDownloadItem.DATASOURCE_TYPE));
c.put(TimeSinceUploadItem.COLUMN_ID, new cInfo(TimeSinceUploadItem.class, TimeSinceUploadItem.DATASOURCE_TYPE));
c.put(OnlyCDing4Item.COLUMN_ID, new cInfo(OnlyCDing4Item.class, OnlyCDing4Item.DATASOURCE_TYPE));
c.put(TrackerNextAccessItem.COLUMN_ID, new cInfo(TrackerNextAccessItem.class, TrackerNextAccessItem.DATASOURCE_TYPE));
c.put(TrackerNameItem.COLUMN_ID, new cInfo(TrackerNameItem.class, TrackerNameItem.DATASOURCE_TYPE));
c.put(SeedToPeerRatioItem.COLUMN_ID, new cInfo(SeedToPeerRatioItem.class, SeedToPeerRatioItem.DATASOURCE_TYPE));
c.put(DownSpeedLimitItem.COLUMN_ID, new cInfo(DownSpeedLimitItem.class, DownSpeedLimitItem.DATASOURCE_TYPE));
c.put(SwarmAverageSpeed.COLUMN_ID, new cInfo(SwarmAverageSpeed.class, SwarmAverageSpeed.DATASOURCE_TYPE));
c.put(SwarmAverageCompletion.COLUMN_ID, new cInfo(SwarmAverageCompletion.class, SwarmAverageCompletion.DATASOURCE_TYPE));
c.put(SwarmMaxCompletion.COLUMN_ID, new cInfo(SwarmMaxCompletion.class, SwarmMaxCompletion.DATASOURCE_TYPE));
c.put(LeecherMaxCompletion.COLUMN_ID, new cInfo(LeecherMaxCompletion.class, LeecherMaxCompletion.DATASOURCE_TYPE));
c.put(BadAvailTimeItem.COLUMN_ID, new cInfo(BadAvailTimeItem.class, BadAvailTimeItem.DATASOURCE_TYPE));
c.put(ColumnFileCount.COLUMN_ID, new cInfo(ColumnFileCount.class, ColumnFileCount.DATASOURCE_TYPE));
c.put(ColumnTorrentSpeed.COLUMN_ID, new cInfo(ColumnTorrentSpeed.class, ColumnTorrentSpeed.DATASOURCE_TYPE));
c.put(MoveOnCompleteItem.COLUMN_ID, new cInfo(MoveOnCompleteItem.class, MoveOnCompleteItem.DATASOURCE_TYPE));
c.put(DateCompletedItem.COLUMN_ID, new cInfo(DateCompletedItem.class, DateCompletedItem.DATASOURCE_TYPE));
c.put(DateFileCompletedItem.COLUMN_ID, new cInfo(DateFileCompletedItem.class, DateFileCompletedItem.DATASOURCE_TYPE));
c.put(DateAddedItem.COLUMN_ID, new cInfo(DateAddedItem.class, DateAddedItem.DATASOURCE_TYPE));
c.put(DateLastActiveItem.COLUMN_ID, new cInfo(DateLastActiveItem.class, DateLastActiveItem.DATASOURCE_TYPE));
c.put(IPFilterItem.COLUMN_ID, new cInfo(IPFilterItem.class, IPFilterItem.DATASOURCE_TYPE));
c.put(AlertsItem.COLUMN_ID, new cInfo(AlertsItem.class, AlertsItem.DATASOURCE_TYPE));
c.put(TorrentCreateDateItem.COLUMN_ID, new cInfo(TorrentCreateDateItem.class, TorrentCreateDateItem.DATASOURCE_TYPE));
c.put(ColumnTC_NameInfo.COLUMN_ID, new cInfo(ColumnTC_NameInfo.class, tc));
c.put(ColumnTC_Sample.COLUMN_ID, new cInfo(ColumnTC_Sample.class, tc));
c.put(ColumnTC_ChosenColumn.COLUMN_ID, new cInfo(ColumnTC_ChosenColumn.class, tc));
c.put(PeakUpItem.COLUMN_ID, new cInfo(PeakUpItem.class, PeakUpItem.DATASOURCE_TYPE));
c.put(PeakDownItem.COLUMN_ID, new cInfo(PeakDownItem.class, PeakDownItem.DATASOURCE_TYPE));
c.put(SmoothedUpItem.COLUMN_ID, new cInfo(SmoothedUpItem.class, SmoothedUpItem.DATASOURCE_TYPE));
c.put(SmoothedDownItem.COLUMN_ID, new cInfo(SmoothedDownItem.class, SmoothedDownItem.DATASOURCE_TYPE));
c.put(SmoothedETAItem.COLUMN_ID, new cInfo(SmoothedETAItem.class, SmoothedETAItem.DATASOURCE_TYPE));
c.put(MinSRItem.COLUMN_ID, new cInfo(MinSRItem.class, MinSRItem.DATASOURCE_TYPE));
c.put(MaxSRItem.COLUMN_ID, new cInfo(MaxSRItem.class, MaxSRItem.DATASOURCE_TYPE));
c.put(SessionUpItem.COLUMN_ID, new cInfo(SessionUpItem.class, SessionUpItem.DATASOURCE_TYPE));
c.put(SessionDownItem.COLUMN_ID, new cInfo(SessionDownItem.class, SessionDownItem.DATASOURCE_TYPE));
c.put(MergedDataItem.COLUMN_ID, new cInfo(MergedDataItem.class, MergedDataItem.DATASOURCE_TYPE));
c.put(DescriptionItem.COLUMN_ID, new cInfo(DescriptionItem.class, DescriptionItem.DATASOURCE_TYPE));
// Core columns are implementors of TableColumn to save one class creation
// Otherwise, we'd have to create a generic TableColumnImpl class, pass it
// to another class so that it could manipulate it and act upon changes.
TableColumnManager tcManager = TableColumnManager.getInstance();
TableColumnCoreCreationListener tcCreator = new TableColumnCoreCreationListener() {
// @see com.biglybt.ui.swt.views.table.TableColumnCoreCreationListener#createTableColumnCore(java.lang.Class, java.lang.String, java.lang.String)
@Override
public TableColumnCore createTableColumnCore(Class forDataSourceType, String tableID, String columnID) {
cInfo info = (cInfo) c.get(columnID);
try {
Constructor constructor = info.cla.getDeclaredConstructor(new Class[] { String.class });
TableColumnCore column = (TableColumnCore) constructor.newInstance(new Object[] { tableID });
return column;
} catch (Exception e) {
Debug.out(e);
}
return null;
}
@Override
public void tableColumnCreated(TableColumn column) {
}
};
for (Iterator<String> iter = c.keySet().iterator(); iter.hasNext(); ) {
String id = iter.next();
cInfo info = c.get(id);
tcManager.registerColumn(info.forDataSourceType, id, tcCreator);
}
}
Aggregations