public void onProductionInOneCycleCheckboxChange(
     final ViewDefinitionState viewDefinitionState,
     final ComponentState state,
     final String[] args) {
   FieldComponent areProductQuantitiesDivisible =
       (FieldComponent)
           viewDefinitionState.getComponentByReference(ARE_PRODUCT_QUANTITIES_DIVISIBLE);
   FieldComponent isTjDivisible =
       (FieldComponent) viewDefinitionState.getComponentByReference(IS_TJ_DIVISIBLE);
   if ("1".equals(areProductQuantitiesDivisible.getFieldValue())) {
     isTjDivisible.setEnabled(true);
   } else {
     isTjDivisible.setEnabled(false);
     isTjDivisible.setFieldValue("0");
   }
 }
 private void clearAndDisabledFields(
     final ViewDefinitionState view, final Set<String> fieldNames) {
   for (String fieldName : fieldNames) {
     FieldComponent currencyField = (FieldComponent) view.getComponentByReference(fieldName);
     currencyField.setFieldValue(L_EMPTY);
     currencyField.setEnabled(false);
   }
 }
  public void fillUnitField(
      final ViewDefinitionState viewDefinitionState,
      final String fieldName,
      final boolean inProduct) {
    checkArgument(viewDefinitionState != null, L_VIEW_DEFINITION_STATE_IS_NULL);

    FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(L_FORM);
    FieldComponent unitField =
        (FieldComponent) viewDefinitionState.getComponentByReference(fieldName);
    unitField.setFieldValue(L_EMPTY);
    unitField.setEnabled(false);
    if (form == null || form.getEntityId() == null) {
      return;
    }

    Long productId = null;

    if (inProduct) {
      productId = (Long) form.getFieldValue();
    } else {
      FieldComponent productField =
          (FieldComponent) viewDefinitionState.getComponentByReference("product");

      if (productField == null) {
        return;
      }

      productId = (Long) productField.getFieldValue();
    }

    Entity product =
        dataDefinitionService
            .get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT)
            .get(productId);

    if (product == null) {
      return;
    }

    String unit = product.getStringField(UNIT);

    fillField(unitField, unit);
  }
  public void changeNextOperationAfterProducedTypeNorm(
      final ViewDefinitionState viewDefinitionState,
      final ComponentState state,
      final String[] args) {
    FieldComponent nextOperationAfterProducedType =
        (FieldComponent)
            viewDefinitionState.getComponentByReference(NEXT_OPERATION_AFTER_PRODUCED_TYPE);
    FieldComponent nextOperationAfterProducedQuantity =
        (FieldComponent)
            viewDefinitionState.getComponentByReference(NEXT_OPERATION_AFTER_PRODUCED_QUANTITY);
    FieldComponent nextOperationAfterProducedQuantityUNIT =
        (FieldComponent)
            viewDefinitionState.getComponentByReference(
                TechnologyOperCompTNFOFields.NEXT_OPERATION_AFTER_PRODUCED_QUANTITY_UNIT);

    Boolean visibilityValue = "02specified".equals(nextOperationAfterProducedType.getFieldValue());
    nextOperationAfterProducedQuantity.setVisible(visibilityValue);
    nextOperationAfterProducedQuantity.setEnabled(visibilityValue);
    nextOperationAfterProducedQuantityUNIT.setVisible(visibilityValue);
  }
  public void enabledFieldForExternalID(final ViewDefinitionState view) {
    FieldComponent nominalCost = (FieldComponent) view.getComponentByReference(L_NOMINAL_COST);
    FormComponent form = (FormComponent) view.getComponentByReference(L_FORM);
    if (form.getEntityId() == null) {
      return;
    }
    Entity entity =
        dataDefinitionService
            .get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT)
            .get(form.getEntityId());

    if (entity == null) {
      return;
    }
    String externalNumber = entity.getStringField("externalNumber");

    if (externalNumber != null) {
      nominalCost.setEnabled(true);
    }
  }