Beispiel #1
0
 /**
  * Add a dropdown menu of lengths
  *
  * @param prompt the prompt explaining the menu
  * @param parent the parnet element to attach it to
  */
 private void addLengthSelector(String prompt, Element parent) {
   Element select = new Element(HTMLNames.SELECT);
   select.addAttribute(HTMLNames.NAME, Params.LENGTH);
   addOption(select, "100", length == 100);
   addOption(select, "150", length == 150);
   addOption(select, "200", length == 200);
   addOption(select, "250", length == 250);
   parent.addText(prompt);
   parent.addChild(select);
 }
Beispiel #2
0
 private void addCheckBox(
     Element form, boolean flag, String prompt, String paramName, String onclick) {
   Element check = new Element(HTMLNames.INPUT);
   check.addAttribute(HTMLNames.TYPE, HTMLNames.CHECKBOX);
   check.addAttribute(HTMLNames.NAME, paramName);
   if (flag) check.addAttribute(HTMLNames.CHECKED, null);
   if (onclick != null) check.addAttribute(HTMLNames.ONCLICK, onclick);
   Element span = new Element(HTMLNames.SPAN);
   span.addText(prompt);
   form.addChild(span);
   form.addChild(check);
 }
Beispiel #3
0
 /**
  * Add a dropdown menu of lengths
  *
  * @param prompt the prompt explaining the menu
  * @param parent the parent element to attach it to
  */
 private void addOffsetSelector(String prompt, Element parent) {
   Element select = new Element(HTMLNames.SELECT);
   select.addAttribute(HTMLNames.NAME, Params.OFFSET);
   addOption(select, "0", offset == 0);
   addOption(select, "100", offset == 100);
   addOption(select, "200", offset == 200);
   addOption(select, "300", offset == 300);
   addOption(select, "400", offset == 400);
   addOption(select, "500", offset == 500);
   addOption(select, "600", offset == 600);
   addOption(select, "700", offset == 700);
   parent.addText(prompt);
   parent.addChild(select);
 }
Beispiel #4
0
  /**
   * Add a dropdown menu containing all the nested versions and groups
   *
   * @param parent the parent element to attach it to
   * @throws Exception
   */
  void addVersionDropdown(Element parent) throws Exception {
    Element select = new Element(HTMLNames.SELECT);
    String versions = getVersions();
    String[] opts = versions.split(",");
    // remove trailing LF-
    HashSet<String> selected = new HashSet<String>();
    if (selectedVersions != null) {
      String[] shortNames = selectedVersions.split(",");
      for (int i = 0; i < shortNames.length; i++) selected.add(shortNames[i]);
    }
    opts[opts.length - 1] = opts[opts.length - 1].trim();
    for (int i = 0; i < opts.length; i++) {
      String[] cols = opts[i].split("/");
      if (cols.length > 0 && cols[0].length() == 0) cols = popArray(cols);
      if (cols.length > 1) {
        HTMLOptGroup group = getGroup(select, cols[0]);
        if (selected.contains(opts[i])) cols[cols.length - 1] += " ×";
        if (group == null) {
          group = new HTMLOptGroup(cols[0]);
          select.addChild(group);
        }
        group.add(opts[i], popArray(cols));

      } else if (cols.length == 1) {
        Element option = new Element(HTMLNames.OPTION);
        select.addChild(option);
        String content = cols[cols.length - 1];
        if (selected.contains(opts[i])) content += " \327";
        option.addText(content);
        option.addAttribute(HTMLNames.VALUE, opts[i]);
      }
    }
    parent.addChild(select);
    if (!someVersions) select.addAttribute(HTMLNames.DISABLED, null);
    select.addAttribute(HTMLNames.ONCHANGE, "checkmark(this)");
    select.addAttribute(HTMLNames.ID, "selector");
    Element hidden = new Element(HTMLNames.INPUT);
    hidden.addAttribute(HTMLNames.TYPE, HTMLNames.HIDDEN);
    hidden.addAttribute(HTMLNames.ID, "versions");
    hidden.addAttribute(HTMLNames.NAME, Params.SELECTED_VERSIONS);
    parent.addChild(hidden);
  }
Beispiel #5
0
 /**
  * Add the specified option to the selector
  *
  * @param select the selector element
  * @param value the new value
  */
 private void addOption(Element select, String value, boolean selectit) {
   Element option = new Element(HTMLNames.OPTION);
   option.addText(value);
   if (selectit) option.addAttribute(HTMLNames.SELECTED, HTMLNames.SELECTED);
   select.addChild(option);
 }