示例#1
0
  private boolean isAddButtonVisible() {
    Component inputPanel = this.get(ID_VALUE_CONTAINER).get(ID_INPUT);
    ValueWrapper valueWrapper = valueWrapperModel.getObject();

    if (valueWrapper.isReadonly()) {
      return false;
    }

    ItemWrapper propertyWrapper = valueWrapper.getItem();
    Item property = propertyWrapper.getItem();

    ItemDefinition definition = property.getDefinition();
    int max = definition.getMaxOccurs();
    List<ValueWrapper> usableValues = getUsableValues(propertyWrapper);
    if (usableValues.indexOf(valueWrapper) != usableValues.size() - 1) {
      return false;
    }

    if (max == -1) {
      return true;
    }

    if (countNonDeletedValues(propertyWrapper) >= max) {
      return false;
    }

    if (propertyWrapper.getContainer() == null) {
      return true; // TODO
    }
    return isAccessible(definition, getContainerStatus(propertyWrapper));
  }
示例#2
0
  private boolean isRemoveButtonVisible() {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();

    if (valueWrapper.isReadonly()) {
      return false;
    }
    Component inputPanel = this.get(ID_VALUE_CONTAINER).get(ID_INPUT);
    if (inputPanel instanceof ValueChoosePanel
        || inputPanel instanceof AssociationValueChoicePanel) {
      return true;
    }

    ItemWrapper propertyWrapper = valueWrapper.getItem();
    ItemDefinition definition = propertyWrapper.getItem().getDefinition();
    int min = definition.getMinOccurs();

    int count = countNonDeletedValues(propertyWrapper);
    if (count <= 1 || count <= min) {
      return false;
    }

    if (propertyWrapper.getContainer() == null) {
      return true; // TODO
    }

    return isAccessible(definition, getContainerStatus(propertyWrapper));
  }
示例#3
0
 private ContainerStatus getContainerStatus(ItemWrapper propertyWrapper) {
   final ObjectWrapper objectWrapper = propertyWrapper.getContainer().getObject();
   return objectWrapper != null ? objectWrapper.getStatus() : ContainerStatus.MODIFYING;
 }