Search in sources :

Example 46 with RibbonGroup

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

the class ParametersHooks method changeButtonsState.

private void changeButtonsState(final ViewDefinitionState view, final boolean enabled) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup company = ribbon.getGroupByName(L_COMPANY);
    RibbonActionItem redirectToCompany = company.getItemByName(L_REDIRECT_TO_COMPANY);
    redirectToCompany.setEnabled(enabled);
    redirectToCompany.requestUpdate(true);
    window.requestRibbonRender();
}
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 47 with RibbonGroup

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

the class StaffsListHooks method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    GridComponent staffsGrid = (GridComponent) view.getComponentByReference(L_GRID);
    WindowComponent window = (WindowComponent) view.getComponentByReference(L_WINDOW);
    RibbonGroup labels = window.getRibbon().getGroupByName(L_LABELS);
    RibbonActionItem printStaffLabels = labels.getItemByName(L_PRINT_STAFF_LABELS);
    boolean isEnabled = !staffsGrid.getSelectedEntities().isEmpty();
    printStaffLabels.setEnabled(isEnabled);
    printStaffLabels.requestUpdate(true);
}
Also used : 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)

Example 48 with RibbonGroup

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

the class ProductDetailsHooks method updateProductFamilySizesRibbonState.

public void updateProductFamilySizesRibbonState(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup productFamily = window.getRibbon().getGroupByName(L_PRODUCT_FAMILY);
    RibbonActionItem productFamilySizes = productFamily.getItemByName(L_PRODUCT_FAMILY_SIZES);
    Entity product = productForm.getEntity();
    updateButtonState(productFamilySizes, ProductFamilyElementType.PRODUCTS_FAMILY.getStringValue().equals(product.getField(ProductFields.ENTITY_TYPE)));
}
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 49 with RibbonGroup

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

the class ImportService method changeButtonsState.

public void changeButtonsState(final ViewDefinitionState view, final boolean isEnabled) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup importRibbonGroup = ribbon.getGroupByName(L_IMPORT);
    RibbonActionItem redirectToLogsRibbonActionItem = importRibbonGroup.getItemByName(L_REDIRECT_TO_LOGS);
    redirectToLogsRibbonActionItem.setEnabled(isEnabled);
    redirectToLogsRibbonActionItem.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 50 with RibbonGroup

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

the class DeliveryDetailsHooks method updateChangeStorageLocationButton.

private void updateChangeStorageLocationButton(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent deliveredProductsGrid = (GridComponent) view.getComponentByReference(DeliveryFields.DELIVERED_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName(L_DELIVERY_POSITIONS);
    RibbonActionItem changeStorageLocations = group.getItemByName(L_CHANGE_STORAGE_LOCATIONS);
    List<Entity> selectedProducts = deliveredProductsGrid.getSelectedEntities();
    Long deliveryId = deliveryForm.getEntityId();
    boolean enabled = false;
    if (Objects.nonNull(deliveryId)) {
        Entity delivery = deliveriesService.getDelivery(deliveryId);
        String state = delivery.getStringField(DeliveryFields.STATE);
        boolean isFinished = DeliveryState.RECEIVED.getStringValue().equals(state) || DeliveryState.DECLINED.getStringValue().equals(state);
        enabled = !selectedProducts.isEmpty() && !isFinished;
        if (enabled) {
            String baseStorageLocation = Optional.ofNullable(selectedProducts.get(0).getStringField("storageLocationNumber")).orElse(StringUtils.EMPTY);
            for (Entity deliveredProduct : selectedProducts) {
                String storageLocation = Optional.ofNullable(deliveredProduct.getStringField("storageLocationNumber")).orElse(StringUtils.EMPTY);
                if (!baseStorageLocation.equals(storageLocation)) {
                    enabled = false;
                }
            }
        }
    }
    updateButtonState(changeStorageLocations, enabled);
}
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) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

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