Search in sources :

Example 16 with CheckBoxComponent

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

the class ModifyTechnologyDetailsHooks method configureAddPart.

private void configureAddPart(ViewDefinitionState view) {
    CheckBoxComponent addNewCheckBox = (CheckBoxComponent) view.getComponentByReference(ModifyTechnologyHelperFields.ADD_NEW);
    AwesomeDynamicListComponent addProductAdl = (AwesomeDynamicListComponent) view.getComponentByReference(L_MODIFY_TECHNOLOGY_ADD_PRODUCTS);
    if (addNewCheckBox.isChecked()) {
        addProductAdl.setEnabled(true);
        addProductAdl.getFormComponents().forEach(fc -> {
            fc.setFormEnabled(true);
            Entity addEntity = fc.getPersistedEntityWithIncludedFormValues();
            Entity product = addEntity.getBelongsToField(PRODUCT);
            if (Objects.nonNull(product)) {
                addEntity.setField(L_UNIT, product.getStringField(ProductFields.UNIT));
                fc.setEntity(addEntity);
            }
        });
    } else {
        addProductAdl.setEnabled(false);
        addProductAdl.getFormComponents().forEach(fc -> fc.setFormEnabled(false));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 17 with CheckBoxComponent

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

the class TechnologicalProcessComponentDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    CheckBoxComponent extendedTimeForSizeGroupField = (CheckBoxComponent) view.getComponentByReference(EXTENDED_TIME_FOR_SIZE_GROUP);
    FieldComponent increasePercentField = (FieldComponent) view.getComponentByReference(INCREASE_PERCENT);
    LookupComponent sizeGroupLookup = (LookupComponent) view.getComponentByReference(SIZE_GROUP);
    if (extendedTimeForSizeGroupField.isChecked()) {
        increasePercentField.setEnabled(true);
        increasePercentField.setRequired(true);
        sizeGroupLookup.setEnabled(true);
        sizeGroupLookup.setRequired(true);
    } else {
        increasePercentField.setEnabled(false);
        increasePercentField.setFieldValue(null);
        increasePercentField.setRequired(false);
        sizeGroupLookup.setEnabled(false);
        sizeGroupLookup.setFieldValue(null);
        sizeGroupLookup.setRequired(false);
    }
    increasePercentField.requestComponentUpdateState();
    sizeGroupLookup.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 18 with CheckBoxComponent

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

the class ChangeTechnologyParametersListeners method onChangePerformanceNorm.

public void onChangePerformanceNorm(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    CheckBoxComponent changePerformanceNorm = (CheckBoxComponent) state;
    FieldComponent standardPerformance = (FieldComponent) view.getComponentByReference(L_STANDARD_PERFORMANCE);
    if (changePerformanceNorm.isChecked()) {
        standardPerformance.setEnabled(true);
    } else {
        standardPerformance.setEnabled(false);
        standardPerformance.setFieldValue(null);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 19 with CheckBoxComponent

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

the class TechnologyDetailsListeners method acceptTemplate.

public void acceptTemplate(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent isTemplateAcceptedCheckBox = (CheckBoxComponent) view.getComponentByReference(TechnologyFields.IS_TEMPLATE_ACCEPTED);
    Entity technology = technologyForm.getEntity();
    Long technologyId = technology.getId();
    boolean isTemplateAccepted = isTemplateAcceptedCheckBox.isChecked();
    if (Objects.nonNull(technologyId)) {
        technology = technology.getDataDefinition().save(technology);
        if (isTemplateAccepted || validateTemplate(technologyForm, technology.getDataDefinition().get(technologyId))) {
            isTemplateAcceptedCheckBox.setChecked(!isTemplateAccepted);
            technologyForm.performEvent(view, "save");
            if (technologyForm.isHasError()) {
                isTemplateAcceptedCheckBox.setChecked(isTemplateAccepted);
            }
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 20 with CheckBoxComponent

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

the class ModifyTechnologyListeners method createTechnologies.

public void createTechnologies(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    componentState.performEvent(view, L_SAVE, args);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(L_GENERATED);
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (!formComponent.isValid()) {
        return;
    }
    Entity mt = formComponent.getEntity().getDataDefinition().get(formComponent.getEntityId());
    ModifyTechnologyResult modifyTechnologyResult = new ModifyTechnologyResult();
    createModifiedTechnology(view, componentState, mt, modifyTechnologyResult);
    if (!modifyTechnologyResult.getCreatedTechnologies().isEmpty()) {
        view.addMessage("technologies.modifyTechnology.createdTechnologies", ComponentState.MessageType.SUCCESS, String.join(",", modifyTechnologyResult.getCreatedTechnologies()));
    }
    if (!modifyTechnologyResult.getNotCreatedTechnologies().isEmpty()) {
        view.addMessage("technologies.modifyTechnology.notCreatedTechnologies", ComponentState.MessageType.FAILURE, String.join(",", modifyTechnologyResult.getNotCreatedTechnologies()));
    }
    generated.setChecked(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ModifyTechnologyResult(com.qcadoo.mes.technologies.dto.ModifyTechnologyResult) 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