use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class MaterialRequirementCoverageDetailsHooks method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FieldComponent generatedField = (FieldComponent) view.getComponentByReference(MaterialRequirementCoverageFields.GENERATED);
boolean generated = "1".equals(generatedField.getFieldValue());
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup coverage = (RibbonGroup) window.getRibbon().getGroupByName(L_COVERAGE);
RibbonActionItem printMaterialRequirementCoverage = (RibbonActionItem) coverage.getItemByName(L_PRINT_MATERIAL_REQUIREMENT_COVERAGE);
updateButtonState(printMaterialRequirementCoverage, generated);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class CopyOfTechnologyHooks method disableRibbonItem.
private void disableRibbonItem(final ViewDefinitionState view, final Entity order) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup technology = ribbon.getGroupByName(L_TECHNOLOGY);
RibbonGroup status = ribbon.getGroupByName(L_STATUS);
RibbonActionItem clearAndLoadPatternTechnology = technology.getItemByName(L_CLEAR_AND_LOAD_PATTERN_TECHNOLOGY);
RibbonActionItem checkTechnology = status.getItemByName(L_CHECK_TECHNOLOGY);
String state = order.getStringField(OrderFields.STATE);
if (!OrderState.PENDING.getStringValue().equals(state)) {
clearAndLoadPatternTechnology.setEnabled(false);
clearAndLoadPatternTechnology.requestUpdate(true);
checkTechnology.setEnabled(false);
checkTechnology.requestUpdate(true);
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderPackDetailsHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) {
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderPackFields.ORDER);
Entity order = orderLookup.getEntity();
FieldComponent orderQuantity = (FieldComponent) view.getComponentByReference("orderQuantity");
FieldComponent sumQuantityOrderPacksField = (FieldComponent) view.getComponentByReference("sumQuantityOrderPacks");
FieldComponent orderQuantityUnit = (FieldComponent) view.getComponentByReference("orderQuantityUnit");
FieldComponent sumQuantityOrderPacksUnit = (FieldComponent) view.getComponentByReference("sumQuantityOrderPacksUnit");
FieldComponent quantityUnit = (FieldComponent) view.getComponentByReference("quantityUnit");
if (order != null) {
String orderState = order.getStringField(OrderFields.STATE);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (OrderState.COMPLETED.getStringValue().equals(orderState) || OrderState.DECLINED.getStringValue().equals(orderState) || OrderState.ABANDONED.getStringValue().equals(orderState) || OrderState.PENDING.getStringValue().equals(orderState)) {
form.setFormEnabled(false);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonActionItem actionsSave = ribbon.getGroupByName(ACTIONS).getItemByName("save");
RibbonActionItem actionsSaveNew = ribbon.getGroupByName(ACTIONS).getItemByName("saveNew");
RibbonActionItem actionsSaveBack = ribbon.getGroupByName(ACTIONS).getItemByName("saveBack");
actionsSave.setEnabled(false);
actionsSave.requestUpdate(true);
actionsSaveNew.setEnabled(false);
actionsSaveNew.requestUpdate(true);
actionsSaveBack.setEnabled(false);
actionsSaveBack.requestUpdate(true);
}
orderQuantity.setFieldValue(numberService.format(order.getField(OrderFields.PLANNED_QUANTITY)));
FieldComponent quantityField = (FieldComponent) view.getComponentByReference(OrderPackFields.QUANTITY);
BigDecimal sumQuantityOrderPacks = orderPackService.getSumQuantityOrderPacksForOrderWithoutPack(order, form.getEntityId());
Either<Exception, Optional<BigDecimal>> eitherNumber = BigDecimalUtils.tryParseAndIgnoreSeparator((String) quantityField.getFieldValue(), LocaleContextHolder.getLocale());
if (eitherNumber.isRight() && eitherNumber.getRight().isPresent()) {
sumQuantityOrderPacks = sumQuantityOrderPacks.add(eitherNumber.getRight().get(), numberService.getMathContext());
}
sumQuantityOrderPacksField.setFieldValue(numberService.format(sumQuantityOrderPacks));
String unit = order.getBelongsToField(OrderFields.PRODUCT).getStringField(ProductFields.UNIT);
orderQuantityUnit.setFieldValue(unit);
sumQuantityOrderPacksUnit.setFieldValue(unit);
quantityUnit.setFieldValue(unit);
} else {
orderQuantity.setFieldValue(null);
sumQuantityOrderPacksField.setFieldValue(null);
orderQuantityUnit.setFieldValue(null);
sumQuantityOrderPacksUnit.setFieldValue(null);
quantityUnit.setFieldValue(null);
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderTechnologicalProcessesListHooks method updateRibbonState.
private void updateRibbonState(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup orderTechnologicalProcessesGroup = window.getRibbon().getGroupByName(L_ORDER_TECHNOLOGICAL_PROCESSES);
RibbonGroup orderTechnologicalProcessWastesGroup = window.getRibbon().getGroupByName(L_ORDER_TECHNOLOGICAL_PROCESS_WASTES);
RibbonActionItem divideOrderTechnologicalProcessActionItem = orderTechnologicalProcessesGroup.getItemByName(L_DIVIDE_ORDER_TECHNOLOGICAL_PROCESS);
RibbonActionItem createOrderTechnologicalProcessWasteActionItem = orderTechnologicalProcessWastesGroup.getItemByName(L_CREATE_ORDER_TECHNOLOGICAL_PROCESS_WASTE);
GridComponent orderTechnologicalProcessesGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> orderTechnologicalProcessesIds = orderTechnologicalProcessesGrid.getSelectedEntitiesIds();
String message = null;
boolean isOrderTechnologicalProcessSelected = orderTechnologicalProcessesIds.size() == 1;
boolean isOrderStateValid = false;
boolean isOrderTechnologicalProcessFilled = false;
if (isOrderTechnologicalProcessSelected) {
Long orderTechnologicalProcessId = orderTechnologicalProcessesIds.stream().findFirst().get();
Entity orderTechnologicalProcess = orderTechnologicalProcessService.getOrderTechnologicalProcess(orderTechnologicalProcessId);
if (Objects.nonNull(orderTechnologicalProcess)) {
Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
Date date = orderTechnologicalProcess.getDateField(OrderTechnologicalProcessFields.DATE);
Entity worker = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.WORKER);
if (Objects.nonNull(order)) {
isOrderStateValid = !orderTechnologicalProcessService.checkOrderState(order);
}
if (isOrderStateValid) {
isOrderTechnologicalProcessFilled = Objects.nonNull(date) && Objects.nonNull(worker);
if (!isOrderTechnologicalProcessFilled) {
message = "orders.ribbon.message.orderTechnologicalProcessNotFilled";
}
} else {
message = "orders.ribbon.message.canNotCreateOrderTechnologicalProcessWaste";
}
}
}
divideOrderTechnologicalProcessActionItem.setEnabled(isOrderTechnologicalProcessSelected && isOrderStateValid);
divideOrderTechnologicalProcessActionItem.requestUpdate(true);
createOrderTechnologicalProcessWasteActionItem.setEnabled(isOrderTechnologicalProcessSelected && isOrderStateValid && isOrderTechnologicalProcessFilled);
createOrderTechnologicalProcessWasteActionItem.setMessage(message);
createOrderTechnologicalProcessWasteActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductDetailsViewHooksO method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity product = productForm.getEntity();
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName("orders");
RibbonActionItem showOrdersWithProductMain = (RibbonActionItem) orders.getItemByName("showOrdersWithProductMain");
RibbonActionItem showOrdersWithProductPlanned = (RibbonActionItem) orders.getItemByName("showOrdersWithProductPlanned");
if (product.getId() != null) {
updateButtonState(showOrdersWithProductMain, true);
updateButtonState(showOrdersWithProductPlanned, true);
return;
}
updateButtonState(showOrdersWithProductMain, false);
updateButtonState(showOrdersWithProductPlanned, false);
}
Aggregations