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;
}
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;
}
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]--;
}
}
}
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());
}
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);
}
Aggregations