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