Пример #1
0
  protected PropertyDefinition getPropertyDefinition(
      FieldSelection fieldSelection, Property property) {
    List<String> propertyPath = getPropertyPath(property.getContextElement());
    if (propertyPath.isEmpty()) {
      return null;
    }

    ContextElement currentElement = null;
    for (ContextElement contextRoot : fieldSelection.getContextElements()) {
      if (contextRoot.getName().equals(propertyPath.get(0))) {
        currentElement = contextRoot;
      }
    }

    propertyPath.remove(0);
    if (currentElement == null) {
      return null;
    }

    while (propertyPath.size() > 0) {
      String name = propertyPath.get(0);
      propertyPath.remove(0);
      currentElement = findByName(currentElement, name);
    }

    for (PropertyDefinition definition : currentElement.getProperties()) {
      if (definition.getName().equals(property.getName())) {
        return definition;
      }
    }

    return null;
  }
Пример #2
0
  private boolean isSelected(FieldSelection fieldSelection, Property property, boolean multiple) {
    PropertyDefinition definition = getPropertyDefinition(fieldSelection, property);
    if (definition == null) {
      return false;
    }
    TernaryButton.State value =
        multiple ? definition.getValueMultiple() : definition.getValueSingle();
    switch (value) {
      case TRUE:
        return true;
      case FALSE:
        return false;
      case DEFAULT:
        return multiple
            ? generator.isSelectedMultiple(property)
            : generator.isSelectedSingle(property);
    }

    return false;
  }