Ejemplo n.º 1
0
  // TODO: this is explicitly missing integration with the new multi-media support
  // TODO: localize the default captions
  public String getRepeatText(String typeKey) {
    GroupDef g = (GroupDef) element;
    if (!g.getRepeat()) {
      throw new RuntimeException("not a repeat");
    }

    String title = getLongText();
    int count = getNumRepetitions();

    String caption = null;
    if ("mainheader".equals(typeKey)) {
      caption = g.mainHeader;
      if (caption == null) {
        return title;
      }
    } else if ("add".equals(typeKey)) {
      caption = g.addCaption;
      if (caption == null) {
        return "Add another " + title;
      }
    } else if ("add-empty".equals(typeKey)) {
      caption = g.addEmptyCaption;
      if (caption == null) {
        caption = g.addCaption;
      }
      if (caption == null) {
        return "None - Add " + title;
      }
    } else if ("del".equals(typeKey)) {
      caption = g.delCaption;
      if (caption == null) {
        return "Delete " + title;
      }
    } else if ("done".equals(typeKey)) {
      caption = g.doneCaption;
      if (caption == null) {
        return "Done";
      }
    } else if ("done-empty".equals(typeKey)) {
      caption = g.doneEmptyCaption;
      if (caption == null) {
        caption = g.doneCaption;
      }
      if (caption == null) {
        return "Skip";
      }
    } else if ("delheader".equals(typeKey)) {
      caption = g.delHeader;
      if (caption == null) {
        return "Delete which " + title + "?";
      }
    }

    HashMap<String, Object> vars = new HashMap<String, Object>();
    vars.put("name", title);
    vars.put("n", Integer.valueOf(count));
    return form.fillTemplateString(caption, index.getReference(), vars);
  }
Ejemplo n.º 2
0
  public List<String> getRepetitionsText() {
    GroupDef g = (GroupDef) element;
    if (!g.getRepeat()) {
      throw new RuntimeException("not a repeat");
    }

    int numRepetitions = getNumRepetitions();
    List<String> reps = new ArrayList<String>(numRepetitions);
    for (int i = 0; i < numRepetitions; i++) {
      reps.add(getRepetitionText("choose", form.descendIntoRepeat(index, i), false));
    }
    return reps;
  }