Example #1
0
  public AddNodeWindow(AbstractQuestionRelation p) {
    this.setParent(p);

    // create ui from template
    Executions.createComponents("/WEB-INF/zk/survey/design/AddNodeWindow.zul", this, null);
    Selectors.wireVariables(this, this, Selectors.newVariableResolvers(getClass(), Div.class));
    Selectors.wireComponents(this, this, false);
    Selectors.wireEventListeners(this, this);

    // type box and default selection
    ntds = nodeRO.getNodeTypeDescriptions();
    ListModelList<String> typeModel = new ListModelList<String>();
    for (Map<String, String> ntd : ntds) {
      String nodeTypeLabel = ntd.get("label");
      typeModel.add(nodeTypeLabel);
    }
    String defaultContactType = p.getQuestion().getDefaultNewContactType();
    if (defaultContactType != null) {
      Map<String, String> ntd = GeneralUtil.getNodeDescription(ntds, defaultContactType);
      if (ntd != null) {
        String nodeTypeLabel = ntd.get("label");
        typeModel.addToSelection(nodeTypeLabel);
      }
    }
    typeBox.setModel(typeModel);
    onNodeTypeChanged();

    this.setWidth("200px");
    this.setVflex("1");
    this.setClosable(true);
  }