Search in sources :

Example 21 with CheckBoxComponent

use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.

the class WorkPlanDetailsHooks method disableFormForGeneratedWorkPlan.

final void disableFormForGeneratedWorkPlan(final ViewDefinitionState view) {
    FormComponent workPlanForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generatedCheckbox = (CheckBoxComponent) view.getComponentByReference(WorkPlanFields.GENERATED);
    if (workPlanForm == null) {
        return;
    }
    if (workPlanForm.getEntityId() == null) {
        view.getComponentByReference(WorkPlanFields.ORDERS).setEnabled(false);
        view.getComponentByReference(WorkPlanFields.WORK_PLAN_ORDER_COLUMNS).setEnabled(false);
    } else {
        boolean isEnabled = !generatedCheckbox.isChecked();
        view.getComponentByReference(WorkPlanFields.NAME).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.TYPE).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.DONT_PRINT_ORDERS_IN_WORK_PLANS).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.ORDERS).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.WORK_PLAN_ORDER_COLUMNS).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.INPUT_PRODUCT_COLUMN_TO_SORT_BY).setEnabled(isEnabled);
        view.getComponentByReference(WorkPlanFields.ORDER_SORTING).setEnabled(isEnabled);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 22 with CheckBoxComponent

use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.

the class OrderParametersListenersBPC method onChangeLockProductionProgress.

public void onChangeLockProductionProgress(final ViewDefinitionState viewState, final ComponentState componentState, final String[] args) {
    CheckBoxComponent lockProductionProgressCheckBox = (CheckBoxComponent) componentState;
    CheckBoxComponent allowQuantityChangeInAcceptedOrderCheckBox = (CheckBoxComponent) viewState.getComponentByReference(ParameterFieldsO.ALLOW_QUANTITY_CHANGE_IN_ACCEPTED_ORDER);
    if (allowQuantityChangeInAcceptedOrderCheckBox == null) {
        if (LOG.isErrorEnabled()) {
            LOG.error(String.format("orderParameters view: can't find component with reference='%s'", ParameterFieldsO.ALLOW_QUANTITY_CHANGE_IN_ACCEPTED_ORDER));
        }
        return;
    }
    if (!allowQuantityChangeInAcceptedOrderCheckBox.isEnabled() && lockProductionProgressCheckBox.isChecked()) {
        allowQuantityChangeInAcceptedOrderCheckBox.setChecked(false);
    }
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 23 with CheckBoxComponent

use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.

the class AttributeDetailsHooks method disableFormComponentsIfAttributeAssign.

private void disableFormComponentsIfAttributeAssign(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent dataType = (FieldComponent) view.getComponentByReference(AttributeFields.DATA_TYPE);
    FieldComponent valueType = (FieldComponent) view.getComponentByReference(AttributeFields.VALUE_TYPE);
    FieldComponent precision = (FieldComponent) view.getComponentByReference(AttributeFields.PRECISION);
    FieldComponent unit = (FieldComponent) view.getComponentByReference(AttributeFields.UNIT);
    CheckBoxComponent forProduct = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_PRODUCT);
    CheckBoxComponent forResource = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_RESOURCE);
    CheckBoxComponent forQualityControl = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_QUALITY_CONTROL);
    dataType.setEnabled(true);
    valueType.setEnabled(true);
    precision.setEnabled(true);
    unit.setEnabled(true);
    forProduct.setEnabled(true);
    forResource.setEnabled(true);
    forQualityControl.setEnabled(true);
    if (Objects.nonNull(form.getEntityId())) {
        Entity attribute = form.getEntity().getDataDefinition().get(form.getEntity().getId());
        if (!attribute.getHasManyField(AttributeFields.PRODUCT_ATTRIBUTE_VALUES).isEmpty()) {
            dataType.setEnabled(false);
            valueType.setEnabled(false);
            precision.setEnabled(false);
            unit.setEnabled(false);
            forProduct.setEnabled(false);
        }
        if (!attribute.getHasManyField(AttributeFields.RESOURCE_ATTRIBUTE_VALUES).isEmpty()) {
            dataType.setEnabled(false);
            valueType.setEnabled(false);
            precision.setEnabled(false);
            unit.setEnabled(false);
            forResource.setEnabled(false);
        }
        if (!attribute.getHasManyField(AttributeFields.QUALITY_CONTROL_ATTRIBUTE).isEmpty()) {
            dataType.setEnabled(false);
            valueType.setEnabled(false);
            precision.setEnabled(false);
            unit.setEnabled(false);
            forQualityControl.setEnabled(false);
        }
        if (!attribute.getHasManyField(AttributeFields.ATTRIBUTE_VALUES).isEmpty()) {
            dataType.setEnabled(false);
            valueType.setEnabled(false);
            precision.setEnabled(false);
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 24 with CheckBoxComponent

use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.

the class CompanyDetailsHooks method fillDefaultCountry.

public void fillDefaultCountry(final ViewDefinitionState view) {
    FormComponent companyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (companyForm.getEntityId() != null) {
        return;
    }
    CheckBoxComponent isSetFieldsFromParameter = (CheckBoxComponent) view.getComponentByReference(CompanyFields.IS_SET_FIELDS_FROM_PARAMETER);
    if (isSetFieldsFromParameter.isChecked()) {
        return;
    }
    LookupComponent countryField = (LookupComponent) view.getComponentByReference(CompanyFields.COUNTRY);
    LookupComponent taxCountryField = (LookupComponent) view.getComponentByReference(CompanyFields.TAX_COUNTRY_CODE);
    Entity defaultCountry = parameterService.getParameter().getBelongsToField(CompanyFields.COUNTRY);
    if (defaultCountry != null) {
        countryField.setFieldValue(defaultCountry.getId());
        taxCountryField.setFieldValue(defaultCountry.getId());
        taxCountryField.requestComponentUpdateState();
        countryField.requestComponentUpdateState();
    }
    isSetFieldsFromParameter.setFieldValue(true);
    isSetFieldsFromParameter.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 25 with CheckBoxComponent

use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.

the class AttributeValueImportListeners method importProductAttrValues.

public void importProductAttrValues(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    CheckBoxComponent importedCheckBoxComponent = (CheckBoxComponent) view.getComponentByReference(IMPORTED);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity formEntity = form.getPersistedEntityWithIncludedFormValues();
    String positionsFilePath = formEntity.getStringField(L_POSITIONS_FILE);
    if (canImportPositions(view, positionsFilePath)) {
        return;
    }
    try {
        boolean imported = attributeImportService.importProductAttributeValues(positionsFilePath, view);
        importedCheckBoxComponent.setChecked(imported);
    } catch (IOException e) {
        view.addMessage("basic.attributeValuesImport.error", ComponentState.MessageType.FAILURE);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) IOException(java.io.IOException) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Aggregations

CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)100 FormComponent (com.qcadoo.view.api.components.FormComponent)38 Entity (com.qcadoo.model.api.Entity)33 FieldComponent (com.qcadoo.view.api.components.FieldComponent)30 GridComponent (com.qcadoo.view.api.components.GridComponent)19 LookupComponent (com.qcadoo.view.api.components.LookupComponent)11 Date (java.util.Date)7 JSONObject (org.json.JSONObject)7 BigDecimal (java.math.BigDecimal)6 ComponentState (com.qcadoo.view.api.ComponentState)4 WindowComponent (com.qcadoo.view.api.components.WindowComponent)4 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)4 IOException (java.io.IOException)4 MaterialFlowResourcesConstants (com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)2 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)2