use of com.biglybt.ui.common.table.TableCellCore in project BiglyBT by BiglySoftware.
the class TableRowSWTBase method refresh.
/* (non-Javadoc)
* @see TableRowCore#refresh(boolean, boolean)
*/
@Override
public List<TableCellCore> refresh(boolean bDoGraphics, boolean bVisible) {
// If this were called from a plugin, we'd have to refresh the sorted column
// even if we weren't visible
List<TableCellCore> list = Collections.EMPTY_LIST;
if (bDisposed) {
return list;
}
if (!bVisible) {
if (!bSetNotUpToDateLastRefresh) {
setUpToDate(false);
bSetNotUpToDateLastRefresh = true;
}
return list;
}
bSetNotUpToDateLastRefresh = false;
// System.out.println(SystemTime.getCurrentTime() + "refresh " + getIndex() + ";vis=" + bVisible + " via " + Debug.getCompressedStackTrace(8));
tv.invokeRefreshListeners(this);
// Make a copy of cells so we don't lock while refreshing
Collection<TableCellCore> lTableCells = null;
synchronized (lock) {
if (mTableCells != null) {
lTableCells = new ArrayList<>(mTableCells.values());
}
}
if (lTableCells != null) {
for (TableCellCore cell : lTableCells) {
if (cell == null || cell.isDisposed()) {
continue;
}
TableColumn column = cell.getTableColumn();
// System.out.println(column);
if (column != tv.getSortColumn() && !tv.isColumnVisible(column)) {
// System.out.println("skip " + column);
continue;
}
boolean cellVisible = bVisible && cell.isShown();
boolean changed = cell.refresh(bDoGraphics, bVisible, cellVisible);
if (changed) {
if (list == Collections.EMPTY_LIST) {
list = new ArrayList<>(lTableCells.size());
}
list.add(cell);
}
}
}
// System.out.println();
return list;
}
use of com.biglybt.ui.common.table.TableCellCore in project BiglyBT by BiglySoftware.
the class TableColumnImpl method compare.
// @see java.util.Comparator#compare(T, T)
@Override
public int compare(Object arg0, Object arg1) {
TableCellCore cell0 = ((TableRowCore) arg0).getTableCellCore(sName);
TableCellCore cell1 = ((TableRowCore) arg1).getTableCellCore(sName);
Comparable c0 = (cell0 == null) ? "" : cell0.getSortValue();
Comparable c1 = (cell1 == null) ? "" : cell1.getSortValue();
// Put nulls and empty strings at bottom.
boolean c0_is_null = (c0 == null || c0.equals(""));
boolean c1_is_null = (c1 == null || c1.equals(""));
if (c1_is_null) {
return (c0_is_null) ? 0 : -1;
} else if (c0_is_null) {
return 1;
}
try {
boolean c0isString = c0 instanceof String;
boolean c1isString = c1 instanceof String;
if (c0isString && c1isString) {
if (bSortAscending) {
return ((String) c0).compareToIgnoreCase((String) c1);
}
return ((String) c1).compareToIgnoreCase((String) c0);
}
int val;
if (c0isString && !c1isString) {
val = -1;
} else if (c1isString && !c0isString) {
val = 1;
} else {
val = c1.compareTo(c0);
}
return bSortAscending ? -val : val;
} catch (ClassCastException e) {
int c0_index = (cell0 == null) ? -999 : cell0.getTableRowCore().getIndex();
int c1_index = (cell1 == null) ? -999 : cell1.getTableRowCore().getIndex();
System.err.println("Can't compare " + c0.getClass().getName() + "(" + c0.toString() + ") from row #" + c0_index + " to " + c1.getClass().getName() + "(" + c1.toString() + ") from row #" + c1_index + " while sorting column " + sName);
e.printStackTrace();
return 0;
}
}
use of com.biglybt.ui.common.table.TableCellCore in project BiglyBT by BiglySoftware.
the class ColumnImageClickArea method cellMouseTrigger.
// @see com.biglybt.pif.ui.tables.TableCellMouseListener#cellMouseTrigger(com.biglybt.pif.ui.tables.TableCellMouseEvent)
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
if (!isVisible) {
return;
}
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN) {
mouseDownOn = false;
Point pt = new Point(event.x, event.y);
mouseDownOn = getArea().contains(pt);
TableCellCore cell = (TableCellCore) event.row.getTableCell(columnID);
if (cell != null) {
cell.invalidate();
cell.refreshAsync();
}
} else if (event.eventType == TableCellMouseEvent.EVENT_MOUSEUP && mouseDownOn) {
mouseDownOn = false;
TableCellMouseEvent mouseEvent = new TableCellMouseEvent();
mouseEvent.button = event.button;
mouseEvent.cell = event.cell;
// EVENT_MOUSECLICK would be nice..
mouseEvent.eventType = TableCellMouseEvent.EVENT_MOUSEUP;
mouseEvent.keyboardState = event.keyboardState;
mouseEvent.skipCoreFunctionality = event.skipCoreFunctionality;
// TODO: Convert to coord relative to image?
mouseEvent.x = event.x;
mouseEvent.y = event.y;
mouseEvent.data = this;
((TableColumnCore) event.cell.getTableColumn()).invokeCellMouseListeners(mouseEvent);
((TableCellCore) event.cell).invokeMouseListeners(mouseEvent);
} else if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE) {
boolean contains = getArea().contains(event.x, event.y);
setContainsMouse(event.cell, contains);
} else if (event.eventType == TableCellMouseEvent.EVENT_MOUSEEXIT) {
setContainsMouse(event.cell, false);
} else if (event.eventType == TableCellMouseEvent.EVENT_MOUSEDOUBLECLICK) {
event.skipCoreFunctionality = true;
}
}
use of com.biglybt.ui.common.table.TableCellCore in project BiglyBT by BiglySoftware.
the class ColumnImageClickArea method rowMouseTrigger.
// @see com.biglybt.pif.ui.tables.TableRowMouseListener#rowMouseTrigger(com.biglybt.pif.ui.tables.TableRowMouseEvent)
@Override
public void rowMouseTrigger(TableRowMouseEvent event) {
if (!isVisible) {
return;
}
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEEXIT) {
if (rowContainingMouse == event.row) {
rowContainingMouse = null;
}
setContainsMouse(null, false);
// System.out.println("d=" + image);
TableCellCore cell = (TableCellCore) event.row.getTableCell(columnID);
if (cell != null) {
cell.invalidate();
cell.refreshAsync();
}
} else if (event.eventType == TableCellMouseEvent.EVENT_MOUSEENTER) {
rowContainingMouse = event.row;
// System.out.println("e=" + image);
TableCellCore cell = (TableCellCore) event.row.getTableCell(columnID);
if (cell != null) {
cell.invalidate();
cell.refreshAsync();
}
}
}
use of com.biglybt.ui.common.table.TableCellCore in project BiglyBT by BiglySoftware.
the class ColumnImageClickArea method setContainsMouse.
private void setContainsMouse(TableCell cell, boolean contains) {
if (cellContainsMouse != contains) {
cellContainsMouse = contains;
if (cell != null) {
TableCellCore cellCore = (TableCellCore) cell;
cellCore.invalidate();
cellCore.refreshAsync();
cellCore.setCursorID(cellContainsMouse ? SWT.CURSOR_HAND : SWT.CURSOR_ARROW);
if (tooltip != null) {
if (cellContainsMouse) {
cellCore.setToolTip(tooltip);
} else {
Object oldTT = cellCore.getToolTip();
if (tooltip.equals(oldTT)) {
cellCore.setToolTip(null);
}
}
}
}
}
}
Aggregations