Search in sources :

Example 36 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 37 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 38 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 39 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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)

Example 40 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class OrderDetailsRibbonHelper method getRibbonItem.

public RibbonActionItem getRibbonItem(final ViewDefinitionState view, final String ribbonGroupName, final String ribbonItemName) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup ribbonGroup = ribbon.getGroupByName(ribbonGroupName);
    if (Objects.isNull(ribbonGroup)) {
        return null;
    }
    return ribbonGroup.getItemByName(ribbonItemName);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon)

Aggregations

RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)92 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)86 WindowComponent (com.qcadoo.view.api.components.WindowComponent)75 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)37 FormComponent (com.qcadoo.view.api.components.FormComponent)36 Entity (com.qcadoo.model.api.Entity)34 GridComponent (com.qcadoo.view.api.components.GridComponent)23 FieldComponent (com.qcadoo.view.api.components.FieldComponent)9 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)3 LookupComponent (com.qcadoo.view.api.components.LookupComponent)3 JSONObject (org.json.JSONObject)3 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)2 Optional (com.google.common.base.Optional)1 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1