Search in sources :

Example 41 with WindowComponent

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

the class MaterialRequirementCoverageDetailsHooks method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FieldComponent generatedField = (FieldComponent) view.getComponentByReference(MaterialRequirementCoverageFields.GENERATED);
    boolean generated = "1".equals(generatedField.getFieldValue());
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup coverage = (RibbonGroup) window.getRibbon().getGroupByName(L_COVERAGE);
    RibbonActionItem printMaterialRequirementCoverage = (RibbonActionItem) coverage.getItemByName(L_PRINT_MATERIAL_REQUIREMENT_COVERAGE);
    updateButtonState(printMaterialRequirementCoverage, generated);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 42 with WindowComponent

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

the class CopyOfTechnologyHooks method disableRibbonItem.

private void disableRibbonItem(final ViewDefinitionState view, final Entity order) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup technology = ribbon.getGroupByName(L_TECHNOLOGY);
    RibbonGroup status = ribbon.getGroupByName(L_STATUS);
    RibbonActionItem clearAndLoadPatternTechnology = technology.getItemByName(L_CLEAR_AND_LOAD_PATTERN_TECHNOLOGY);
    RibbonActionItem checkTechnology = status.getItemByName(L_CHECK_TECHNOLOGY);
    String state = order.getStringField(OrderFields.STATE);
    if (!OrderState.PENDING.getStringValue().equals(state)) {
        clearAndLoadPatternTechnology.setEnabled(false);
        clearAndLoadPatternTechnology.requestUpdate(true);
        checkTechnology.setEnabled(false);
        checkTechnology.requestUpdate(true);
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 43 with WindowComponent

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

the class OrderPackDetailsHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) {
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderPackFields.ORDER);
    Entity order = orderLookup.getEntity();
    FieldComponent orderQuantity = (FieldComponent) view.getComponentByReference("orderQuantity");
    FieldComponent sumQuantityOrderPacksField = (FieldComponent) view.getComponentByReference("sumQuantityOrderPacks");
    FieldComponent orderQuantityUnit = (FieldComponent) view.getComponentByReference("orderQuantityUnit");
    FieldComponent sumQuantityOrderPacksUnit = (FieldComponent) view.getComponentByReference("sumQuantityOrderPacksUnit");
    FieldComponent quantityUnit = (FieldComponent) view.getComponentByReference("quantityUnit");
    if (order != null) {
        String orderState = order.getStringField(OrderFields.STATE);
        FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
        if (OrderState.COMPLETED.getStringValue().equals(orderState) || OrderState.DECLINED.getStringValue().equals(orderState) || OrderState.ABANDONED.getStringValue().equals(orderState) || OrderState.PENDING.getStringValue().equals(orderState)) {
            form.setFormEnabled(false);
            WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
            Ribbon ribbon = window.getRibbon();
            RibbonActionItem actionsSave = ribbon.getGroupByName(ACTIONS).getItemByName("save");
            RibbonActionItem actionsSaveNew = ribbon.getGroupByName(ACTIONS).getItemByName("saveNew");
            RibbonActionItem actionsSaveBack = ribbon.getGroupByName(ACTIONS).getItemByName("saveBack");
            actionsSave.setEnabled(false);
            actionsSave.requestUpdate(true);
            actionsSaveNew.setEnabled(false);
            actionsSaveNew.requestUpdate(true);
            actionsSaveBack.setEnabled(false);
            actionsSaveBack.requestUpdate(true);
        }
        orderQuantity.setFieldValue(numberService.format(order.getField(OrderFields.PLANNED_QUANTITY)));
        FieldComponent quantityField = (FieldComponent) view.getComponentByReference(OrderPackFields.QUANTITY);
        BigDecimal sumQuantityOrderPacks = orderPackService.getSumQuantityOrderPacksForOrderWithoutPack(order, form.getEntityId());
        Either<Exception, Optional<BigDecimal>> eitherNumber = BigDecimalUtils.tryParseAndIgnoreSeparator((String) quantityField.getFieldValue(), LocaleContextHolder.getLocale());
        if (eitherNumber.isRight() && eitherNumber.getRight().isPresent()) {
            sumQuantityOrderPacks = sumQuantityOrderPacks.add(eitherNumber.getRight().get(), numberService.getMathContext());
        }
        sumQuantityOrderPacksField.setFieldValue(numberService.format(sumQuantityOrderPacks));
        String unit = order.getBelongsToField(OrderFields.PRODUCT).getStringField(ProductFields.UNIT);
        orderQuantityUnit.setFieldValue(unit);
        sumQuantityOrderPacksUnit.setFieldValue(unit);
        quantityUnit.setFieldValue(unit);
    } else {
        orderQuantity.setFieldValue(null);
        sumQuantityOrderPacksField.setFieldValue(null);
        orderQuantityUnit.setFieldValue(null);
        sumQuantityOrderPacksUnit.setFieldValue(null);
        quantityUnit.setFieldValue(null);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) Optional(com.google.common.base.Optional) LookupComponent(com.qcadoo.view.api.components.LookupComponent) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) FieldComponent(com.qcadoo.view.api.components.FieldComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) BigDecimal(java.math.BigDecimal)

Example 44 with WindowComponent

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

the class OrderTechnologicalProcessesListHooks method updateRibbonState.

private void updateRibbonState(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orderTechnologicalProcessesGroup = window.getRibbon().getGroupByName(L_ORDER_TECHNOLOGICAL_PROCESSES);
    RibbonGroup orderTechnologicalProcessWastesGroup = window.getRibbon().getGroupByName(L_ORDER_TECHNOLOGICAL_PROCESS_WASTES);
    RibbonActionItem divideOrderTechnologicalProcessActionItem = orderTechnologicalProcessesGroup.getItemByName(L_DIVIDE_ORDER_TECHNOLOGICAL_PROCESS);
    RibbonActionItem createOrderTechnologicalProcessWasteActionItem = orderTechnologicalProcessWastesGroup.getItemByName(L_CREATE_ORDER_TECHNOLOGICAL_PROCESS_WASTE);
    GridComponent orderTechnologicalProcessesGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Set<Long> orderTechnologicalProcessesIds = orderTechnologicalProcessesGrid.getSelectedEntitiesIds();
    String message = null;
    boolean isOrderTechnologicalProcessSelected = orderTechnologicalProcessesIds.size() == 1;
    boolean isOrderStateValid = false;
    boolean isOrderTechnologicalProcessFilled = false;
    if (isOrderTechnologicalProcessSelected) {
        Long orderTechnologicalProcessId = orderTechnologicalProcessesIds.stream().findFirst().get();
        Entity orderTechnologicalProcess = orderTechnologicalProcessService.getOrderTechnologicalProcess(orderTechnologicalProcessId);
        if (Objects.nonNull(orderTechnologicalProcess)) {
            Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
            Date date = orderTechnologicalProcess.getDateField(OrderTechnologicalProcessFields.DATE);
            Entity worker = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.WORKER);
            if (Objects.nonNull(order)) {
                isOrderStateValid = !orderTechnologicalProcessService.checkOrderState(order);
            }
            if (isOrderStateValid) {
                isOrderTechnologicalProcessFilled = Objects.nonNull(date) && Objects.nonNull(worker);
                if (!isOrderTechnologicalProcessFilled) {
                    message = "orders.ribbon.message.orderTechnologicalProcessNotFilled";
                }
            } else {
                message = "orders.ribbon.message.canNotCreateOrderTechnologicalProcessWaste";
            }
        }
    }
    divideOrderTechnologicalProcessActionItem.setEnabled(isOrderTechnologicalProcessSelected && isOrderStateValid);
    divideOrderTechnologicalProcessActionItem.requestUpdate(true);
    createOrderTechnologicalProcessWasteActionItem.setEnabled(isOrderTechnologicalProcessSelected && isOrderStateValid && isOrderTechnologicalProcessFilled);
    createOrderTechnologicalProcessWasteActionItem.setMessage(message);
    createOrderTechnologicalProcessWasteActionItem.requestUpdate(true);
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) Date(java.util.Date)

Example 45 with WindowComponent

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

the class ProductDetailsViewHooksO method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity product = productForm.getEntity();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName("orders");
    RibbonActionItem showOrdersWithProductMain = (RibbonActionItem) orders.getItemByName("showOrdersWithProductMain");
    RibbonActionItem showOrdersWithProductPlanned = (RibbonActionItem) orders.getItemByName("showOrdersWithProductPlanned");
    if (product.getId() != null) {
        updateButtonState(showOrdersWithProductMain, true);
        updateButtonState(showOrdersWithProductPlanned, true);
        return;
    }
    updateButtonState(showOrdersWithProductMain, false);
    updateButtonState(showOrdersWithProductPlanned, false);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

WindowComponent (com.qcadoo.view.api.components.WindowComponent)105 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)93 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)75 FormComponent (com.qcadoo.view.api.components.FormComponent)51 Entity (com.qcadoo.model.api.Entity)46 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)31 GridComponent (com.qcadoo.view.api.components.GridComponent)28 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 EntityTree (com.qcadoo.model.api.EntityTree)4 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)3 JSONObject (org.json.JSONObject)3 Optional (com.google.common.base.Optional)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 TreeComponent (com.qcadoo.view.api.components.TreeComponent)2 Date (java.util.Date)2 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1