Search in sources :

Example 51 with RibbonGroup

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

the class DeliveryDetailsHooks method updateCopyOrderedProductButtonsState.

private void updateCopyOrderedProductButtonsState(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long deliveryId = deliveryForm.getEntityId();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup reports = window.getRibbon().getGroupByName(L_COPY_ORDERED_PRODUCTS_TO_DELIVERY);
    RibbonActionItem copyWithout = reports.getItemByName(L_COPY_PRODUCTS_WITHOUT_QUANTITY);
    RibbonActionItem copyWith = reports.getItemByName(L_COPY_PRODUCTS_WITH_QUANTITY);
    if (Objects.isNull(deliveryId)) {
        return;
    }
    Entity delivery = deliveriesService.getDelivery(deliveryId);
    boolean hasOrderedProducts = !delivery.getHasManyField(DeliveryFields.ORDERED_PRODUCTS).isEmpty();
    String state = delivery.getStringField(DeliveryFields.STATE);
    boolean isFinished = DeliveryState.RECEIVED.getStringValue().equals(state) || DeliveryState.DECLINED.getStringValue().equals(state);
    copyWith.setEnabled(hasOrderedProducts && !isFinished);
    copyWithout.setEnabled(hasOrderedProducts && !isFinished);
    copyWith.requestUpdate(true);
    copyWithout.requestUpdate(true);
}
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 52 with RibbonGroup

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

the class DeliveriesServiceImpl method disableShowProductButton.

@Override
public void disableShowProductButton(final ViewDefinitionState view) {
    GridComponent orderedProductGrid = (GridComponent) view.getComponentByReference(DeliveryFields.ORDERED_PRODUCTS);
    GridComponent deliveredProductsGrid = (GridComponent) view.getComponentByReference(DeliveryFields.DELIVERED_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup product = window.getRibbon().getGroupByName(L_PRODUCT);
    RibbonActionItem showProduct = product.getItemByName(L_SHOW_PRODUCT);
    int sizeOfSelectedEntitiesOrderedGrid = orderedProductGrid.getSelectedEntities().size();
    int sizeOfSelectedEntitiesDeliveredGrid = deliveredProductsGrid.getSelectedEntities().size();
    boolean isEnabled = ((sizeOfSelectedEntitiesOrderedGrid == 1) && (sizeOfSelectedEntitiesDeliveredGrid == 0)) || ((sizeOfSelectedEntitiesOrderedGrid == 0) && (sizeOfSelectedEntitiesDeliveredGrid == 1));
    showProduct.setEnabled(isEnabled);
    showProduct.requestUpdate(true);
    window.requestRibbonRender();
}
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 53 with RibbonGroup

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

the class CompanyDetailsHooksD method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent companyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup suppliers = window.getRibbon().getGroupByName(L_SUPPLIERS);
    RibbonActionItem redirectToFilteredDeliveriesList = suppliers.getItemByName(L_REDIRECT_TO_FILTERED_DELIVERIES_LIST);
    Entity company = companyForm.getEntity();
    boolean isEnabled = Objects.nonNull(company.getId());
    updateButtonState(redirectToFilteredDeliveriesList, isEnabled);
}
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 54 with RibbonGroup

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

the class ProductDetailsHooksPFTD method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup materialFlowRibbonGroup = ribbon.getGroupByName("materialFlow");
    RibbonActionItem showProductAvailabilityRibbonActionItem = materialFlowRibbonGroup.getItemByName("productAvailability");
    Long id = form.getEntityId();
    boolean isEnabled = Objects.nonNull(id);
    showProductAvailabilityRibbonActionItem.setEnabled(isEnabled);
    showProductAvailabilityRibbonActionItem.requestUpdate(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) 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 55 with RibbonGroup

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

the class ProductionTrackingDetailsHooksPFTD method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup materialFlowRibbonGroup = (RibbonGroup) window.getRibbon().getGroupByName(L_MATERIAL_FLOW);
    RibbonActionItem componentAvailabilityRibbonActionItem = (RibbonActionItem) materialFlowRibbonGroup.getItemByName(L_COMPONENT_AVAILABILITY);
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productionTracking = productionTrackingForm.getEntity();
    boolean isDraft = ProductionTrackingStateStringValues.DRAFT.equals(productionTracking.getStringField(ProductionTrackingFields.STATE));
    Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
    if (order == null) {
        return;
    }
    boolean registerQuantityInProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT);
    boolean registerQuantityOutProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT);
    componentAvailabilityRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    componentAvailabilityRibbonActionItem.requestUpdate(true);
}
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

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