コード例 #1
0
  private String getRepetitionText(String type, FormIndex index, boolean newrep) {
    if (element instanceof GroupDef
        && ((GroupDef) element).getRepeat()
        && index.getElementMultiplicity() >= 0) {
      GroupDef g = (GroupDef) element;

      String title = getLongText();
      int ix = index.getElementMultiplicity() + 1;
      int count = getNumRepetitions();

      String caption = null;
      if ("header".equals(type)) {
        caption = g.entryHeader;
      } else if ("choose".equals(type)) {
        caption = g.chooseCaption;
        if (caption == null) {
          caption = g.entryHeader;
        }
      }
      if (caption == null) {
        return title + " " + ix + "/" + count;
      }

      HashMap<String, Object> vars = new HashMap<String, Object>();
      vars.put("name", title);
      vars.put("i", Integer.valueOf(ix));
      vars.put("n", Integer.valueOf(count));
      vars.put("new", new Boolean(newrep));
      return form.fillTemplateString(caption, index.getReference(), vars);
    } else {
      return null;
    }
  }
コード例 #2
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);
  }
コード例 #3
0
 protected String substituteStringArgs(String templateStr) {
   if (templateStr == null) {
     return null;
   }
   return form.fillTemplateString(templateStr, index.getReference());
 }