use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class PlannedEventDetailsHooks method actionsButtonProcess.
private void actionsButtonProcess(Entity plannedEvent, ViewDefinitionState view, FieldsForType ftype) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
PlannedEventType type = PlannedEventType.from(plannedEvent);
Ribbon ribbon = window.getRibbon();
RibbonGroup actionsGroup = ribbon.getGroupByName("actionsGroup");
RibbonActionItem addActionsItem = actionsGroup.getItemByName("actions");
if (plannedEvent.getId() == null) {
addActionsItem.setEnabled(false);
addActionsItem.requestUpdate(true);
window.requestRibbonRender();
return;
}
boolean enable = false;
if (type.compareTo(PlannedEventType.REVIEW) == 0) {
enable = true;
} else if (type.compareTo(PlannedEventType.REPAIRS) == 0) {
enable = true;
} else if (type.compareTo(PlannedEventType.EXTERNAL_SERVICE) == 0) {
enable = false;
} else if (type.compareTo(PlannedEventType.ADDITIONAL_WORK) == 0) {
enable = true;
} else if (type.compareTo(PlannedEventType.MANUAL) == 0) {
enable = true;
} else if (type.compareTo(PlannedEventType.METER_READING) == 0) {
enable = false;
} else if (type.compareTo(PlannedEventType.UDT_REVIEW) == 0) {
enable = false;
} else if (type.compareTo(PlannedEventType.AFTER_REVIEW) == 0) {
enable = false;
}
addActionsItem.setEnabled(enable);
addActionsItem.requestUpdate(true);
window.requestRibbonRender();
}
use of com.qcadoo.view.api.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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();
}
Aggregations