protected Group createInquirySection(String groupId, String headerText) {
   Group group = ComponentFactory.getGroupWithDisclosureGridLayout();
   group.setId(groupId);
   group.setHeaderText(headerText);
   group.setItems(new ArrayList<Component>());
   return group;
 }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public void performInitialization(Object model) {
   List<Component> items = new ArrayList<Component>();
   List<Object> modelCollection =
       ObjectPropertyUtils.getPropertyValue(model, tabCollectionPropertyName);
   int index = 0;
   for (Object tabObj : modelCollection) {
     String idSuffix;
     if (idSuffixPropertyName != null) {
       idSuffix = ObjectPropertyUtils.getPropertyValueAsText(tabObj, idSuffixPropertyName);
     } else {
       idSuffix = Integer.toString(index);
     }
     Group newGroup = ComponentUtils.copy(groupPrototype, "_" + idSuffix);
     if (expressionProperties != null && !expressionProperties.isEmpty()) {
       Map<String, Object> tabContext = new HashMap<String, Object>();
       for (Map.Entry<String, String> entry : expressionProperties.entrySet()) {
         tabContext.put(
             entry.getKey(), ObjectPropertyUtils.getPropertyValueAsText(tabObj, entry.getValue()));
       }
       ContextUtils.pushAllToContextDeep(newGroup, tabContext);
     }
     if (setFieldBindingObjectPath && newGroup instanceof CollectionGroup) {
       ((CollectionGroup) newGroup)
           .getBindingInfo()
           .setBindingObjectPath(tabCollectionPropertyName + "[" + index + "]");
     } else if (setFieldBindingObjectPath) {
       newGroup.setFieldBindingObjectPath(tabCollectionPropertyName + "[" + index + "]");
     }
     items.add(newGroup);
     index++;
   }
   setItems(items);
   super.performInitialization(model);
 }
  @SuppressWarnings("unchecked")
  protected void addAttributeSectionsToInquiryView(
      InquiryView view, DataObjectEntry dataObjectEntry) {
    // Set up data structures to manage the creation of sections
    Map<String, Group> inquirySectionsById = new HashMap<String, Group>();
    Group currentGroup = createInquirySection("default", dataObjectEntry.getObjectLabel());
    inquirySectionsById.put(currentGroup.getId(), currentGroup);
    ((List<Group>) view.getItems()).add(currentGroup);

    // Loop over the attributes on the data object, adding them into the inquiry
    // If we have an @Section notation, switch to the section, creating if the ID is unknown
    List<Component> items =
        (List<Component>) currentGroup.getItems(); // needed to deal with generics issue
    for (AttributeDefinition attr : dataObjectEntry.getAttributes()) {
      boolean dontDisplay =
          hasHintOfType(attr.getDataObjectAttribute(), UifDisplayHintType.NO_INQUIRY);
      dontDisplay |= (attr.getControlField() instanceof HiddenControl);
      // Check for a section hint
      // Create or retrieve existing section as determined by the ID on the annotation
      UifDisplayHint sectionHint =
          getHintOfType(attr.getDataObjectAttribute(), UifDisplayHintType.SECTION);
      if (sectionHint != null) {
        if (StringUtils.isNotBlank(sectionHint.id())) {
          currentGroup = inquirySectionsById.get(sectionHint.id());
          if (currentGroup == null) {
            String sectionLabel = sectionHint.label();
            if (StringUtils.isBlank(sectionLabel)) {
              sectionLabel = deriveHumanFriendlyNameFromPropertyName(sectionHint.id());
            }

            currentGroup = createInquirySection(sectionHint.id(), sectionHint.label());
            inquirySectionsById.put(currentGroup.getId(), currentGroup);
            ((List<Group>) view.getItems()).add(currentGroup);
          }
        } else {
          LOG.warn("SECTION UifDisplayHint given without an ID - assuming 'default'");
          currentGroup = inquirySectionsById.get("default");
        }
        items = (List<Component>) currentGroup.getItems();
      }

      // This is checked after the section test, since the @Section annotation
      // would be on the FK field
      if (dontDisplay) {
        continue;
      }

      DataField dataField = ComponentFactory.getDataField();
      dataField.setPropertyName(attr.getName());
      dataField.setLabel(attr.getLabel());
      items.add(dataField);
    }
  }
예제 #4
0
  /** {@inheritDoc} */
  @Override
  public void performInitialization(Object model) {
    super.performInitialization(model);

    if (isReadOnly()) {
      if (upperGroup != null) {
        upperGroup.setReadOnly(true);
      }
      if (lowerGroup != null) {
        lowerGroup.setReadOnly(true);
      }
      if (rightGroup != null) {
        rightGroup.setReadOnly(true);
      }
    }
  }
예제 #5
0
  /**
   * List of <code>Component</code> instances contained in the lower header group
   *
   * <p>Convenience method for configuration to get the items List from the lower header group
   *
   * @return List<? extends Component> items
   */
  @ViewLifecycleRestriction
  @BeanTagAttribute(name = "items", type = BeanTagAttribute.AttributeType.LISTBEAN)
  public List<? extends Component> getItems() {
    if (lowerGroup != null) {
      return lowerGroup.getItems();
    }

    return null;
  }
  /**
   * Method to add and enter key add to the given Group. Will use given lineContext and
   * expressionEvaluator if action string starts with '@{'.
   *
   * @param group
   * @param lineContext
   * @param expressionEvaluator
   * @param enterKeyAction
   */
  protected void addEnterKeyDataAttributeToGroup(
      Group group,
      Map<String, Object> lineContext,
      ExpressionEvaluator expressionEvaluator,
      String enterKeyAction) {
    if (StringUtils.isNotBlank(enterKeyAction)) {
      String action = enterKeyAction;
      if (action.contains("@{")) {
        action = expressionEvaluator.evaluateExpressionTemplate(lineContext, enterKeyAction);
      }

      group.addDataAttribute(
          UifConstants.DataAttributes.ENTER_KEY,
          KRADUtils.convertToHTMLAttributeSafeString(action));
    }
  }
예제 #7
0
 /**
  * Setter for the lower group's items
  *
  * <p>Convenience method for configuration to set the items List for the lower header group
  *
  * @param items
  */
 public void setItems(List<? extends Component> items) {
   if (lowerGroup != null) {
     lowerGroup.setItems(items);
   }
 }