use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class PalletBalanceDetailsHooks method changeRibbonState.
private void changeRibbonState(final ViewDefinitionState view, final boolean generated) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup reportGroup = window.getRibbon().getGroupByName("report");
RibbonActionItem generate = reportGroup.getItemByName("generate");
RibbonActionItem print = reportGroup.getItemByName("print");
generate.setEnabled(!generated);
generate.requestUpdate(true);
print.setEnabled(generated);
print.requestUpdate(true);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class MRCForOrderDetailsHooks method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FieldComponent generatedField = (FieldComponent) view.getComponentByReference(CoverageForOrderFields.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 MRCForOrderDetailsHooksOFSPG method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FieldComponent generatedField = (FieldComponent) view.getComponentByReference(CoverageForOrderFields.GENERATED);
boolean isEnabled = "1".equals(generatedField.getFieldValue());
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup coverage = (RibbonGroup) window.getRibbon().getGroupByName(ORDERS_RIBBON_GROUP);
RibbonActionItem generateOrders = (RibbonActionItem) coverage.getItemByName(ORDERS_RIBBON_GROUP_GENERATE_ORDERS);
generateOrders.setMessage("ordersForSubproductsGeneration.ordersForSubproducts.generateFromCoverage.msg");
FormComponent coverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long coverageId = coverageForm.getEntityId();
Entity coverageEntity = coverageForm.getPersistedEntityWithIncludedFormValues();
Entity order = coverageEntity.getBelongsToField(CoverageForOrderFields.ORDER);
List<Entity> coverageOrders = coverageEntity.getHasManyField(MaterialRequirementCoverageFields.COVERAGE_ORDERS);
if (coverageId != null) {
if (ordersForSubproductsGenerationService.hasSubOrders(order) || ordersForSubproductsGenerationService.hasSubOrders(getOrdersIds(coverageEntity))) {
isEnabled = false;
}
}
if (order == null && coverageOrders.isEmpty()) {
isEnabled = false;
}
updateButtonState(generateOrders, isEnabled);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class OrdersForSubproductsHooks method toggleGenerateOrderButton.
private void toggleGenerateOrderButton(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long id = form.getEntityId();
boolean isEnabled = false;
if (Objects.nonNull(id)) {
Entity entity = form.getEntity().getDataDefinition().get(id);
isEnabled = !hasGeneratedOrders(entity);
}
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup group = window.getRibbon().getGroupByName("orders");
RibbonActionItem generateOrders = group.getItemByName("generateOrders");
generateOrders.setMessage("ordersForSubproductsGeneration.ordersForSubproducts.generate.msg");
updateButtonState(generateOrders, isEnabled);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class GenerateMaterialRequirementCoverageHooks method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
boolean saved = orderSuppliesService.checkIfMaterialRequirementCoverageIsSaved(materialRequirementCoverageId);
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);
RibbonGroup reports = (RibbonGroup) window.getRibbon().getGroupByName(L_REPORTS);
RibbonGroup materialAvailability = (RibbonGroup) window.getRibbon().getGroupByName(L_MATERIAL_AVAILABILITY);
RibbonGroup analysis = (RibbonGroup) window.getRibbon().getGroupByName(L_ANALYSIS);
RibbonActionItem generateMaterialRequirementCoverage = (RibbonActionItem) coverage.getItemByName(L_GENERATE_MATERIAL_REQUIREMENT_COVERAGE);
RibbonActionItem printMaterialRequirementCoverage = (RibbonActionItem) coverage.getItemByName(L_PRINT_MATERIAL_REQUIREMENT_COVERAGE);
RibbonActionItem saveMaterialRequirementCoverage = (RibbonActionItem) reports.getItemByName(L_SAVE_MATERIAL_REQUIREMENT_COVERAGE);
RibbonActionItem showMaterialRequirementCoverages = (RibbonActionItem) reports.getItemByName(L_SHOW_MATERIAL_REQUIREMENT_COVERAGES);
RibbonActionItem showReplacementsAvailability = (RibbonActionItem) materialAvailability.getItemByName(L_SHOW_REPLACEMENTS_AVAILABILITY);
RibbonActionItem generateCoverageAnalysis = (RibbonActionItem) analysis.getItemByName(L_GENERATE_COVERAGE_ANALYSIS);
showReplacementsAvailability.setMessage("orderWithMaterialAvailabilityList.materialAvailability.ribbon.message.selectOneRecordWithReplacements");
boolean areSaved = checkIfThereAreSavedMaterialRequirementCoverages();
updateButtonState(generateMaterialRequirementCoverage, !saved);
updateButtonState(printMaterialRequirementCoverage, generated && !saved);
updateButtonState(saveMaterialRequirementCoverage, generated && !saved);
updateButtonState(showMaterialRequirementCoverages, areSaved);
GridComponent grid = (GridComponent) view.getComponentByReference(L_COVERAGE_PRODUCTS);
if (generated && grid.getSelectedEntitiesIds().size() == 1 && isReplacement(grid.getSelectedEntitiesIds().stream().findFirst().get())) {
showReplacementsAvailability.setEnabled(true);
} else {
showReplacementsAvailability.setEnabled(false);
}
showReplacementsAvailability.requestUpdate(true);
if (generated) {
generateCoverageAnalysis.setEnabled(true);
} else {
generateCoverageAnalysis.setEnabled(false);
}
generateCoverageAnalysis.requestUpdate(true);
}
Aggregations