use of com.biglybt.pif.download.DownloadStub.DownloadStubEx in project BiglyBT by BiglySoftware.
the class ColumnArchiveDLDate method refresh.
@Override
public void refresh(TableCell cell) {
TableColumn tc = cell.getTableColumn();
if (tc instanceof ColumnDateSizer) {
DownloadStubEx dl = (DownloadStubEx) cell.getDataSource();
((ColumnDateSizer) tc).refresh(cell, dl.getCreationDate());
}
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubEx in project BiglyBT by BiglySoftware.
the class ColumnArchiveDLTags method refresh.
@Override
public void refresh(TableCell cell) {
DownloadStubEx dl = (DownloadStubEx) cell.getDataSource();
String text = "";
if (dl != null) {
String[] tags = dl.getManualTags();
if (tags != null) {
for (String t : tags) {
text += (text.length() == 0 ? "" : ", ") + t;
}
}
}
if (!cell.setSortValue(text) && cell.isValid()) {
return;
}
if (!cell.isShown()) {
return;
}
cell.setText(text);
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubEx in project BiglyBT by BiglySoftware.
the class ColumnArchiveShareRatio method refresh.
@Override
public void refresh(TableCell cell) {
DownloadStubEx dl = (DownloadStubEx) cell.getDataSource();
String sr_str;
int sr = -1;
if (dl != null) {
sr = dl.getShareRatio();
if (sr < 0) {
// migration
sr_str = "";
} else if (sr == Integer.MAX_VALUE) {
sr_str = Constants.INFINITY_STRING;
} else {
sr_str = DisplayFormatters.formatDecimal((double) sr / 1000, 3);
}
} else {
sr_str = "";
}
if (!cell.setSortValue(sr) && cell.isValid()) {
return;
}
cell.setText(sr_str);
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubEx in project BiglyBT by BiglySoftware.
the class TorrentUtil method removeDownloadStubsPrompterClosed.
private static void removeDownloadStubsPrompterClosed(DownloadStubEx[] dms, int index, AERunnable deleteFailed, int result, boolean doAll, boolean deleteTorrent) {
if (result == -1) {
// list
return;
}
if (doAll) {
if (result == 1 || result == 2) {
for (int i = index; i < dms.length; i++) {
DownloadStubEx dm = dms[i];
boolean deleteData = result == 2 ? false : // dm.getDownloadState().getFlag(Download.FLAG_DO_NOT_DELETE_DATA_ON_REMOVE);
!false;
// ManagerUtils.asyncStopDelete(dm, DownloadManager.STATE_STOPPED, deleteTorrent, deleteData, deleteFailed);
try {
dm.remove(deleteTorrent, deleteData);
} catch (Throwable e) {
if (deleteFailed != null) {
deleteFailed.runSupport();
}
}
}
}
// else cancel
} else {
// not remembered
if (result == 1 || result == 2) {
DownloadStubEx dm = dms[index];
boolean deleteData = result == 2 ? false : // dm.getDownloadState().getFlag(Download.FLAG_DO_NOT_DELETE_DATA_ON_REMOVE);
!false;
// ManagerUtils.asyncStopDelete(dm, DownloadManager.STATE_STOPPED, deleteTorrent, deleteData, null);
try {
dm.remove(deleteTorrent, deleteData);
} catch (Throwable e) {
// no delete failed logic here apparently...
}
}
// remove the one we just did and go through loop again
dms[index] = null;
if (index != dms.length - 1) {
removeDownloadStubs(dms, deleteFailed, true);
}
}
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubEx in project BiglyBT by BiglySoftware.
the class TorrentUtil method removeDownloadStubs.
public static void removeDownloadStubs(final DownloadStubEx[] dms, final AERunnable deleteFailed, final boolean forcePrompt) {
if (dms == null) {
return;
}
for (int i = 0; i < dms.length; i++) {
DownloadStubEx dm = dms[i];
boolean deleteTorrent = COConfigurationManager.getBooleanParameter("def.deletetorrent");
int confirm = COConfigurationManager.getIntParameter("tb.confirm.delete.content");
boolean doPrompt = confirm == 0 | forcePrompt;
if (doPrompt) {
String title = MessageText.getString("deletedata.title");
String text = MessageText.getString("v3.deleteContent.message", new String[] { dm.getName() });
String[] buttons;
int defaultButtonPos;
buttons = new String[] { MessageText.getString("Button.cancel"), MessageText.getString("Button.deleteContent.fromComputer"), MessageText.getString("Button.deleteContent.fromLibrary") };
/*
int[] buttonVals = new int[] {
SWT.CANCEL,
1,
2
};
*/
defaultButtonPos = 2;
final MessageBoxShell mb = new MessageBoxShell(title, text, buttons, defaultButtonPos);
int numLeft = (dms.length - i);
if (numLeft > 1) {
mb.setRemember("na", false, MessageText.getString("v3.deleteContent.applyToAll", new String[] { "" + numLeft }));
// never store remember state
mb.setRememberOnlyIfButton(-3);
}
mb.setRelatedObject(dm);
mb.setLeftImage("image.trash");
mb.addCheckBox("deletecontent.also.deletetorrent", 2, deleteTorrent);
final int index = i;
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
ImageLoader.getInstance().releaseImage("image.trash");
removeDownloadStubsPrompterClosed(dms, index, deleteFailed, result, mb.isRemembered(), mb.getCheckBoxEnabled());
}
});
return;
} else {
boolean deleteData = confirm == 1;
removeDownloadStubsPrompterClosed(dms, i, deleteFailed, deleteData ? 1 : 2, true, deleteTorrent);
}
}
}
Aggregations