use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class UserDetailsHooksMF method setupRibbonForAdmin.
public void setupRibbonForAdmin(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
if (!securityService.hasCurrentUserRole("ROLE_SUPERADMIN") && securityService.hasCurrentUserRole("ROLE_ADMIN")) {
RibbonActionItem saveActionItem = window.getRibbon().getGroupByName("actions").getItemByName("save");
saveActionItem.setEnabled(true);
saveActionItem.requestUpdate(true);
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OperationalTasksDetailsHooks method disableButtons.
public void disableButtons(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
FieldComponent typeField = (FieldComponent) view.getComponentByReference(OperationalTaskFields.TYPE);
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.ORDER);
LookupComponent technologyOperationComponentLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.TECHNOLOGY_OPERATION_COMPONENT);
String type = (String) typeField.getFieldValue();
boolean isOperationalTaskTypeExecutionOperationInOrder = operationalTasksService.isOperationalTaskTypeExecutionOperationInOrder(type);
boolean isOrderSelected = !Objects.isNull(orderLookup.getEntity());
boolean isTechnologyOperationComponentSelected = !Objects.isNull(technologyOperationComponentLookup.getEntity());
RibbonGroup order = window.getRibbon().getGroupByName(L_ORDER);
RibbonGroup technologyOperationComponent = window.getRibbon().getGroupByName(L_TECHNOLOGY_OPERATION_COMPONENT);
RibbonGroup operationalTasks = window.getRibbon().getGroupByName(L_OPERATIONAL_TASKS);
RibbonActionItem showOrder = order.getItemByName(L_SHOW_ORDER);
RibbonActionItem showOperationParameters = technologyOperationComponent.getItemByName(L_SHOW_OPERATION_PARAMETERS);
RibbonActionItem showOperationalTasksWithOrder = operationalTasks.getItemByName(L_SHOW_OPERATIONAL_TASKS_WITH_ORDER);
showOrder.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected);
showOrder.requestUpdate(true);
showOperationParameters.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected && isTechnologyOperationComponentSelected);
showOperationParameters.requestUpdate(true);
showOperationalTasksWithOrder.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected);
showOperationalTasksWithOrder.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderDetailsHooks method disabledRibbonWhenOrderIsSynchronized.
public void disabledRibbonWhenOrderIsSynchronized(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
List<RibbonGroup> ribbonGroups = ribbon.getGroups();
Long orderId = orderForm.getEntityId();
if (Objects.isNull(orderId)) {
return;
}
Entity order = orderService.getOrder(orderId);
if (orderStateService.isSynchronized(order)) {
return;
}
for (RibbonGroup ribbonGroup : ribbonGroups) {
for (RibbonActionItem ribbonActionItem : ribbonGroup.getItems()) {
ribbonActionItem.setEnabled(false);
ribbonActionItem.requestUpdate(true);
}
}
RibbonActionItem refreshRibbonActionItem = ribbon.getGroupByName(L_ORDER_DETAILS_ACTIONS).getItemByName(L_REFRESH);
RibbonActionItem backRibbonActionItem = ribbon.getGroupByName(L_NAVIGATION).getItemByName(L_BACK);
refreshRibbonActionItem.setEnabled(true);
backRibbonActionItem.setEnabled(true);
refreshRibbonActionItem.requestUpdate(true);
backRibbonActionItem.requestUpdate(true);
orderForm.setFormEnabled(false);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderPacksSingleOrderListHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(OrdersConstants.MODEL_ORDER);
Entity order = form.getPersistedEntityWithIncludedFormValues();
String orderState = order.getStringField(OrderFields.STATE);
if (OrderState.COMPLETED.getStringValue().equals(orderState) || OrderState.DECLINED.getStringValue().equals(orderState) || OrderState.ABANDONED.getStringValue().equals(orderState) || OrderState.PENDING.getStringValue().equals(orderState)) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
grid.setEditable(false);
grid.setEnabled(false);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonActionItem generateOrderPacks = ribbon.getGroupByName("orderPacks").getItemByName("generateOrderPacks");
RibbonActionItem actionsNew = ribbon.getGroupByName(ACTIONS).getItemByName("new");
generateOrderPacks.setEnabled(false);
generateOrderPacks.requestUpdate(true);
actionsNew.setEnabled(false);
actionsNew.requestUpdate(true);
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderTechnologicalProcessDetailsHooks method updateRibbonState.
private void updateRibbonState(final ViewDefinitionState view, final Entity orderTechnologicalProcess) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actionsGroup = window.getRibbon().getGroupByName(L_ACTIONS);
RibbonActionItem deleteActionItem = actionsGroup.getItemByName(L_DELETE);
Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
boolean isOrderStateValid = !checkOrderState(order);
deleteActionItem.setEnabled(isOrderStateValid);
deleteActionItem.requestUpdate(true);
}
Aggregations