use of com.biglybt.core.devices.TranscodeFile 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.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Tags method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
String[] tags = tf.getTags(true);
String str = "";
for (String tag : tags) {
str += (str.length() == 0 ? "" : ",") + tag;
}
cell.setText(str);
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Completion method refresh.
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
int percentDone = getPerThouDone(tf);
cell.setSortValue(percentDone);
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Name method refresh.
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
String text = tf.getName();
if (text == null || text.length() == 0) {
return;
}
cell.setText(text);
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Status method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null || tf.isDeleted()) {
return;
}
TranscodeJob job = tf.getJob();
String tooltip = null;
String text = null;
boolean error = false;
if (job == null) {
try {
if (tf.isComplete() && !tf.getTargetFile().getFile(true).exists()) {
tooltip = "File '" + tf.getTargetFile().getFile().getAbsolutePath() + "' not found";
text = js_resources[5] + ": File not found";
error = true;
}
} catch (Throwable e) {
}
if (text == null) {
if (tf.isCopyingToDevice()) {
text = js_resources[11];
} else if (tf.getCopyToDeviceFails() > 0) {
text = js_resources[7];
error = true;
} else if (tf.isTemplate() && !tf.isComplete()) {
text = js_resources[8];
} else {
text = js_resources[9];
}
}
} else {
int state = job.getState();
text = js_resources[state];
if (state == TranscodeJob.ST_QUEUED) {
long eta = job.getDownloadETA();
if (eta > 0) {
text = js_resources[10] + ": " + eta_text + " " + (eta == Long.MAX_VALUE ? Constants.INFINITY_STRING : TimeFormatter.format(eta));
}
} else {
text = js_resources[state];
if (state == TranscodeJob.ST_FAILED) {
String error_msg = job.getError();
if (error_msg != null) {
try {
int pos = error_msg.indexOf('\n');
if (pos >= 0) {
error_msg = error_msg.substring(0, pos);
}
pos = error_msg.indexOf(',');
if (pos >= 0) {
pos = error_msg.indexOf(',', pos + 1);
if (pos >= 0) {
error_msg = error_msg.substring(0, pos);
}
}
text += ": " + error_msg.trim();
} catch (Throwable e) {
}
}
tooltip = "See transcode log for more details";
error = true;
}
}
}
cell.setText(text);
cell.setToolTip(tooltip);
if (error) {
cell.setForegroundToErrorColor();
} else {
cell.setForeground(Utils.colorToIntArray(null));
}
}
Aggregations