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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations