@Override
  protected void attachField(Object propertyId, Field field) {
    PhysicalAttributeConfirmActualsFieldSetComponent fieldSet =
        ((CollapsiblePhysicalAttributeConfirmActualsFormComponent) getComponentModel())
            .getFieldSetForField((String) propertyId);
    if (fieldSet != null) {
      PhysicalAttributeConfirmActualsFieldSetFieldComponent fieldComponent =
          fieldSet.getFieldSetField((String) propertyId);
      if (fieldComponent != null) {
        fields.put(field, fieldComponent);
        field.setWidth("100%");
        VaadinFormFieldAugmenter.augment(field, fieldComponent);
        if (this.getComponentModel().isReadOnly()) {
          field.setReadOnly(true);
        }
        VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader header =
            headers.get(fieldSet);
        if (header == null) {
          header = addFormSection(fieldSet);
        }

        GridLayout gridLayout = (GridLayout) header.getLayout();
        Integer index = fieldIndexMap.get(fieldComponent);
        if (index == null) {
          index = getNextIndex(gridLayout);
          fieldIndexMap.put(fieldComponent, index);
        }
        allocateIndex(gridLayout, index);

        Label label = new Label(fieldComponent.getCaption());
        label.setStyleName("conx-confirm-actuals-field-caption");
        label.setWidth("100%");
        addCaptionLabel(gridLayout, index, label);

        if (fieldSet.isExpected(propertyId)) {
          field.setEnabled(false);
          field.setCaption(null);
          addExpectedField(gridLayout, index, field);
        } else if (fieldSet.isActual(propertyId)) {
          field.setCaption(null);
          addActualField(gridLayout, index, field);
        } else if (fieldSet.isActualUnit(propertyId)) {
          field.setCaption(null);
          addActualUnitField(gridLayout, index, field);
        } else if (fieldSet.isExpectedUnit(propertyId)) {
          field.setCaption(null);
          field.setEnabled(false);
          addExpectedUnitField(gridLayout, index, field);
        }
      }
    }
  }
コード例 #2
0
    @Override
    protected Field createField(Object propertyId, String caption) {

      if (RelatedProjectsExt.PROPERTY_CALCULATED.equals(propertyId)) {
        final CheckBox field = new CheckBox(caption);
        field.setImmediate(true);
        field.addListener(
            new ValueChangeListener() {

              private static final long serialVersionUID = 3996507266934851419L;

              @Override
              public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                if (comboBox != null) {
                  comboBox.setEnabled(!field.booleanValue());
                }
              }
            });
        return field;
      } else if (RelatedProjectsExt.PROPERTY_RELATED_PROJECT.equals(propertyId)) {
        UUIDList ids = extension.getRelatedProjects();
        comboBox = new MultiComboBox(caption, ids);
        comboBox.setEnabled(!extension.getCalculated());
        return comboBox;
      }
      return null;
    }
コード例 #3
0
 private void enableField(Field<?> field, boolean enabled) {
   field.setEnabled(enabled);
   // we revert changes, when we disable the fields
   if (!enabled) {
     field.discard();
     // hide validation errors when disabled
     if (field instanceof AbstractComponent) {
       ((AbstractComponent) field).setComponentError(null);
     }
   }
 }