Package freenet.support

Examples of freenet.support.HTMLNode


    }
    return identifierCell;
  }

  private HTMLNode createPersistenceCell(boolean persistent, boolean persistentForever) {
    HTMLNode persistenceCell = new HTMLNode("td", "class", "request-persistence");
    if (persistentForever) {
      persistenceCell.addChild("span", "class", "persistence_forever", l10n("persistenceForever"));
    } else if (persistent) {
      persistenceCell.addChild("span", "class", "persistence_reboot", l10n("persistenceReboot"));
    } else {
      persistenceCell.addChild("span", "class", "persistence_none", l10n("persistenceNone"));
    }
    return persistenceCell;
  }
View Full Code Here


    }
    return persistenceCell;
  }

  private HTMLNode createTypeCell(String type) {
    HTMLNode typeCell = new HTMLNode("td", "class", "request-type");
    if (type != null) {
      typeCell.addChild("span", "class", "mimetype_is", type);
    } else {
      typeCell.addChild("span", "class", "mimetype_unknown", l10n("unknown"));
    }
    return typeCell;
  }
View Full Code Here

    }
    return typeCell;
  }

  private HTMLNode createSizeCell(long dataSize, boolean confirmed, boolean advancedModeEnabled) {
    HTMLNode sizeCell = new HTMLNode("td", "class", "request-size");
    if (dataSize > 0 && (confirmed || advancedModeEnabled)) {
      sizeCell.addChild("span", "class", "filesize_is", (confirmed ? "" : ">= ") + SizeUtil.formatSize(dataSize) + (confirmed ? "" : " ??"));
    } else {
      sizeCell.addChild("span", "class", "filesize_unknown", l10n("unknown"));
    }
    return sizeCell;
  }
View Full Code Here

    }
    return sizeCell;
  }

  private HTMLNode createKeyCell(FreenetURI uri, boolean addSlash) {
    HTMLNode keyCell = new HTMLNode("td", "class", "request-key");
    if (uri != null) {
      keyCell.addChild("span", "class", "key_is").addChild("a", "href", '/' + uri.toString() + (addSlash ? "/" : ""), uri.toShortString() + (addSlash ? "/" : ""));
    } else {
      keyCell.addChild("span", "class", "key_unknown", l10n("unknown"));
    }
    return keyCell;
  }
View Full Code Here

  }

  private HTMLNode createBulkDownloadForm(ToadletContext ctx, PageMaker pageMaker) {
    InfoboxNode infobox = pageMaker.getInfobox(
            l10n("downloadFiles"), "grouped-downloads", true);
    HTMLNode downloadBox = infobox.outer;
    HTMLNode downloadBoxContent = infobox.content;
    HTMLNode downloadForm = ctx.addFormChild(downloadBoxContent, path(), "queueDownloadForm");
    downloadForm.addChild("#", l10n("downloadFilesInstructions"));
    downloadForm.addChild("br");
    downloadForm.addChild("textarea",
            new String[] { "id", "name", "cols", "rows" },
            new String[] { "bulkDownloads", "bulkDownloads", "120", "8" });
    downloadForm.addChild("br");
    PHYSICAL_THREAT_LEVEL threatLevel = core.node.securityLevels.getPhysicalThreatLevel();
    //Force downloading to encrypted space if high/maximum threat level or if the user has disabled
    //downloading to disk.
    if(threatLevel == PHYSICAL_THREAT_LEVEL.HIGH || threatLevel == PHYSICAL_THREAT_LEVEL.MAXIMUM ||
            core.isDownloadDisabled()) {
      downloadForm.addChild("input",
              new String[] { "type", "name", "value" },
              new String[] { "hidden", "target", "direct" });
    } else if(threatLevel == PHYSICAL_THREAT_LEVEL.LOW) {
      downloadForm.addChild("input",
              new String[] { "type", "name", "value" },
              new String[] { "hidden", "target", "disk" });
      selectLocation(downloadForm);
    } else {
      downloadForm.addChild("br");
      downloadForm.addChild("input",
              new String[] { "type", "value", "name" },
              new String[] { "radio", "disk", "target" },
          //Nicer spacing for radio button
              ' '+l10n("bulkDownloadSelectOptionDisk")+' ');
      selectLocation(downloadForm);
      downloadForm.addChild("br");
      downloadForm.addChild("input",
              new String[] { "type", "value", "name", "checked" },
              new String[] { "radio", "direct", "target", "checked" },
              ' '+l10n("bulkDownloadSelectOptionDirect")+' ');
    }
    HTMLNode filterControl = downloadForm.addChild("div", l10n("filterData"));
    filterControl.addChild("input",
            new String[] { "type", "name", "value", "checked" },
            new String[] { "checkbox", "filterData", "filterData", "checked"});
    filterControl.addChild("#", l10n("filterDataMessage"));
    downloadForm.addChild("br");
    downloadForm.addChild("input",
            new String[] { "type", "name", "value" },
            new String[] { "submit", "insert", l10n("download") });
    return downloadBox;
View Full Code Here

   * @param lastActivity
   *            The last activity of the request
   * @return The created table cell HTML node
   */
  private HTMLNode createLastActivityCell(long now, long lastActivity) {
    HTMLNode lastActivityCell = new HTMLNode("td", "class", "request-last-activity");
    if (lastActivity == 0) {
      lastActivityCell.addChild("i", l10n("lastActivity.unknown"));
    } else {
      lastActivityCell.addChild("#", l10n("lastActivity.ago", "time", TimeUtil.formatTime(now - lastActivity)));
    }
    return lastActivityCell;
  }
View Full Code Here

  private HTMLNode createRequestTable(PageMaker pageMaker, ToadletContext ctx, List<? extends RequestStatus> requests, QueueColumn[] columns, String[] priorityClasses, boolean advancedModeEnabled, boolean isUpload, String id, boolean isDownloadToTemp, boolean isFailed, boolean isDisableFilterChecked, boolean isCompleted, String mimeType) {
    boolean hasFriends = core.node.getDarknetConnections().length > 0;
    boolean isFinishedDiskDownloads = isCompleted && !isUpload && !isDownloadToTemp && !isFailed;
    long now = System.currentTimeMillis();
   
    HTMLNode formDiv = new HTMLNode("div", "class", "request-table-form");
    HTMLNode form = ctx.addFormChild(formDiv, path(), "request-table-form-"+id+(advancedModeEnabled?"-advanced":"-simple"));
   
    createRequestTableButtons(form, pageMaker, ctx, isDownloadToTemp, isFailed, isDisableFilterChecked, isUpload, mimeType, hasFriends, isFinishedDiskDownloads, advancedModeEnabled, isCompleted, priorityClasses, true);

    HTMLNode table = form.addChild("table", "class", "requests");
    HTMLNode headerRow = table.addChild("tr", "class", "table-header");

    // Checkbox header
    headerRow.addChild("th"); // No description

    //Add a header for each column.
    for (QueueColumn column : columns) {
      switch (column) {
        case IDENTIFIER:
          headerRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=id" : "?sortBy=id&reversed")).addChild("#", l10n("identifier"));
          break;
        case SIZE:
          headerRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=size" : "?sortBy=size&reversed")).addChild("#", l10n("size"));
          break;
        case MIME_TYPE:
          headerRow.addChild("th", l10n("mimeType"));
          break;
        case PERSISTENCE:
          headerRow.addChild("th", l10n("persistence"));
          break;
        case KEY:
          headerRow.addChild("th", l10n("key"));
          break;
        case FILENAME:
          headerRow.addChild("th", l10n("fileName"));
          break;
        case PRIORITY:
          headerRow.addChild("th", l10n("priority"));
          break;
        case FILES:
          headerRow.addChild("th", l10n("files"));
          break;
        case TOTAL_SIZE:
          headerRow.addChild("th", l10n("totalSize"));
          break;
        case PROGRESS:
          headerRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=progress" : "?sortBy=progress&reversed")).addChild("#", l10n("progress"));
          break;
        case REASON:
          headerRow.addChild("th", l10n("reason"));
          break;
        case LAST_ACTIVITY:
          headerRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=lastActivity" : "?sortBy=lastActivity&reversed"),  l10n("lastActivity"));
          break;
        case COMPAT_MODE:
          headerRow.addChild("th", l10n("compatibilityMode"));
          break;
      }
    }
    //Add a row with a checkbox for each request.
    int x = 0;
    for (RequestStatus clientRequest : requests) {
      HTMLNode requestRow = table.addChild("tr", "class", "priority" + clientRequest.getPriority());
      requestRow.addChild(createCheckboxCell(clientRequest, x++));

      for (QueueColumn column : columns) {
        switch (column) {
          case IDENTIFIER:
            requestRow.addChild(createIdentifierCell(clientRequest.getURI(), clientRequest.getIdentifier(), clientRequest instanceof UploadDirRequestStatus));
            break;
          case SIZE:
            boolean isFinal = true;
            if(clientRequest instanceof DownloadRequestStatus)
              isFinal = ((DownloadRequestStatus)clientRequest).isTotalFinalized();
            requestRow.addChild(createSizeCell(clientRequest.getDataSize(), isFinal, advancedModeEnabled));
            break;
          case MIME_TYPE:
            if (clientRequest instanceof DownloadRequestStatus) {
              requestRow.addChild(createTypeCell(((DownloadRequestStatus) clientRequest).getMIMEType()));
            } else if (clientRequest instanceof UploadFileRequestStatus) {
              requestRow.addChild(createTypeCell(((UploadFileRequestStatus) clientRequest).getMIMEType()));
            }
            break;
          case PERSISTENCE:
            requestRow.addChild(createPersistenceCell(clientRequest.isPersistent(), clientRequest.isPersistentForever()));
            break;
          case KEY:
            if (clientRequest instanceof DownloadRequestStatus) {
              requestRow.addChild(createKeyCell(((DownloadRequestStatus) clientRequest).getURI(), false));
            } else if (clientRequest instanceof UploadFileRequestStatus) {
              requestRow.addChild(createKeyCell(((UploadFileRequestStatus) clientRequest).getFinalURI(), false));
            }else {
              requestRow.addChild(createKeyCell(((UploadDirRequestStatus) clientRequest).getFinalURI(), true));
            }
            break;
          case FILENAME:
            if (clientRequest instanceof DownloadRequestStatus) {
              requestRow.addChild(createFilenameCell(((DownloadRequestStatus) clientRequest).getDestFilename()));
            } else if (clientRequest instanceof UploadFileRequestStatus) {
              requestRow.addChild(createFilenameCell(((UploadFileRequestStatus) clientRequest).getOrigFilename()));
            }
            break;
          case PRIORITY:
            requestRow.addChild(createPriorityCell(clientRequest.getPriority(), priorityClasses));
            break;
          case FILES:
            requestRow.addChild(createNumberCell(((UploadDirRequestStatus) clientRequest).getNumberOfFiles()));
            break;
          case TOTAL_SIZE:
            requestRow.addChild(createSizeCell(((UploadDirRequestStatus) clientRequest).getTotalDataSize(), true, advancedModeEnabled));
            break;
          case PROGRESS:
            if(clientRequest instanceof UploadFileRequestStatus)
              requestRow.addChild(createProgressCell(ctx.isAdvancedModeEnabled(),
                  clientRequest.isStarted(), ((UploadFileRequestStatus)clientRequest).isCompressing(),
                  clientRequest.getFetchedBlocks(), clientRequest.getFailedBlocks(),
                  clientRequest.getFatalyFailedBlocks(), clientRequest.getMinBlocks(),
                  clientRequest.getTotalBlocks(),
                  clientRequest.isTotalFinalized() || clientRequest instanceof UploadFileRequestStatus,
                  isUpload));
            else
              requestRow.addChild(createProgressCell(ctx.isAdvancedModeEnabled(),
                  clientRequest.isStarted(), COMPRESS_STATE.WORKING,
                  clientRequest.getFetchedBlocks(), clientRequest.getFailedBlocks(),
                  clientRequest.getFatalyFailedBlocks(), clientRequest.getMinBlocks(),
                  clientRequest.getTotalBlocks(),
                  clientRequest.isTotalFinalized() || clientRequest instanceof UploadFileRequestStatus,
                  isUpload));
            break;
          case REASON:
            requestRow.addChild(createReasonCell(clientRequest.getFailureReason(false)));
            break;
          case LAST_ACTIVITY:
            requestRow.addChild(createLastActivityCell(now, clientRequest.getLastActivity()));
            break;
          case COMPAT_MODE:
            if(clientRequest instanceof DownloadRequestStatus) {
              requestRow.addChild(createCompatModeCell((DownloadRequestStatus)clientRequest));
            } else {
              requestRow.addChild("td");
            }
            break;
        }
      }
    }
View Full Code Here

    if(announcer != null)
      announcer.maybeSendAnnouncementOffThread();
  }

  public void drawOpennetStatsBox(HTMLNode box) {
    HTMLNode table = box.addChild("table", "border", "0");
    HTMLNode row = table.addChild("tr");

    row.addChild("th");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("th", type.name());
    }

    row = table.addChild("tr");
    row.addChild("td", "Connection attempts");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("td", Long.toString(connectionAttempts.get(type)));
    }

    row = table.addChild("tr");
    row.addChild("td", "Connections accepted");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("td", Long.toString(connectionAttemptsAdded.get(type)));
    }

    row = table.addChild("tr");
    row.addChild("td", "Accepted (free slots)");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("td", Long.toString(connectionAttemptsAddedPlentySpace.get(type)));
    }

    row = table.addChild("tr");
    row.addChild("td", "Rejected (per-type grace periods)");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("td", Long.toString(connectionAttemptsRejectedByPerTypeEnforcement.get(type)));
    }

    row = table.addChild("tr");
    row.addChild("td", "Rejected (no droppable peers)");
    for(ConnectionType type : ConnectionType.values()) {
      row.addChild("td", Long.toString(connectionAttemptsRejectedNoPeersDroppable.get(type)));
    }

  }
View Full Code Here

  public void updateState(boolean initial) {
    if (logMINOR) {
      Logger.minor(this, "Updating ImageElement for url:" + key + (origKey == key ? (" originally " + origKey) : ""));
    }
    children.clear();
    HTMLNode whenJsEnabled = new HTMLNode("span", "class", "jsonly ImageElement");
    addChild(whenJsEnabled);
    // When js disabled
    addChild("noscript").addChild(makeHtmlNodeForParsedTag(originalImg));
    if (initial) {
      if (wasError) {
        whenJsEnabled.addChild(makeHtmlNodeForParsedTag(originalImg));
      } else {
        Map<String, String> attr = originalImg.getAttributesAsMap();
        String sizePart = "";
        if (attr.containsKey("width") && attr.containsKey("height")) {
          sizePart = "&width=" + attr.get("width") + "&height=" + attr.get("height");
        }
        attr.put("src", "/imagecreator/?text=+"+FProxyToadlet.l10n("imageinitializing")+"+" + sizePart);
        whenJsEnabled.addChild(makeHtmlNodeForParsedTag(new ParsedTag(originalImg, attr)));
        whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "fetchedBlocks", String.valueOf(0) });
        whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "requiredBlocks", String.valueOf(1) });

      }
    } else {
      FProxyFetchResult fr = null;
      FProxyFetchWaiter waiter = null;
      try {
        try {
          waiter = tracker.makeFetcher(key, maxSize, null, REFILTER_POLICY.RE_FILTER);
          fr = waiter.getResultFast();
        } catch (FetchException fe) {
          whenJsEnabled.addChild("div", "error");
        }
        if (fr == null) {
          whenJsEnabled.addChild("div", "No fetcher found");
        } else {

          if (fr.isFinished() && fr.hasData()) {
            if (logMINOR) {
              Logger.minor(this, "ImageElement is completed");
            }
            whenJsEnabled.addChild(makeHtmlNodeForParsedTag(originalImg));
          } else if (fr.failed != null) {
            if (logMINOR) {
              Logger.minor(this, "ImageElement is errorous");
            }
            whenJsEnabled.addChild(makeHtmlNodeForParsedTag(originalImg));
          } else {
            if (logMINOR) {
              Logger.minor(this, "ImageElement is still in progress");
            }
            int total = fr.requiredBlocks;
            int fetchedPercent = (int) (fr.fetchedBlocks / (double) total * 100);
            Map<String, String> attr = originalImg.getAttributesAsMap();
            String sizePart = new String();
            if (attr.containsKey("width") && attr.containsKey("height")) {
              sizePart = "&width=" + attr.get("width") + "&height=" + attr.get("height");
            }
            attr.put("src", "/imagecreator/?text=" + fetchedPercent + "%25" + sizePart);
            whenJsEnabled.addChild(makeHtmlNodeForParsedTag(new ParsedTag(originalImg, attr)));
            whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "fetchedBlocks", String.valueOf(fr.fetchedBlocks) });
            whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "requiredBlocks", String.valueOf(fr.requiredBlocks) });
          }
        }
      } finally {
        if (waiter != null) {
          tracker.getFetchInProgress(key, maxSize, null).close(waiter);
View Full Code Here

    List<String> attributeValues = new ArrayList<String>();
    for (Entry<String, String> att : pt.getAttributesAsMap().entrySet()) {
      attributeNames.add(att.getKey());
      attributeValues.add(att.getValue());
    }
    return new HTMLNode(pt.element, attributeNames.toArray(new String[] {}), attributeValues.toArray(new String[] {}));
  }
View Full Code Here

TOP

Related Classes of freenet.support.HTMLNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.