Examples of HTMLNode


Examples of freenet.support.HTMLNode

    return l10n("shortText");
  }

  @Override
  public HTMLNode getHTMLText() {
    return new HTMLNode("div", getText());
  }
View Full Code Here

Examples of freenet.support.HTMLNode

  /**
   * Write the alerts as HTML.
   */
  public HTMLNode createAlerts(boolean showOnlyErrors) {
    HTMLNode alertsNode = new HTMLNode("div");
    int totalNumber = 0;
    for (UserAlert alert: getAlerts()) {
      if(showOnlyErrors && alert.getPriorityClass() > UserAlert.ERROR)
        continue;
      if (!alert.isValid())
        continue;
      totalNumber++;
      alertsNode.addChild("a", "name", alert.anchor());
      if(showOnlyErrors) {
        // Paranoia. Don't break the web interface no matter what.
        try {
          alertsNode.addChild(renderAlert(alert));
        } catch (Throwable t) {
          Logger.error(this, "FAILED TO RENDER ALERT: "+alert+" : "+t, t);
        }
      } else {
        // Alerts toadlet itself can error, that's OK.
        alertsNode.addChild(renderAlert(alert));
      }
    }
    if (totalNumber == 0) {
      return new HTMLNode("#", "");
    }
    return alertsNode;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

   * @param userAlert
   *            The user alert to render
   * @return The rendered HTML node
   */
  public HTMLNode renderAlert(UserAlert userAlert) {
    HTMLNode userAlertNode = null;
    short level = userAlert.getPriorityClass();
    userAlertNode = new HTMLNode("div", "class", "infobox infobox-"+getAlertLevelName(level));

    userAlertNode.addChild("div", "class", "infobox-header", userAlert.getTitle());
    HTMLNode alertContentNode = userAlertNode.addChild("div", "class", "infobox-content");
    alertContentNode.addChild(userAlert.getHTMLText());
    if (userAlert.userCanDismiss()) {
      HTMLNode dismissFormNode = alertContentNode.addChild("form", new String[] { "action", "method" }, new String[] { "/alerts/", "post" }).addChild("div");
      dismissFormNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "disable", String.valueOf(userAlert.hashCode()) });
      dismissFormNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
      dismissFormNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "dismiss-user-alert", userAlert.dismissButtonText() });
    }
    return userAlertNode;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

    if(numberOfMinor == 0 && numberOfWarning == 0 && oneLine)
      return null;

    if (totalNumber == 0)
      return new HTMLNode("#", "");

    boolean separatorNeeded = false;
    String separator = oneLine?", ":" | ";
    int messageTypes=0;
    StringBuilder alertSummaryString = new StringBuilder(1024);
    if (numberOfCriticalError != 0 && !oneLine) {
      alertSummaryString.append(l10n("criticalErrorCountLabel")).append(' ').append(numberOfCriticalError);
      separatorNeeded = true;
      messageTypes++;
    }
    if (numberOfError != 0 && !oneLine) {
      if (separatorNeeded)
        alertSummaryString.append(separator);
      alertSummaryString.append(l10n("errorCountLabel")).append(' ').append(numberOfError);
      separatorNeeded = true;
      messageTypes++;
    }
    if (numberOfWarning != 0) {
      if (separatorNeeded)
        alertSummaryString.append(separator);
      if(oneLine) {
      alertSummaryString.append(numberOfWarning).append(' ').append(l10n("warningCountLabel").replace(":", ""));
      } else {
        alertSummaryString.append(l10n("warningCountLabel")).append(' ').append(numberOfWarning);
      }
      separatorNeeded = true;
      messageTypes++;
    }
    if (numberOfMinor != 0) {
      if (separatorNeeded)
        alertSummaryString.append(separator);
      if(oneLine) {
        alertSummaryString.append(numberOfMinor).append(' ').append(l10n("minorCountLabel").replace(":", ""));
      } else {
        alertSummaryString.append(l10n("minorCountLabel")).append(' ').append(numberOfMinor);
      }
      separatorNeeded = true;
      messageTypes++;
    }
    if (messageTypes != 1 && !oneLine) {
      if (separatorNeeded)
        alertSummaryString.append(separator);
      alertSummaryString.append(l10n("totalLabel")).append(' ').append(totalNumber);
    }
    HTMLNode summaryBox = null;

    String classes = oneLine?"alerts-line contains-":"infobox infobox-";

    if (highestLevel <= UserAlert.CRITICAL_ERROR && !oneLine)
      summaryBox = new HTMLNode("div", "class", classes + "error");
    else if (highestLevel <= UserAlert.ERROR && !oneLine)
      summaryBox = new HTMLNode("div", "class", classes + "alert");
    else if (highestLevel <= UserAlert.WARNING)
      summaryBox = new HTMLNode("div", "class", classes + "warning");
    else if (highestLevel <= UserAlert.MINOR)
      summaryBox = new HTMLNode("div", "class", classes + "information");
    summaryBox.addChild("div", "class", "infobox-header", l10n("alertsTitle"));
    HTMLNode summaryContent = summaryBox.addChild("div", "class", "infobox-content");
    if(!oneLine) {
      summaryContent.addChild("#", alertSummaryString.toString() + separator + " ");
      NodeL10n.getBase().addL10nSubstitution(summaryContent, "UserAlertManager.alertsOnAlertsPage",
        new String[] { "link" }, new HTMLNode[] { ALERTS_LINK });
    } else {
      summaryContent.addChild("a", "href", "/alerts/", NodeL10n.getBase().getString("StatusBar.alerts") + " " + alertSummaryString.toString());
    }
    summaryBox.addAttribute("id", "messages-summary-box");
    return summaryBox;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

  @Override
  public HTMLNode getHTMLText() {
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("name");

    HTMLNode alertNode = new HTMLNode("div");
    HTMLNode textNode = alertNode.addChild("div");
    textNode.addChild("#", l10n("noNodeNick"));
    HTMLNode formNode = alertNode.addChild("form", new String[] { "action", "method" }, new String[] { "/config/"+sc.getPrefix(), "post" });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "subconfig", sc.getPrefix() });
    HTMLNode listNode = formNode.addChild("ul", "class", "config");
    HTMLNode itemNode = listNode.addChild("li");
    itemNode.addChild("span", new String[]{ "class", "title", "style" },
        new String[]{ "configshortdesc", NodeL10n.getBase().getString("ConfigToadlet.defaultIs", new String[] { "default" }, new String[] { o.getDefault() }),
        "cursor: help;" }).addChild(o.getShortDescNode());
    itemNode.addChild("input", new String[] { "type", "class", "alt", "name", "value" }, new String[] { "text", "config", o.getShortDesc(), "node.name", o.getValueDisplayString() });
    itemNode.addChild("span", "class", "configlongdesc").addChild(o.getLongDescNode());
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "submit", NodeL10n.getBase().getString("UserAlert.apply") });
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "reset", NodeL10n.getBase().getString("UserAlert.reset") });

    return alertNode;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

  public abstract String getEventText();
  public abstract HTMLNode getEventHTMLText();

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode text = new HTMLNode("div");
    synchronized(events) {
      for(StoringUserEvent<T> event : events.values()) {
        text.addChild(event.getEventHTMLText());
      }
    }
    return text;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

    return getTitle();
  }

  @Override
  public HTMLNode getHTMLText() {
    return new HTMLNode("div", getText());
  }
View Full Code Here

Examples of freenet.support.HTMLNode

    return getTitle();
  }

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode alertNode = new HTMLNode("div");
    alertNode.addChild("a", "href", "/" + uri).addChild("#", uri.toShortString());
    if (description != null && description.length() != 0) {
      String[] lines = description.split("\n");
      alertNode.addChild("br");
      alertNode.addChild("br");
      alertNode.addChild("#", l10n("fileDescription"));
      alertNode.addChild("br");
      for (int i = 0; i < lines.length; i++) {
        alertNode.addChild("#", lines[i]);
        if (i != lines.length - 1)
          alertNode.addChild("br");
      }
    }
    return alertNode;
  }
View Full Code Here

Examples of freenet.support.HTMLNode

  public SimpleUserAlert(boolean canDismiss, String title, String text, String shortText, short type) {
    this(canDismiss, title, text, shortText, type, null);
  }
 
  public SimpleUserAlert(boolean canDismiss, String title, String text, String shortText, short type, Object userIdentifier) {
    super(canDismiss, title, text, shortText, new HTMLNode("div", text), type, true, NodeL10n.getBase().getString("UserAlert.hide"), true, userIdentifier);
  }
View Full Code Here

Examples of freenet.support.HTMLNode

          }
        }
       
        @Override
        public HTMLNode getHTMLText() {
          HTMLNode div = new HTMLNode("div");
          // Text saying the plugin has been updated...
          synchronized(this) {
         
            if(deployOnNoRevocation || deployOnNextNoRevocation) {
              div.addChild("#", l10n("willDeployAfterRevocationCheck", "name", pluginName));
            } else {
              div.addChild("#", l10n("pluginUpdatedText", new String[] { "name", "newVersion" }, new String[] { pluginName, Long.toString(fetchedVersion) }));
             
              // Form to deploy the updated version.
              // This is not the same as reloading because we haven't written it yet.
             
              HTMLNode formNode = div.addChild("form", new String[] { "action", "method" }, new String[] { PproxyToadlet.PATH, "post" });
              formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
              formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "update", pluginName });
              formNode.addChild("input", new String[] { "type", "value" }, new String[] { "submit", l10n("updatePlugin") });
            }
          }
          return div;
        }
      };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.