Search in sources :

Example 51 with CheckBoxComponent

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

the class DivideOrderTechnologicalProcessListeners method saveDivision.

public void saveDivision(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent orderTechnologicalProcessForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
    CheckBoxComponent isValidCheckBox = (CheckBoxComponent) view.getComponentByReference(OrderTechnologicalProcessFields.IS_VALID);
    Entity orderTechnologicalProcess = orderTechnologicalProcessForm.getEntity();
    Long orderTechnologicalProcessId = orderTechnologicalProcess.getId();
    orderTechnologicalProcess = orderTechnologicalProcess.getDataDefinition().get(orderTechnologicalProcessId);
    List<FormComponent> orderTechnologicalProcessPartForms = orderTechnologicalProcessPartsADL.getFormComponents();
    boolean isValid = validateDivision(orderTechnologicalProcessForm, orderTechnologicalProcessPartForms, orderTechnologicalProcess);
    if (isValid) {
        for (FormComponent orderTechnologicalProcessPartForm : orderTechnologicalProcessPartForms) {
            FieldComponent numberField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.NUMBER);
            FieldComponent quantityField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.QUANTITY);
            String number = (String) numberField.getFieldValue();
            Either<Exception, Optional<BigDecimal>> eitherQuantity = BigDecimalUtils.tryParse(quantityField.getFieldValue().toString(), LocaleContextHolder.getLocale());
            Optional<BigDecimal> mayBeQuantity = eitherQuantity.getRight();
            if ("1".equals(number)) {
                if (mayBeQuantity.isPresent()) {
                    orderTechnologicalProcess.setField(OrderTechnologicalProcessFields.QUANTITY, mayBeQuantity.get());
                }
                orderTechnologicalProcess.getDataDefinition().save(orderTechnologicalProcess);
            } else {
                Entity orderPack = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER_PACK);
                Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
                Entity product = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.PRODUCT);
                Entity operation = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.OPERATION);
                Entity technologyOperationComponent = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGY_OPERATION_COMPONENT);
                Entity technologicalProcess = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGICAL_PROCESS);
                if (mayBeQuantity.isPresent()) {
                    createOrderTechnologicalProcess(orderPack, order, product, technologyOperationComponent, operation, technologicalProcess, mayBeQuantity.get());
                }
            }
        }
        view.addMessage("orders.divideOrderTechnologicalProcess.divide.success", ComponentState.MessageType.SUCCESS);
    } else {
        view.addMessage("orders.divideOrderTechnologicalProcess.divide.failure", ComponentState.MessageType.FAILURE);
    }
    isValidCheckBox.setChecked(isValid);
    isValidCheckBox.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Optional(com.google.common.base.Optional) FieldComponent(com.qcadoo.view.api.components.FieldComponent) BigDecimal(java.math.BigDecimal) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 52 with CheckBoxComponent

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

the class OrderTechnologicalProcessWasteSingleDetailsListeners method saveWaste.

public void saveWaste(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent orderTechnologicalProcessWasteForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent isValidCheckBox = (CheckBoxComponent) view.getComponentByReference(OrderTechnologicalProcessFields.IS_VALID);
    orderTechnologicalProcessWasteForm.performEvent(view, "save");
    boolean isValid = orderTechnologicalProcessWasteForm.isValid();
    isValidCheckBox.setChecked(isValid);
    isValidCheckBox.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 53 with CheckBoxComponent

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

the class SetCategoryListeners method setCategory.

public void setCategory(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");
    FieldComponent orderCategory = (FieldComponent) view.getComponentByReference("orderCategory");
    String value = (String) orderCategory.getFieldValue();
    JSONObject context = view.getJsonContext();
    Set<Long> ids = Arrays.stream(context.getString("window.mainTab.form.selectedEntities").replaceAll("[\\[\\]]", "").split(",")).map(Long::valueOf).collect(Collectors.toSet());
    ids.forEach(orderId -> {
        fillCategory(value, orderId);
    });
    generated.setChecked(true);
    view.addMessage("orders.order.setCategory.success", ComponentState.MessageType.SUCCESS);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) JSONObject(org.json.JSONObject) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 54 with CheckBoxComponent

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

the class ParametersHooksO method onPlanningParametersBeforeRender.

public void onPlanningParametersBeforeRender(final ViewDefinitionState view) {
    CheckBoxComponent automaticallyGenerateTasksForOrder = (CheckBoxComponent) view.getComponentByReference(L_AUTOMATICALLY_GENERATE_TASKS_FOR_ORDER);
    CheckBoxComponent completeStationAndEmployeeInGeneratedTasks = (CheckBoxComponent) view.getComponentByReference(L_COMPLETE_STATION_AND_EMPLOYEE_IN_GENERATED_TASKS);
    if (automaticallyGenerateTasksForOrder.isChecked()) {
        completeStationAndEmployeeInGeneratedTasks.setEnabled(true);
    } else {
        completeStationAndEmployeeInGeneratedTasks.setEnabled(false);
    }
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 55 with CheckBoxComponent

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

the class ParametersHooksO method onOrdersParameterBeforeRender.

public void onOrdersParameterBeforeRender(final ViewDefinitionState view) {
    CheckBoxComponent realizationFromStockComponent = (CheckBoxComponent) view.getComponentByReference(L_REALIZATION_FROM_STOCK);
    CheckBoxComponent alwaysOrderItemsWithPersonalizationComponent = (CheckBoxComponent) view.getComponentByReference(L_ALWAYS_ORDER_ITEMS_WITH_PERSONALIZATION);
    GridComponent realizationLocationsGrid = (GridComponent) view.getComponentByReference(L_REALIZATION_LOCATIONS);
    if (realizationFromStockComponent.isChecked()) {
        alwaysOrderItemsWithPersonalizationComponent.setEnabled(true);
        realizationLocationsGrid.setEditable(true);
    } else {
        alwaysOrderItemsWithPersonalizationComponent.setEnabled(false);
        realizationLocationsGrid.setEditable(false);
    }
    alwaysOrderItemsWithPersonalizationComponent.requestComponentUpdateState();
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent) 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