use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class SBC_TagDiscovery method initColumns.
protected void initColumns() {
synchronized (SBC_TagDiscovery.class) {
if (columnsAdded) {
return;
}
columnsAdded = true;
}
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.registerColumn(TagDiscovery.class, ColumnTagDiscoveryName.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnTagDiscoveryName(column);
}
});
tableManager.registerColumn(TagDiscovery.class, ColumnTagDiscoveryTorrent.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnTagDiscoveryTorrent(column);
}
});
tableManager.registerColumn(TagDiscovery.class, ColumnTagDiscoveryAddedOn.COLUMN_ID, new TableColumnCoreCreationListener() {
@Override
public TableColumnCore createTableColumnCore(Class<?> forDataSourceType, String tableID, String columnID) {
return new ColumnDateSizer(TagDiscovery.class, columnID, TableColumnCreator.DATE_COLUMN_WIDTH, tableID) {
};
}
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnTagDiscoveryAddedOn(column);
}
});
tableManager.registerColumn(TagDiscovery.class, ColumnTagDiscoveryNetwork.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnTagDiscoveryNetwork(column);
}
});
tableManager.setDefaultColumnNames(TABLE_TAGDISCOVERY, new String[] { ColumnTagDiscoveryName.COLUMN_ID, ColumnTagDiscoveryTorrent.COLUMN_ID, ColumnTagDiscoveryAddedOn.COLUMN_ID });
tableManager.setDefaultSortColumnName(TABLE_TAGDISCOVERY, ColumnTagDiscoveryAddedOn.COLUMN_ID);
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class ColumnCS_Received method refresh.
@Override
public void refresh(TableCell cell) {
ClientStatsDataSource ds = (ClientStatsDataSource) cell.getDataSource();
if (ds == null) {
return;
}
long val = ds.bytesReceived;
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, "bytesReceived", 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 TableRowPainted method buildCells.
private void buildCells() {
// debug("buildCells " + Debug.getCompressedStackTrace());
TableColumnCore[] visibleColumns = getView().getVisibleColumns();
if (visibleColumns == null) {
return;
}
synchronized (lock) {
mTableCells = new LinkedHashMap<>(visibleColumns.length, 1);
TableColumn currentSortColumn = null;
if (cellSort != null) {
currentSortColumn = cellSort.getTableColumn();
}
TableRowCore parentRow = getParentRowCore();
// create all the cells for the column
for (int i = 0; i < visibleColumns.length; i++) {
if (visibleColumns[i] == null) {
continue;
}
if (parentRow != null && !visibleColumns[i].handlesDataSourceType(getDataSource(false).getClass())) {
mTableCells.put(visibleColumns[i].getName(), null);
continue;
}
// System.out.println(dataSource + ": " + tableColumns[i].getName() + ": " + tableColumns[i].getPosition());
TableCellCore cell = (currentSortColumn != null && visibleColumns[i].equals(currentSortColumn)) ? cellSort : new TableCellPainted(TableRowPainted.this, visibleColumns[i], i);
mTableCells.put(visibleColumns[i].getName(), cell);
// if (i == 10) cell.bDebug = true;
}
}
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class TableRowPainted method swt_paintGC.
/**
* @param gc GC to draw to
* @param drawBounds Area that needs redrawing
* @param rowStartX where in the GC this row's x-axis starts
* @param rowStartY where in the GC this row's y-axis starts
* @param pos
*/
public void swt_paintGC(GC gc, Rectangle drawBounds, int rowStartX, int rowStartY, int pos, boolean isTableSelected, boolean isTableEnabled) {
if (isRowDisposed() || gc == null || gc.isDisposed() || drawBounds == null || isHidden) {
return;
}
// done by caller
// if (!drawBounds.intersects(rowStartX, rowStartY, 9999, getHeight())) {
// return;
// }
TableColumnCore[] visibleColumns = getView().getVisibleColumns();
if (visibleColumns == null || visibleColumns.length == 0) {
return;
}
boolean isSelected = isSelected();
boolean isSelectedNotFocused = isSelected && !isTableSelected;
Color origBG = gc.getBackground();
Color origFG = gc.getForeground();
Color fg = getForeground();
Color shadowColor = null;
Color altColor;
Color bg;
if (isTableEnabled) {
altColor = Colors.alternatingColors[pos >= 0 ? pos % 2 : 0];
if (altColor == null) {
altColor = gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
}
if (isSelected) {
Color color;
color = gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION);
gc.setBackground(color);
} else {
gc.setBackground(altColor);
}
bg = getBackground();
if (bg == null) {
bg = gc.getBackground();
} else {
gc.setBackground(bg);
}
if (isSelected) {
shadowColor = fg;
fg = gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
} else {
if (fg == null) {
fg = gc.getDevice().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
}
}
} else {
Device device = gc.getDevice();
altColor = Colors.getSystemColor(device, SWT.COLOR_WIDGET_BACKGROUND);
if (isSelected) {
bg = Colors.getSystemColor(device, SWT.COLOR_WIDGET_LIGHT_SHADOW);
} else {
bg = altColor;
}
gc.setBackground(bg);
fg = Colors.getSystemColor(device, SWT.COLOR_WIDGET_NORMAL_SHADOW);
}
gc.setForeground(fg);
int rowAlpha = getAlpha();
Font font = gc.getFont();
Rectangle clipping = gc.getClipping();
int x = rowStartX;
// boolean paintedRow = false;
synchronized (lock) {
if (mTableCells == null) {
// not sure if this is wise, but visibleRows seems to keep up to date.. so, it must be ok!
setShown(true, true);
}
if (mTableCells != null) {
for (TableColumn tc : visibleColumns) {
TableCellCore cell = mTableCells.get(tc.getName());
int w = tc.getWidth();
Rectangle r = new Rectangle(x, rowStartY, w, getHeight());
TableCellPainted cellSWT = null;
if (cell instanceof TableCellPainted && !cell.isDisposed()) {
cellSWT = (TableCellPainted) cell;
cellSWT.setBoundsRaw(r);
}
if (drawBounds.intersects(r)) {
// paintedRow = true;
gc.setAlpha(255);
if (isSelectedNotFocused) {
gc.setBackground(altColor);
gc.fillRectangle(r);
gc.setAlpha(100);
gc.setBackground(bg);
gc.fillRectangle(r);
} else {
gc.setBackground(bg);
gc.fillRectangle(r);
if (isSelected) {
gc.setAlpha(80);
gc.setForeground(altColor);
gc.fillGradientRectangle(r.x, r.y, r.width, r.height, true);
gc.setForeground(fg);
}
}
gc.setAlpha(rowAlpha);
if (cellSWT == null) {
x += w;
continue;
}
if (swt_paintCell(gc, cellSWT.getBounds(), cellSWT, shadowColor)) {
// row color may have changed; this would update the color
// for all new cells. However, setting color triggers a
// row redraw that will fix up the UI
// Color fgNew = getForeground();
// if (fgNew != null && fgNew != fg) {
// fg = fgNew;
// }
gc.setBackground(bg);
gc.setForeground(fg);
gc.setFont(font);
Utils.setClipping(gc, clipping);
}
if (DEBUG_ROW_PAINT) {
((TableCellSWTBase) cell).debug("painted " + (cell.getVisuallyChangedSinceRefresh() ? "VC" : "!P") + " @ " + r);
}
} else {
if (DEBUG_ROW_PAINT) {
((TableCellSWTBase) cell).debug("Skip paintItem; no intersects; r=" + r + ";dB=" + drawBounds + " from " + Debug.getCompressedStackTrace(4));
}
}
x += w;
}
}
int w = drawBounds.width - x;
if (w > 0) {
Rectangle r = new Rectangle(x, rowStartY, w, getHeight());
if (clipping.intersects(r)) {
gc.setAlpha(255);
if (isSelectedNotFocused) {
gc.setBackground(altColor);
gc.fillRectangle(r);
gc.setAlpha(100);
gc.setBackground(bg);
gc.fillRectangle(r);
} else {
gc.fillRectangle(r);
if (isSelected) {
gc.setAlpha(80);
gc.setForeground(altColor);
gc.fillGradientRectangle(r.x, r.y, r.width, r.height, true);
gc.setForeground(fg);
}
}
gc.setAlpha(rowAlpha);
}
}
}
if (isFocused()) {
gc.setAlpha(40);
gc.setForeground(origFG);
gc.setLineDash(new int[] { 1, 2 });
gc.drawRectangle(rowStartX, rowStartY, getViewPainted().getClientArea().width - 1, getHeight() - 1);
gc.setLineStyle(SWT.LINE_SOLID);
}
gc.setAlpha(255);
gc.setBackground(origBG);
gc.setForeground(origFG);
}
use of com.biglybt.pif.ui.tables.TableColumn in project BiglyBT by BiglySoftware.
the class SBC_ChatOverview method initColumns.
protected void initColumns() {
synchronized (SBC_ChatOverview.class) {
if (columnsAdded) {
return;
}
columnsAdded = true;
}
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.registerColumn(ChatInstance.class, ColumnChatName.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatName(column);
}
});
tableManager.registerColumn(ChatInstance.class, ColumnChatMessageCount.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatMessageCount(column);
}
});
tableManager.registerColumn(ChatInstance.class, ColumnChatUserCount.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatUserCount(column);
}
});
tableManager.registerColumn(ChatInstance.class, ColumnChatFavorite.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatFavorite(column);
}
});
tableManager.registerColumn(ChatInstance.class, ColumnChatMsgOutstanding.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatMsgOutstanding(column);
}
});
// last
tableManager.registerColumn(ChatInstance.class, ColumnChatStatus.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnChatStatus(column);
}
});
tableManager.setDefaultColumnNames(TABLE_CHAT, new String[] { ColumnChatName.COLUMN_ID, ColumnChatMessageCount.COLUMN_ID, ColumnChatUserCount.COLUMN_ID, ColumnChatFavorite.COLUMN_ID, ColumnChatMsgOutstanding.COLUMN_ID, ColumnChatStatus.COLUMN_ID });
tableManager.setDefaultSortColumnName(TABLE_CHAT, ColumnChatName.COLUMN_ID);
}
Aggregations