use of com.qcadoo.view.api.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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.ribbon.RibbonGroup 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);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class OrderDetailsRibbonHelper method getRibbonItem.
public RibbonActionItem getRibbonItem(final ViewDefinitionState view, final String ribbonGroupName, final String ribbonItemName) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup ribbonGroup = ribbon.getGroupByName(ribbonGroupName);
if (Objects.isNull(ribbonGroup)) {
return null;
}
return ribbonGroup.getItemByName(ribbonItemName);
}
Aggregations