Search in sources :

Example 1 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class SBC_ActivityView method skinObjectInitialShow.

// @see SkinView#showSupport(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    soListArea = getSkinObject(ID + "-area");
    SWTSkinObject so;
    so = getSkinObject(ID + "-button-smalltable");
    if (so != null) {
        btnSmallTable = new SWTSkinButtonUtility(so);
        btnSmallTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_SMALLTABLE, true);
            }
        });
    }
    so = getSkinObject(ID + "-button-bigtable");
    if (so != null) {
        btnBigTable = new SWTSkinButtonUtility(so);
        btnBigTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_BIGTABLE, true);
            }
        });
    }
    so = getSkinObject(ID + "-button-right");
    if (so != null) {
        so.setVisible(true);
        SWTSkinButtonUtility btnReadAll = new SWTSkinButtonUtility(so);
        btnReadAll.setTextID("v3.activity.button.readall");
        btnReadAll.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    entry.setRead(true);
                }
            }
        });
    }
    setViewMode(COConfigurationManager.getIntParameter(ID + ".viewmode", MODE_DEFAULT), false);
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) List(java.util.List)

Example 2 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class DataSourceUtils method getTorrent.

public static TOTorrent getTorrent(Object ds) {
    if (ds instanceof TOTorrent) {
        return (TOTorrent) ds;
    }
    if (ds instanceof DownloadManager) {
        TOTorrent torrent = ((DownloadManager) ds).getTorrent();
        if (torrent != null) {
            return torrent;
        }
    }
    if (ds instanceof ActivitiesEntry) {
        TOTorrent torrent = ((ActivitiesEntry) ds).getTorrent();
        if (torrent == null) {
            // getDM will check hash as well
            DownloadManager dm = getDM(ds);
            if (dm != null) {
                torrent = dm.getTorrent();
            }
        }
        return torrent;
    }
    if (ds instanceof TranscodeFile) {
        TranscodeFile tf = (TranscodeFile) ds;
        try {
            DiskManagerFileInfo file = tf.getSourceFile();
            if (file != null) {
                Download download = file.getDownload();
                if (download != null) {
                    Torrent torrent = download.getTorrent();
                    if (torrent != null) {
                        return PluginCoreUtils.unwrap(torrent);
                    }
                }
            }
        } catch (Throwable e) {
        }
    }
    if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
            DiskManagerFileInfo file = tj.getFile();
            if (file != null) {
                Download download = tj.getFile().getDownload();
                if (download != null) {
                    Torrent torrent = download.getTorrent();
                    if (torrent != null) {
                        return PluginCoreUtils.unwrap(torrent);
                    }
                }
            }
        } catch (DownloadException e) {
        }
    }
    if (ds instanceof ISelectedContent) {
        return ((ISelectedContent) ds).getTorrent();
    }
    if (ds instanceof String) {
        String hash = (String) ds;
        try {
            GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
            DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
            if (dm != null) {
                return dm.getTorrent();
            }
        } catch (Exception e) {
        // ignore
        }
    }
    DownloadManager dm = getDM(ds);
    if (dm != null) {
        return dm.getTorrent();
    }
    return null;
}
Also used : TOTorrent(com.biglybt.core.torrent.TOTorrent) Torrent(com.biglybt.pif.torrent.Torrent) DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DownloadManager(com.biglybt.core.download.DownloadManager) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeJob(com.biglybt.core.devices.TranscodeJob) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) GlobalManager(com.biglybt.core.global.GlobalManager) HashWrapper(com.biglybt.core.util.HashWrapper) TOTorrent(com.biglybt.core.torrent.TOTorrent) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeFile(com.biglybt.core.devices.TranscodeFile) Download(com.biglybt.pif.download.Download)

Example 3 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class PlayUtils method canPlayDS.

public static boolean canPlayDS(Object ds, int file_index, boolean block_for_accuracy) {
    if (ds == null) {
        return false;
    }
    try {
        if (!block_for_accuracy) {
            tls_non_block_indicator.get()[0]++;
        }
        if (ds instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
            com.biglybt.core.disk.DiskManagerFileInfo fi = (com.biglybt.core.disk.DiskManagerFileInfo) ds;
            return canPlayDS(fi.getDownloadManager(), fi.getIndex(), block_for_accuracy);
        }
        DownloadManager dm = DataSourceUtils.getDM(ds);
        if (dm != null) {
            return canPlay(dm, file_index);
        }
        TOTorrent torrent = DataSourceUtils.getTorrent(ds);
        if (torrent != null) {
            return canPlay(torrent, file_index);
        }
        if (ds instanceof ActivitiesEntry) {
            return ((ActivitiesEntry) ds).isPlayable(block_for_accuracy);
        }
        return false;
    } finally {
        if (!block_for_accuracy) {
            tls_non_block_indicator.get()[0]--;
        }
    }
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) TOTorrent(com.biglybt.core.torrent.TOTorrent)

Example 4 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class ColumnActivityActions method refresh.

// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
    ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
    if (entry == null)
        return;
    String[] actions = entry.getActions();
    String sort_value = "";
    for (String action : actions) {
        sort_value += "," + action;
    }
    if (sort_value.isEmpty()) {
        sort_value = entry.getTypeID();
    }
    if (!cell.setSortValue(sort_value) && cell.isValid()) {
        return;
    }
    DownloadManager dm = entry.getDownloadManger();
    boolean canPlay = PlayUtils.canPlayDS(entry, -1, false);
    boolean canDL = dm == null && entry.getDownloadManger() == null && (entry.getTorrent() != null || entry.getAssetHash() != null);
    boolean canRun = !canPlay && dm != null;
    if (canRun && dm != null && !dm.getAssumedComplete()) {
        canRun = false;
    }
    StringBuilder sb = new StringBuilder();
    if (canDL) {
        if (sb.length() > 0) {
            sb.append(" | ");
        }
        sb.append("<A HREF=\"download\">Download</A>");
    }
    if (canPlay) {
        if (sb.length() > 0) {
            sb.append(" | ");
        }
        sb.append("<A HREF=\"play\">Play</A>");
    }
    if (canRun) {
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append("<A HREF=\"launch\">Launch</A>");
    }
    for (String action : actions) {
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append("<A HREF=\"action:").append(action).append("\">").append(action).append("</A>");
    }
    cell.getTableRow().setData("text", sb.toString());
}
Also used : ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 5 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class ColumnActivityDate method refresh.

// @see com.biglybt.ui.swt.views.tableitems.ColumnDateSizer#refresh(com.biglybt.pif.ui.tables.TableCell, long)
@Override
public void refresh(TableCell cell, long timestamp) {
    ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
    timestamp = entry.getTimestamp();
    super.refresh(cell, timestamp);
}
Also used : ActivitiesEntry(com.biglybt.activities.ActivitiesEntry)

Aggregations

ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)21 GCStringPrinter (com.biglybt.ui.swt.shells.GCStringPrinter)4 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)4 List (java.util.List)4 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)3 URLInfo (com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo)3 Image (org.eclipse.swt.graphics.Image)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)2 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)2 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)2 ArrayList (java.util.ArrayList)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ActivitiesListener (com.biglybt.activities.ActivitiesListener)1 TranscodeFile (com.biglybt.core.devices.TranscodeFile)1 TranscodeJob (com.biglybt.core.devices.TranscodeJob)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 PlatformMessage (com.biglybt.core.messenger.PlatformMessage)1