Search in sources :

Example 96 with CheckBoxComponent

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

the class TrackingOperationProductInComponentDetailsHooks method toggleEnabledForWastes.

private void toggleEnabledForWastes(final ViewDefinitionState view) {
    CheckBoxComponent wasteUsed = (CheckBoxComponent) view.getComponentByReference(L_WASTE_USED);
    CheckBoxComponent wasteUsedOnly = (CheckBoxComponent) view.getComponentByReference(L_WASTE_USED_ONLY);
    FieldComponent wasteUsedQuantity = (FieldComponent) view.getComponentByReference(L_WASTE_USED_QUANTITY);
    FieldComponent wasteUnit = (FieldComponent) view.getComponentByReference(L_WASTE_UNIT);
    if (wasteUsed.isChecked()) {
        wasteUsedOnly.setEnabled(true);
        wasteUsedQuantity.setEnabled(true);
        wasteUnit.setEnabled(true);
    } else {
        wasteUsedOnly.setEnabled(false);
        wasteUsedQuantity.setEnabled(false);
        wasteUnit.setEnabled(false);
    }
    FieldComponent usedQuantity = (FieldComponent) view.getComponentByReference(L_USED_QUANTITY);
    FieldComponent givenQuantity = (FieldComponent) view.getComponentByReference(L_GIVEN_QUANTITY);
    if (wasteUsedOnly.isChecked()) {
        usedQuantity.setEnabled(false);
        givenQuantity.setEnabled(false);
    } else {
        usedQuantity.setEnabled(true);
        givenQuantity.setEnabled(true);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 97 with CheckBoxComponent

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

the class ParametersHooksPC method setStateConsumptionOfRawMaterialsBasedOnStandards.

private void setStateConsumptionOfRawMaterialsBasedOnStandards(ViewDefinitionState view) {
    CheckBoxComponent consumptionOfRawMaterialsBasedOnStandards = (CheckBoxComponent) view.getComponentByReference(ParameterFieldsPC.CONSUMPTION_OF_RAW_MATERIALS_BASED_ON_STANDARDS);
    FieldComponent releaseOfMaterials = (FieldComponent) view.getComponentByReference(ParameterFieldsPC.RELEASE_OF_MATERIALS);
    if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials.getFieldValue().toString())) {
        consumptionOfRawMaterialsBasedOnStandards.setEnabled(false);
    } else {
        consumptionOfRawMaterialsBasedOnStandards.setEnabled(true);
    }
    consumptionOfRawMaterialsBasedOnStandards.requestComponentUpdateState();
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 98 with CheckBoxComponent

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

the class ChangeTechnologyParametersListeners method changeTechnologyParameters.

public void changeTechnologyParameters(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
    LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(L_TECHNOLOGY_GROUP);
    String code = lookupComponent.getCurrentCode();
    if (StringUtils.isNoneEmpty(code) && Objects.isNull(lookupComponent.getFieldValue())) {
        form.findFieldComponentByName(L_TECHNOLOGY_GROUP).addMessage("qcadooView.lookup.noMatchError", ComponentState.MessageType.FAILURE);
        generated.setChecked(false);
        return;
    }
    Entity group = null;
    Entity entity = form.getPersistedEntityWithIncludedFormValues();
    if (entity.getBooleanField(L_CHANGE_GROUP) && Objects.nonNull(entity.getLongField(L_TECHNOLOGY_GROUP))) {
        group = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_GROUP).get(entity.getLongField(L_TECHNOLOGY_GROUP));
        entity.setField(L_TECHNOLOGY_GROUP, group);
    }
    try {
        entity = entity.getDataDefinition().validate(entity);
        if (!entity.isValid()) {
            form.setEntity(entity);
            return;
        }
    } catch (IllegalArgumentException e) {
        form.findFieldComponentByName(L_STANDARD_PERFORMANCE).addMessage("qcadooView.validate.field.error.invalidNumericFormat", ComponentState.MessageType.FAILURE);
        generated.setChecked(false);
        return;
    }
    JSONObject context = view.getJsonContext();
    Set<Long> ids = Arrays.stream(context.getString("window.mainTab.form.gridLayout.selectedEntities").replaceAll("[\\[\\]]", "").split(",")).map(Long::valueOf).collect(Collectors.toSet());
    BigDecimal standardPerformance = null;
    if (entity.getBooleanField(L_CHANGE_PERFORMANCE_NORM)) {
        standardPerformance = entity.getDecimalField(L_STANDARD_PERFORMANCE);
    }
    try {
        createCustomizedTechnologies(view, state, ids, entity, group, standardPerformance);
    } catch (Exception exc) {
        view.addMessage("technologies.changeTechnologyParameters.error.technologiesNotCreated", ComponentState.MessageType.FAILURE);
    }
    generated.setChecked(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) LookupComponent(com.qcadoo.view.api.components.LookupComponent) BigDecimal(java.math.BigDecimal) JSONException(org.json.JSONException) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 99 with CheckBoxComponent

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

the class ChangeTechnologyParametersListeners method onChangeChangeGroup.

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

Example 100 with CheckBoxComponent

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

the class TOCDetailsListenersPFTD method onProductionLineChange.

public void onProductionLineChange(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    CheckBoxComponent productionLineChange = (CheckBoxComponent) view.getComponentByReference("productionLineChange");
    productionLineChange.setChecked(true);
    productionLineChange.requestComponentUpdateState();
}
Also used : 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