コード例 #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
ファイル: FormDef.java プロジェクト: ClaudiaAlawi/MyRepo
  public boolean canCreateRepeat(TreeReference repeatRef, FormIndex repeatIndex) {
    GroupDef repeat = (GroupDef) this.getChild(repeatIndex);

    // Check to see if this repeat can have children added by the user
    if (repeat.noAddRemove) {
      // Check to see if there's a count to use to determine how many children this repeat
      // should have
      if (repeat.getCountReference() != null) {
        int currentMultiplicity = repeatIndex.getElementMultiplicity();

        // get the total multiplicity possible
        long fullcount =
            ((Integer) this.getInstance().getDataValue(repeat.getCountReference()).getValue())
                .intValue();

        if (fullcount <= currentMultiplicity) {
          return false;
        }
      } else {
        // Otherwise the user can never add repeat instances
        return false;
      }
    }

    // TODO: If we think the node is still relevant, we also need to figure out a way to test that
    // assumption against
    // the repeat's constraints.

    return true;
  }
コード例 #3
0
 public int getMultiplicity() {
   return index.getElementMultiplicity();
 }