use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class TechnologyDetailsHooksCNFM method updateViewCostsButtonState.
public void updateViewCostsButtonState(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup materials = window.getRibbon().getGroupByName("materials");
RibbonActionItem viewCosts = materials.getItemByName("viewCosts");
viewCosts.setEnabled(orderForm.getEntityId() != null);
viewCosts.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class DeliveryDetailsHooks method updateRelatedDeliveryButtonsState.
private void updateRelatedDeliveryButtonsState(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_RELATED_DELIVERY);
RibbonActionItem createRelatedDelivery = reports.getItemByName(L_CREATE_RELATED_DELIVERY);
RibbonActionItem showRelatedDelivery = reports.getItemByName(L_SHOW_RELATED_DELIVERIES);
if (Objects.isNull(deliveryId)) {
return;
}
Entity delivery = deliveriesService.getDelivery(deliveryId);
List<Entity> relatedDeliveries = delivery.getHasManyField(DeliveryFields.RELATED_DELIVERIES);
boolean received = DeliveryState.RECEIVED.getStringValue().equals(delivery.getStringField(DeliveryFields.STATE));
boolean receiveConfirmWaiting = DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(delivery.getStringField(DeliveryFields.STATE));
boolean created = (Objects.nonNull(relatedDeliveries) && !relatedDeliveries.isEmpty());
updateButtonState(createRelatedDelivery, (received || receiveConfirmWaiting) && !created);
updateButtonState(showRelatedDelivery, (received || receiveConfirmWaiting) && created);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class DeliveryDetailsHooks method updateAssignStorageLocationsButton.
private void updateAssignStorageLocationsButton(final ViewDefinitionState view) {
FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup group = ribbon.getGroupByName(L_DELIVERY_POSITIONS);
RibbonActionItem assignStorageLocations = group.getItemByName(ASSIGN_STORAGE_LOCATIONS);
Long deliveryId = deliveryForm.getEntityId();
boolean enabled = false;
if (Objects.nonNull(deliveryId)) {
Entity delivery = deliveriesService.getDelivery(deliveryId);
String state = delivery.getStringField(DeliveryFields.STATE);
enabled = !DeliveryState.RECEIVED.getStringValue().equals(state) && !DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(state) && !DeliveryState.DECLINED.getStringValue().equals(state);
}
updateButtonState(assignStorageLocations, enabled);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class MasterOrderDetailsHooks method ribbonRender.
public void ribbonRender(final ViewDefinitionState view) {
GridComponent masterOrderProductsGrid = (GridComponent) view.getComponentByReference(MasterOrderFields.MASTER_ORDER_PRODUCTS);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName(L_ORDERS);
RibbonActionItem createOrder = (RibbonActionItem) orders.getItemByName(L_CREATE_ORDER);
if (masterOrderProductsGrid.getSelectedEntities().isEmpty()) {
createOrder.setEnabled(false);
} else
createOrder.setEnabled(masterOrderProductsGrid.getSelectedEntities().size() == 1);
if (PluginUtils.isEnabled("goodFood") && !masterOrderProductsGrid.getEntities().isEmpty()) {
createOrder.setEnabled(true);
} else {
createOrder.setMessage("masterOrders.order.ribbon.message.selectOneProduct");
}
createOrder.requestUpdate(true);
toggleGenerateButton(view);
window.requestRibbonRender();
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class MasterOrdersMaterialRequirementDetailsHooks method setRibbonEnabled.
private void setRibbonEnabled(final ViewDefinitionState view) {
FormComponent masterOrdersMaterialRequirementForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.GENERATED);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup generateRibbonGroup = ribbon.getGroupByName(L_GENERATE);
RibbonActionItem generateRibbonActionItem = generateRibbonGroup.getItemByName(L_GENERATE_MASTER_ORDERS_MATERIAL_REQUIREMENT);
Long masterOrdersMaterialRequirementId = masterOrdersMaterialRequirementForm.getEntityId();
boolean isEnabled = Objects.nonNull(masterOrdersMaterialRequirementId);
boolean isGenerated = generatedCheckBox.isChecked();
generateRibbonActionItem.setEnabled(isEnabled && !isGenerated);
generateRibbonActionItem.requestUpdate(true);
}
Aggregations