Package freenet.support

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


    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

  @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

  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

    return getTitle();
  }

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

    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

  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

          }
        }
       
        @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

        getHTML(disabledNotBlown, msg),
        UserAlert.CRITICAL_ERROR, true, null, false, null);
  }
 
  private static HTMLNode getHTML(boolean disabledNotBlown, String msg) {
    HTMLNode div = new HTMLNode("div");
    if(disabledNotBlown) {
      div.addChild("p", NodeL10n.getBase().getString("RevocationKeyFoundUserAlert.textDisabled"));
      div.addChild("p", NodeL10n.getBase().getString("RevocationKeyFoundUserAlert.textDisabledDetail", "message", msg));
    } else {
      div.addChild("p", NodeL10n.getBase().getString("RevocationKeyFoundUserAlert.text"));
      div.addChild("p", NodeL10n.getBase().getString("RevocationKeyFoundUserAlert.textDetail", "message", msg));
    }
    return div;
  }
View Full Code Here

    return true;
  }

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode textNode = new HTMLNode("div");
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("tempIPAddressHint");
   
    NodeL10n.getBase().addL10nSubstitution(textNode, "IPUndetectedUserAlert."+(node.ipDetector.isDetecting() ? "detectingWithConfigLink" : "unknownAddressWithConfigLink"),
        new String[] { "link" },
        new HTMLNode[] { HTMLNode.link("/config/"+sc.getPrefix()) });
   
    int peers = node.peers.getDarknetPeers().length;
    if(peers > 0)
      textNode.addChild("p", l10n("noIPMaybeFromPeers", "number", Integer.toString(peers)));
   
    if(node.ipDetector.noDetectPlugins()) {
      HTMLNode p = textNode.addChild("p");
      NodeL10n.getBase().addL10nSubstitution(p, "IPUndetectedUserAlert.loadDetectPlugins", new String[] { "plugins", "config", },
          new HTMLNode[] { HTMLNode.link("/plugins/"), HTMLNode.link("/config/node") });
    } else if(!node.ipDetector.hasJSTUN() && !node.ipDetector.isDetecting()) {
      HTMLNode p = textNode.addChild("p");
      NodeL10n.getBase().addL10nSubstitution(p, "IPUndetectedUserAlert.loadJSTUN", new String[] { "plugins" },
          new HTMLNode[] { HTMLNode.link("/plugins/") });
    }
   
    addPortForwardSuggestion(textNode);
   
    HTMLNode formNode = textNode.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", "class", "configshortdesc", o.getLocalisedShortDesc()).addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", sc.getPrefix() + ".tempIPAddressHint", o.getValueDisplayString() });
    itemNode.addChild("span", "class", "configlongdesc", o.getLocalisedLongDesc());
    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 textNode;
  }
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.