'/' + failedDownload.size() +
'/' + (completedDownloadToDisk.size() + completedDownloadToTemp.size()) +
") "+l10n("titleDownloads");
PageNode page = pageMaker.getPageNode(pageName, ctx);
HTMLNode pageNode = page.outer;
HTMLNode contentNode = page.content;
/* add alert summary box */
if(ctx.isAllowedFullAccess())
contentNode.addChild(ctx.getAlertManager().createSummary());
/* navigation bar */
InfoboxNode infobox = pageMaker.getInfobox("navbar", l10n("requestNavigation"), null, false);
HTMLNode navigationBar = infobox.outer;
HTMLNode navigationContent = infobox.content.addChild("ul");
boolean includeNavigationBar = false;
if (!completedDownloadToTemp.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#completedDownloadToTemp", l10n("completedDtoTemp", new String[]{ "size" }, new String[]{ String.valueOf(completedDownloadToTemp.size()) }));
includeNavigationBar = true;
}
if (!completedDownloadToDisk.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#completedDownloadToDisk", l10n("completedDtoDisk", new String[]{ "size" }, new String[]{ String.valueOf(completedDownloadToDisk.size()) }));
includeNavigationBar = true;
}
if (!completedUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#completedUpload", l10n("completedU", new String[]{ "size" }, new String[]{ String.valueOf(completedUpload.size()) }));
includeNavigationBar = true;
}
if (!completedDirUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#completedDirUpload", l10n("completedDU", new String[]{ "size" }, new String[]{ String.valueOf(completedDirUpload.size()) }));
includeNavigationBar = true;
}
if (!failedDownload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#failedDownload", l10n("failedD", new String[]{ "size" }, new String[]{ String.valueOf(failedDownload.size()) }));
includeNavigationBar = true;
}
if (!failedUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#failedUpload", l10n("failedU", new String[]{ "size" }, new String[]{ String.valueOf(failedUpload.size()) }));
includeNavigationBar = true;
}
if (!failedDirUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#failedDirUpload", l10n("failedDU", new String[]{ "size" }, new String[]{ String.valueOf(failedDirUpload.size()) }));
includeNavigationBar = true;
}
if (failedUnknownMIMEType.size() > 0) {
String[] types = failedUnknownMIMEType.keySet().toArray(new String[failedUnknownMIMEType.size()]);
Arrays.sort(types);
for(String type : types) {
String atype = type.replace("-", "--").replace('/', '-');
navigationContent.addChild("li").addChild("a", "href", "#failedDownload-unknowntype-"+atype, l10n("failedDUnknownMIME", new String[]{ "size", "type" }, new String[]{ String.valueOf(failedUnknownMIMEType.get(type).size()), type }));
}
}
if (failedBadMIMEType.size() > 0) {
String[] types = failedBadMIMEType.keySet().toArray(new String[failedBadMIMEType.size()]);
Arrays.sort(types);
for(String type : types) {
String atype = type.replace("-", "--").replace('/', '-');
navigationContent.addChild("li").addChild("a", "href", "#failedDownload-badtype-"+atype, l10n("failedDBadMIME", new String[]{ "size", "type" }, new String[]{ String.valueOf(failedBadMIMEType.get(type).size()), type }));
}
}
if (!uncompletedDownload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#uncompletedDownload", l10n("DinProgress", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedDownload.size()) }));
includeNavigationBar = true;
}
if (!uncompletedUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#uncompletedUpload", l10n("UinProgress", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedUpload.size()) }));
includeNavigationBar = true;
}
if (!uncompletedDirUpload.isEmpty()) {
navigationContent.addChild("li").addChild("a", "href", "#uncompletedDirUpload", l10n("DUinProgress", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedDirUpload.size()) }));
includeNavigationBar = true;
}
if (totalQueuedDownloadSize > 0) {
navigationContent.addChild("li", l10n("totalQueuedDownloads", "size", SizeUtil.formatSize(totalQueuedDownloadSize)));
includeNavigationBar = true;
}
if (totalQueuedUploadSize > 0) {
navigationContent.addChild("li", l10n("totalQueuedUploads", "size", SizeUtil.formatSize(totalQueuedUploadSize)));
includeNavigationBar = true;
}
navigationContent.addChild("li").addChild("a", "href", FETCH_KEY_LIST_LOCATION,
l10n("openKeyList"));
if (includeNavigationBar) {
contentNode.addChild(navigationBar);
}
final String[] priorityClasses = new String[] {
l10n("priority0"),
l10n("priority1"),
l10n("priority2"),
l10n("priority3"),
l10n("priority4"),
l10n("priority5"),
l10n("priority6")
};
boolean advancedModeEnabled = pageMaker.advancedMode(request, this.container);
HTMLNode legendContent = pageMaker.getInfobox("legend", l10n("legend"), contentNode, "queue-legend", true);
HTMLNode legendTable = legendContent.addChild("table", "class", "queue");
HTMLNode legendRow = legendTable.addChild("tr");
for(int i=0; i<7; i++){
if(i > RequestStarter.INTERACTIVE_PRIORITY_CLASS || advancedModeEnabled || i <= lowestQueuedPrio)
legendRow.addChild("td", "class", "priority" + i, priorityClasses[i]);
}
if (SimpleToadletServer.isPanicButtonToBeShown) {
// There may be persistent downloads etc under other PersistentRequestClient's, so still show it.
contentNode.addChild(createPanicBox(pageMaker, ctx));
}
final QueueColumn[] advancedModeFailure = new QueueColumn[] {
QueueColumn.IDENTIFIER,
QueueColumn.FILENAME,
QueueColumn.SIZE,
QueueColumn.MIME_TYPE,
QueueColumn.PROGRESS,
QueueColumn.REASON,
QueueColumn.PERSISTENCE,
QueueColumn.KEY };
final QueueColumn[] simpleModeFailure = new QueueColumn[] {
QueueColumn.FILENAME,
QueueColumn.SIZE,
QueueColumn.PROGRESS,
QueueColumn.REASON,
QueueColumn.KEY };
if (!completedDownloadToTemp.isEmpty()) {
contentNode.addChild("a", "id", "completedDownloadToTemp");
HTMLNode completedDownloadsToTempContent = pageMaker.getInfobox("completed_requests", l10n("completedDinTempDirectory", new String[]{ "size" }, new String[]{ String.valueOf(completedDownloadToTemp.size()) }), contentNode, "request-completed", false);
if (advancedModeEnabled) {
completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToTemp, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.SIZE, QueueColumn.MIME_TYPE, QueueColumn.PERSISTENCE, QueueColumn.KEY, QueueColumn.COMPAT_MODE }, priorityClasses, advancedModeEnabled, false, "completed-temp", true, true));
} else {
completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToTemp, new QueueColumn[] { QueueColumn.SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "completed-temp", true, true));
}
}
if (!completedDownloadToDisk.isEmpty()) {
contentNode.addChild("a", "id", "completedDownloadToDisk");
HTMLNode completedToDiskInfoboxContent = pageMaker.getInfobox("completed_requests", l10n("completedDinDownloadDirectory", new String[]{ "size" }, new String[]{ String.valueOf(completedDownloadToDisk.size()) }), contentNode, "request-completed", false);
if (advancedModeEnabled) {
completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToDisk, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.MIME_TYPE, QueueColumn.PERSISTENCE, QueueColumn.KEY, QueueColumn.COMPAT_MODE }, priorityClasses, advancedModeEnabled, false, "completed-disk", false, true));
} else {
completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToDisk, new QueueColumn[] { QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "completed-disk", false, true));
}
}
if (!completedUpload.isEmpty()) {
contentNode.addChild("a", "id", "completedUpload");
HTMLNode completedUploadInfoboxContent = pageMaker.getInfobox("completed_requests", l10n("completedU", new String[]{ "size" }, new String[]{ String.valueOf(completedUpload.size()) }), contentNode, "download-completed", false);
if (advancedModeEnabled) {
completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedUpload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.MIME_TYPE, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "completed-upload-file", false, true));
} else {
completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedUpload, new QueueColumn[] { QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "completed-upload-file", false, true));
}
}
if (!completedDirUpload.isEmpty()) {
contentNode.addChild("a", "id", "completedDirUpload");
HTMLNode completedUploadDirContent = pageMaker.getInfobox("completed_requests", l10n("completedUDirectory", new String[]{ "size" }, new String[]{ String.valueOf(completedDirUpload.size()) }), contentNode, "download-completed", false);
if (advancedModeEnabled) {
completedUploadDirContent.addChild(createRequestTable(pageMaker, ctx, completedDirUpload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILES, QueueColumn.TOTAL_SIZE, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "completed-upload-dir", false, true));
} else {
completedUploadDirContent.addChild(createRequestTable(pageMaker, ctx, completedDirUpload, new QueueColumn[] { QueueColumn.FILES, QueueColumn.TOTAL_SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "completed-upload-dir", false, true));
}
}
if (!failedDownload.isEmpty()) {
contentNode.addChild("a", "id", "failedDownload");
HTMLNode failedContent = pageMaker.getInfobox("failed_requests", l10n("failedD", new String[]{ "size" }, new String[]{ String.valueOf(failedDownload.size()) }), contentNode, "download-failed", false);
if (advancedModeEnabled) {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedDownload, advancedModeFailure, priorityClasses, advancedModeEnabled, false, "failed-download", false, true, false, false, null));
} else {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedDownload, simpleModeFailure, priorityClasses, advancedModeEnabled, false, "failed-download", false, true, false, false, null));
}
}
if (!failedUpload.isEmpty()) {
contentNode.addChild("a", "id", "failedUpload");
HTMLNode failedContent = pageMaker.getInfobox("failed_requests", l10n("failedU", new String[]{ "size" }, new String[]{ String.valueOf(failedUpload.size()) }), contentNode, "upload-failed", false);
if (advancedModeEnabled) {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedUpload, advancedModeFailure, priorityClasses, advancedModeEnabled, true, "failed-upload-file", false, true, false, false, null));
} else {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedUpload, simpleModeFailure, priorityClasses, advancedModeEnabled, true, "failed-upload-file", false, true, false, false, null));
}
}
if (!failedDirUpload.isEmpty()) {
contentNode.addChild("a", "id", "failedDirUpload");
HTMLNode failedContent = pageMaker.getInfobox("failed_requests", l10n("failedU", new String[]{ "size" }, new String[]{ String.valueOf(failedDirUpload.size()) }), contentNode, "upload-failed", false);
if (advancedModeEnabled) {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedDirUpload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILES, QueueColumn.TOTAL_SIZE, QueueColumn.PROGRESS, QueueColumn.REASON, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "failed-upload-dir", false, true, false, false, null));
} else {
failedContent.addChild(createRequestTable(pageMaker, ctx, failedDirUpload, new QueueColumn[] { QueueColumn.FILES, QueueColumn.TOTAL_SIZE, QueueColumn.PROGRESS, QueueColumn.REASON, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "failed-upload-dir", false, true, false, false, null));
}
}
if(!failedBadMIMEType.isEmpty()) {
String[] types = failedBadMIMEType.keySet().toArray(new String[failedBadMIMEType.size()]);
Arrays.sort(types);
for(String type : types) {
LinkedList<DownloadRequestStatus> getters = failedBadMIMEType.get(type);
String atype = type.replace("-", "--").replace('/', '-');
contentNode.addChild("a", "id", "failedDownload-badtype-"+atype);
FilterMIMEType typeHandler = ContentFilter.getMIMEType(type);
HTMLNode failedContent = pageMaker.getInfobox("failed_requests", l10n("failedDBadMIME", new String[]{ "size", "type" }, new String[]{ String.valueOf(getters.size()), type }), contentNode, "download-failed-"+atype, false);
// FIXME add a class for easier styling.
KnownUnsafeContentTypeException e = new KnownUnsafeContentTypeException(typeHandler);
failedContent.addChild("p", l10n("badMIMETypeIntro", "type", type));
List<String> detail = e.details();
if(detail != null && !detail.isEmpty()) {
HTMLNode list = failedContent.addChild("ul");
for(String s : detail)
list.addChild("li", s);
}
failedContent.addChild("p", l10n("mimeProblemFetchAnyway"));
Collections.sort(getters, jobComparator);
if (advancedModeEnabled) {
failedContent.addChild(createRequestTable(pageMaker, ctx, getters, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "failed-download-file-badmime", false, true, true, false, type));
} else {
failedContent.addChild(createRequestTable(pageMaker, ctx, getters, new QueueColumn[] { QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "failed-download-file-badmime", false, true, true, false, type));
}
}
}
if(!failedUnknownMIMEType.isEmpty()) {
String[] types = failedUnknownMIMEType.keySet().toArray(new String[failedUnknownMIMEType.size()]);
Arrays.sort(types);
for(String type : types) {
LinkedList<DownloadRequestStatus> getters = failedUnknownMIMEType.get(type);
String atype = type.replace("-", "--").replace('/', '-');
contentNode.addChild("a", "id", "failedDownload-unknowntype-"+atype);
HTMLNode failedContent = pageMaker.getInfobox("failed_requests", l10n("failedDUnknownMIME", new String[]{ "size", "type" }, new String[]{ String.valueOf(getters.size()), type }), contentNode, "download-failed-"+atype, false);
// FIXME add a class for easier styling.
failedContent.addChild("p", NodeL10n.getBase().getString("UnknownContentTypeException.explanation", "type", type));
failedContent.addChild("p", l10n("mimeProblemFetchAnyway"));
Collections.sort(getters, jobComparator);
if (advancedModeEnabled) {
failedContent.addChild(createRequestTable(pageMaker, ctx, getters, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "failed-download-file-unknownmime", false, true, true, false, type));
} else {
failedContent.addChild(createRequestTable(pageMaker, ctx, getters, new QueueColumn[] { QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "failed-download-file-unknownmime", false, true, true, false, type));
}
}
}
if (!uncompletedDownload.isEmpty()) {
contentNode.addChild("a", "id", "uncompletedDownload");
HTMLNode uncompletedContent = pageMaker.getInfobox("requests_in_progress", l10n("wipD", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedDownload.size()) }), contentNode, "download-progressing", false);
if (advancedModeEnabled) {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDownload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.PRIORITY, QueueColumn.SIZE, QueueColumn.MIME_TYPE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.PERSISTENCE, QueueColumn.FILENAME, QueueColumn.KEY, QueueColumn.COMPAT_MODE }, priorityClasses, advancedModeEnabled, false, "uncompleted-download", false, false));
} else {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDownload, new QueueColumn[] { QueueColumn.PRIORITY, QueueColumn.SIZE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, false, "uncompleted-download", false, false));
}
}
if (!uncompletedUpload.isEmpty()) {
contentNode.addChild("a", "id", "uncompletedUpload");
HTMLNode uncompletedContent = pageMaker.getInfobox("requests_in_progress", l10n("wipU", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedUpload.size()) }), contentNode, "upload-progressing", false);
if (advancedModeEnabled) {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedUpload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.PRIORITY, QueueColumn.SIZE, QueueColumn.MIME_TYPE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.PERSISTENCE, QueueColumn.FILENAME, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "uncompleted-upload-file", false, false));
} else {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedUpload, new QueueColumn[] { QueueColumn.PRIORITY, QueueColumn.FILENAME, QueueColumn.SIZE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "uncompleted-upload-file", false, false));
}
}
if (!uncompletedDirUpload.isEmpty()) {
contentNode.addChild("a", "id", "uncompletedDirUpload");
HTMLNode uncompletedContent = pageMaker.getInfobox("requests_in_progress", l10n("wipDU", new String[]{ "size" }, new String[]{ String.valueOf(uncompletedDirUpload.size()) }), contentNode, "download-progressing upload-progressing", false);
if (advancedModeEnabled) {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDirUpload, new QueueColumn[] { QueueColumn.IDENTIFIER, QueueColumn.FILES, QueueColumn.PRIORITY, QueueColumn.TOTAL_SIZE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.PERSISTENCE, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "uncompleted-upload-dir", false, false));
} else {
uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDirUpload, new QueueColumn[] { QueueColumn.PRIORITY, QueueColumn.FILES, QueueColumn.TOTAL_SIZE, QueueColumn.PROGRESS, QueueColumn.LAST_ACTIVITY, QueueColumn.KEY }, priorityClasses, advancedModeEnabled, true, "uncompleted-upload-dir", false, false));
}
}
if(!uploads) {
contentNode.addChild(createBulkDownloadForm(ctx, pageMaker));