Search in sources :

Example 6 with TableCellCore

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;
}
Also used : TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Example 7 with TableCellCore

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;
    }
}
Also used : TableRowCore(com.biglybt.ui.common.table.TableRowCore) TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Example 8 with TableCellCore

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;
    }
}
Also used : TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Example 9 with TableCellCore

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();
        }
    }
}
Also used : TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Example 10 with TableCellCore

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);
                    }
                }
            }
        }
    }
}
Also used : TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Aggregations

TableCellCore (com.biglybt.ui.common.table.TableCellCore)18 TableRowCore (com.biglybt.ui.common.table.TableRowCore)6 Rectangle (org.eclipse.swt.graphics.Rectangle)4 TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)3 Point (org.eclipse.swt.graphics.Point)3 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2 DownloadManager (com.biglybt.core.download.DownloadManager)2 TableColumn (com.biglybt.pif.ui.tables.TableColumn)2 FilesView (com.biglybt.ui.swt.views.FilesView)2 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 MenuItem (com.biglybt.pif.ui.menus.MenuItem)1 TableCell (com.biglybt.pif.ui.tables.TableCell)1 TableSelectedRowsListener (com.biglybt.ui.swt.views.table.TableSelectedRowsListener)1 TableCellSWTBase (com.biglybt.ui.swt.views.table.impl.TableCellSWTBase)1 File (java.io.File)1 CLabel (org.eclipse.swt.custom.CLabel)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1