コード例 #1
0
  private Bind getBindByNodesetRecursive(Bind bind, String searchedNodeset, String accNodeset) {
    String ns = bind.getAttributes().get("nodeset");
    if (ns != null) accNodeset += "/" + ns;

    if (accNodeset.equals(searchedNodeset) || accNodeset.substring(1).equals(searchedNodeset)) {
      // found matching bind (first / is optional)
      return bind;
    } else if (bind.getBinds().size() > 0) {
      // not found, continue search in child binds
      for (Bind nestedBind : bind.getBinds()) {
        Bind result = getBindByNodesetRecursive(nestedBind, searchedNodeset, accNodeset);
        if (result != null) return result;
      }
      return null;
    } else {
      // not found, no children
      return null;
    }
  }
コード例 #2
0
  private void appendElementERDF(Writer writer, XFormsElement element) throws IOException {
    writer.append("<div id=\"" + element.getResourceId() + "\">");
    appendOryxField(writer, "type", STENCILSET_URI + "#" + element.getStencilId());

    for (String field : element.getAttributes().keySet()) {
      if (!field.equals("bind"))
        appendXFormsField(writer, field, element.getAttributes().get(field));
    }

    // handle PCData containers
    if (element instanceof PCDataContainer) {
      String content = ((PCDataContainer) element).getContent();
      if (element instanceof Label) {
        appendXFormsField(writer, "text", content);
      } else {
        appendXFormsField(writer, "message", content);
      }
    }

    // handle model item properties
    String ref = element.getAttributes().get("ref");
    if (ref != null) {

      if (!ref.startsWith("/") && (element instanceof XFormsUIElement)) {
        ref = getNodesetContext((XFormsUIElement) element) + ref;
      }

      Bind bind = getBindByNodeset(ref);

      if (bind != null) {
        for (String field : bind.getAttributes().keySet()) {
          if (!field.equals("id") && !field.equals("nodeset"))
            appendXFormsField(writer, field, bind.getAttributes().get(field));
        }
      }
    }

    // handle submission properties
    String submissionId = element.getAttributes().get("submission");
    if (submissionId != null) {
      Submission submission = getSubmissionById(submissionId);
      if (submission != null) {
        for (String field : submission.getAttributes().keySet()) {
          if (!field.equals("id"))
            appendXFormsField(writer, field, submission.getAttributes().get(field));
        }
      }
    }

    // handle item element
    if (element instanceof Item) {
      Item item = (Item) element;
      Value value = item.getValue();
      if (value != null) {
        for (String field : value.getAttributes().keySet()) {
          if (!field.equals("id"))
            appendXFormsField(writer, "value_" + field, value.getAttributes().get(field));
        }
      }
      appendOryxField(writer, "bounds", "0," + item.getYPosition() + ",0," + item.getYPosition());
    }

    // handle itemset element
    if (element instanceof Itemset) {
      Itemset itemset = (Itemset) element;
      Value value = itemset.getValue();
      if (value != null) {
        for (String field : value.getAttributes().keySet()) {
          appendXFormsField(writer, "value_" + field, value.getAttributes().get(field));
        }
      }
      Copy copy = ((Itemset) element).getCopy();
      if (copy != null) {
        for (String field : copy.getAttributes().keySet()) {
          appendXFormsField(writer, "copy_" + field, copy.getAttributes().get(field));
        }
      }
      appendOryxField(
          writer, "bounds", "0," + itemset.getYPosition() + ",0," + itemset.getYPosition());
    }

    if (element instanceof XFormsUIElement) {
      int x = ((XFormsUIElement) element).getXPosition();
      int y = (((XFormsUIElement) element).getYPosition() + 10) * DISTANCE_FACTOR;
      appendOryxField(writer, "bounds", x + "," + y + "," + x + "," + y);
    }

    writer.append(
        "<a rel=\"raziel-parent\" href=\"#" + context.getParent(element).getResourceId() + "\"/>");
    writer.append("</div>");
  }