use of com.biglybt.ui.common.table.TableColumnCore 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.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableColumnCreator method setVisibility.
private static void setVisibility(Map mapTCs, String[] defaultVisibleOrder) {
for (Iterator iter = mapTCs.values().iterator(); iter.hasNext(); ) {
TableColumnCore tc = (TableColumnCore) iter.next();
Long force_visible = (Long) tc.getUserData(TableColumn.UD_FORCE_VISIBLE);
if (force_visible == null || force_visible == 0) {
tc.setVisible(false);
}
}
for (int i = 0; i < defaultVisibleOrder.length; i++) {
String id = defaultVisibleOrder[i];
TableColumnCore tc = (TableColumnCore) mapTCs.get(id);
if (tc != null) {
tc.setVisible(true);
tc.setPositionNoShift(i);
}
}
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableColumnCreator method createCompleteDM.
public static TableColumnCore[] createCompleteDM(String tableID) {
final String[] defaultVisibleOrder = { HealthItem.COLUMN_ID, RankItem.COLUMN_ID, "SeedingRank", NameItem.COLUMN_ID, "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", "RatingColumn", "Info", "RateIt", CommentIconItem.COLUMN_ID, SizeItem.COLUMN_ID, StatusItem.COLUMN_ID, SeedsItem.COLUMN_ID, PeersItem.COLUMN_ID, UpSpeedItem.COLUMN_ID, ShareRatioItem.COLUMN_ID, UpItem.COLUMN_ID, TrackerStatusItem.COLUMN_ID };
TableColumnManager tcManager = TableColumnManager.getInstance();
Map mapTCs = tcManager.getTableColumnsAsMap(DownloadTypeComplete.class, tableID);
tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
if (!tcManager.loadTableColumnSettings(DownloadTypeComplete.class, tableID) || areNoneVisible(mapTCs)) {
setVisibility(mapTCs, defaultVisibleOrder);
RankItem tc = (RankItem) mapTCs.get(RankItem.COLUMN_ID);
if (tc != null) {
tcManager.setDefaultSortColumnName(tableID, RankItem.COLUMN_ID);
tc.setSortAscending(true);
}
}
return (TableColumnCore[]) mapTCs.values().toArray(new TableColumnCore[0]);
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableColumnCreator method createIncompleteDM.
public static TableColumnCore[] createIncompleteDM(String tableID) {
final String[] defaultVisibleOrder = { HealthItem.COLUMN_ID, RankItem.COLUMN_ID, NameItem.COLUMN_ID, "TorrentStream", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", "RatingColumn", "Info", CommentIconItem.COLUMN_ID, SizeItem.COLUMN_ID, DownItem.COLUMN_ID, DoneItem.COLUMN_ID, StatusItem.COLUMN_ID, SeedsItem.COLUMN_ID, PeersItem.COLUMN_ID, DownSpeedItem.COLUMN_ID, UpSpeedItem.COLUMN_ID, ETAItem.COLUMN_ID, ShareRatioItem.COLUMN_ID, TrackerStatusItem.COLUMN_ID };
TableColumnManager tcManager = TableColumnManager.getInstance();
Map mapTCs = tcManager.getTableColumnsAsMap(DownloadTypeIncomplete.class, tableID);
tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
if (!tcManager.loadTableColumnSettings(DownloadTypeIncomplete.class, tableID) || areNoneVisible(mapTCs)) {
setVisibility(mapTCs, defaultVisibleOrder);
RankItem tc = (RankItem) mapTCs.get(RankItem.COLUMN_ID);
if (tc != null) {
tcManager.setDefaultSortColumnName(tableID, RankItem.COLUMN_ID);
tc.setSortAscending(true);
}
}
return (TableColumnCore[]) mapTCs.values().toArray(new TableColumnCore[0]);
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableCellSWTBase method dispose.
@Override
public void dispose() {
if (isDisposed()) {
// parg added this check at same time as removing the isDisposed check in getDataSource
// in case there is some recursive disposal occuring on a dispose-listener
Debug.out("Double disposal!");
return;
}
setFlag(FLAG_DISPOSED);
TableColumnCore tc = tableColumn;
if (tc != null) {
tc.invokeCellDisposeListeners(this);
}
if (disposeListeners != null) {
try {
for (Iterator iter = disposeListeners.iterator(); iter.hasNext(); ) {
TableCellDisposeListener listener = (TableCellDisposeListener) iter.next();
listener.dispose(this);
}
disposeListeners = null;
} catch (Throwable e) {
pluginError(e);
}
}
refreshListeners = null;
tableColumn = null;
tableRow = null;
sortValue = null;
}
Aggregations