Search in sources :

Example 21 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class NameItem method refresh.

@Override
public void refresh(TableCell cell, boolean sortOnlyRefresh) {
    final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    String name = (fileInfo == null) ? "" : fileInfo.getFile(true).getName();
    if (name == null)
        name = "";
    cell.setSortValue(name);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 22 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class PathItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    cell.setText(determinePath(fileInfo, show_full_path));
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 23 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class PathNameItem method refresh.

@Override
public void refresh(TableCell cell, boolean sortOnlyRefresh) {
    final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    String file_name = (fileInfo == null) ? "" : fileInfo.getFile(true).getName();
    if (file_name == null)
        file_name = "";
    String file_path = PathItem.determinePath(fileInfo, show_full_path);
    if (!file_path.isEmpty()) {
        if (!file_path.endsWith(File.separator)) {
            file_path += File.separator;
        }
        file_name = file_path + file_name;
    }
    // setText returns true only if the text is updated
    if (cell.setText(file_name) || !cell.isValid()) {
        if (bShowIcon && !sortOnlyRefresh) {
            Image icon = null;
            final TableCellSWT _cell = (TableCellSWT) cell;
            if (fileInfo == null) {
                icon = null;
            } else {
                if (Utils.isSWTThread()) {
                    icon = ImageRepository.getPathIcon(fileInfo.getFile(true).getPath(), cell.getHeight() > 32, false);
                } else {
                    // happens rarely (seen of filtering of file-view rows
                    // when a new row is added )
                    Utils.execSWTThread(new Runnable() {

                        @Override
                        public void run() {
                            Image icon = ImageRepository.getPathIcon(fileInfo.getFile(true).getPath(), _cell.getHeight() > 32, false);
                            _cell.setIcon(icon);
                            _cell.redraw();
                        }
                    });
                }
            }
            if (icon != null) {
                _cell.setIcon(icon);
            }
        }
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) Image(org.eclipse.swt.graphics.Image)

Example 24 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class AlertsItem method refresh.

@Override
public void refresh(TableCell cell) {
    UISWTGraphic icon = null;
    int sort = 0;
    Object ds = cell.getDataSource();
    if (ds instanceof DownloadManager) {
        DownloadManager dm = (DownloadManager) ds;
        Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
        if (map != null && map.size() > 0) {
            for (String k : map.keySet()) {
                if (k.length() > 0) {
                    if (Character.isDigit(k.charAt(0))) {
                        icon = gray_tick_icon;
                        sort = 1;
                    } else {
                        icon = black_tick_icon;
                        sort = 2;
                        break;
                    }
                }
            }
        }
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fi = (DiskManagerFileInfo) ds;
        DownloadManager dm = fi.getDownloadManager();
        if (dm != null) {
            Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
            if (map != null && map.size() > 0) {
                String prefix = fi.getIndex() + ".";
                for (String k : map.keySet()) {
                    if (k.startsWith(prefix)) {
                        icon = black_tick_icon;
                        sort = 2;
                        break;
                    }
                }
            }
        }
    }
    cell.setSortValue(sort);
    if (cell.getGraphic() != icon) {
        cell.setGraphic(icon);
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) UISWTGraphic(com.biglybt.ui.swt.pif.UISWTGraphic) DownloadManager(com.biglybt.core.download.DownloadManager) Map(java.util.Map)

Example 25 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class FileExtensionItem method refresh.

@Override
public void refresh(TableCell cell) {
    Object ds = cell.getDataSource();
    String text = "";
    DownloadManager dm;
    if (ds instanceof DownloadManager) {
        dm = (DownloadManager) ds;
        DiskManagerFileInfo prim = dm.getDownloadState().getPrimaryFile();
        text = prim == null ? "" : prim.getFile(true).getName();
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        dm = fileInfo.getDownloadManager();
        text = fileInfo.getFile(true).getName();
    } else {
        return;
    }
    String incomp_suffix = dm == null ? null : dm.getDownloadState().getAttribute(DownloadManagerState.AT_INCOMP_FILE_SUFFIX);
    if (incomp_suffix != null && text.endsWith(incomp_suffix)) {
        text = text.substring(0, text.length() - incomp_suffix.length());
    }
    int pos = text.lastIndexOf(".");
    if (pos >= 0) {
        text = text.substring(pos + 1);
    } else {
        text = "";
    }
    cell.setText(text);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)107 DownloadManager (com.biglybt.core.download.DownloadManager)54 File (java.io.File)16 TOTorrent (com.biglybt.core.torrent.TOTorrent)15 PEPeerManager (com.biglybt.core.peer.PEPeerManager)9 DiskManagerFileInfoSet (com.biglybt.core.disk.DiskManagerFileInfoSet)8 TableRowCore (com.biglybt.ui.common.table.TableRowCore)8 DiskManager (com.biglybt.core.disk.DiskManager)7 IOException (java.io.IOException)7 Point (org.eclipse.swt.graphics.Point)7 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)6 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)6 FilesView (com.biglybt.ui.swt.views.FilesView)6 List (java.util.List)6 Image (org.eclipse.swt.graphics.Image)6 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)5 PEPeer (com.biglybt.core.peer.PEPeer)5 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)5 UIFunctions (com.biglybt.ui.UIFunctions)5 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)5