use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class ModelCardDetailsHooks method setRibbonEnabled.
private void setRibbonEnabled(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(ModelCardFields.GENERATED);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup generateRibbonGroup = ribbon.getGroupByName(L_GENERATE);
RibbonGroup exportRibbonGroup = ribbon.getGroupByName(L_EXPORT);
RibbonActionItem generateRibbonActionItem = generateRibbonGroup.getItemByName(L_GENERATE);
RibbonActionItem exportRibbonActionItem = exportRibbonGroup.getItemByName(L_PDF);
Long modelCardId = form.getEntityId();
boolean entityIdIsNotNull = Objects.nonNull(modelCardId);
boolean isGenerated = generated.isChecked();
generateRibbonActionItem.setEnabled(entityIdIsNotNull && !isGenerated);
generateRibbonActionItem.requestUpdate(true);
exportRibbonActionItem.setEnabled(entityIdIsNotNull && isGenerated);
exportRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class OrderWithMaterialAvailabilityListHooks method toggleShowAvailabilityButton.
public void toggleShowAvailabilityButton(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup materialAvailability = window.getRibbon().getGroupByName(L_MATERIAL_AVAILABILITY);
RibbonGroup resources = window.getRibbon().getGroupByName(RESOURCES);
RibbonActionItem showAvailability = materialAvailability.getItemByName(L_SHOW_AVAILABILITY);
RibbonActionItem showReplacementsAvailability = materialAvailability.getItemByName(L_SHOW_REPLACEMENTS_AVAILABILITY);
RibbonActionItem showWarehouseResources = resources.getItemByName(SHOW_WAREHOUSE_RESOURCES);
JSONObject obj = view.getJsonContext();
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
if (grid.getSelectedEntitiesIds().size() != 1) {
showAvailability.setEnabled(false);
showReplacementsAvailability.setEnabled(false);
showWarehouseResources.setEnabled(false);
} else {
showAvailability.setEnabled(true);
showWarehouseResources.setEnabled(true);
Entity selected = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY).get(grid.getSelectedEntitiesIds().stream().findFirst().get());
showReplacementsAvailability.setEnabled(selected.getBooleanField(MaterialAvailabilityFields.REPLACEMENT));
}
showAvailability.setMessage("orderWithMaterialAvailabilityList.materialAvailability.ribbon.message.selectOneRecord");
showReplacementsAvailability.setMessage("orderWithMaterialAvailabilityList.materialAvailability.ribbon.message.selectOneRecordWithReplacements");
showWarehouseResources.setMessage("orderWithMaterialAvailabilityList.resources.ribbon.showWarehouseResources.message");
if (obj.has(FROM_TERMINAL)) {
showAvailability.setEnabled(false);
showAvailability.setMessage(null);
showReplacementsAvailability.setEnabled(false);
showReplacementsAvailability.setMessage(null);
showWarehouseResources.setEnabled(false);
showWarehouseResources.setMessage(null);
}
showAvailability.requestUpdate(true);
showReplacementsAvailability.requestUpdate(true);
showWarehouseResources.requestUpdate(true);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class ProductToIssueCorrectionHelperHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity helper = form.getEntity();
FieldComponent locationFromLabel = (FieldComponent) view.getComponentByReference("locationFromLabel");
Entity locationFrom = helper.getBelongsToField("locationFrom");
if (locationFrom != null) {
locationFromLabel.setFieldValue(translationService.translate("productFlowThruDivision.productToIssueCorrectionHelper.locationFrom.label", LocaleContextHolder.getLocale(), locationFrom.getStringField(LocationFields.NUMBER)));
locationFromLabel.setRequired(true);
}
if (helper.getHasManyField("corrections").isEmpty()) {
String idsStr = helper.getStringField("productsToIssueIds");
String[] split = idsStr.split(",");
List<Long> ids = Lists.newArrayList(split).stream().map(Long::valueOf).collect(Collectors.toList());
DataDefinition correctionDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_PRODUCT_TO_ISSUE_CORRECTION);
DataDefinition productToIssueDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_PRODUCTS_TO_ISSUE);
List<Entity> createdCorrections = Lists.newArrayList();
for (Long id : ids) {
Entity productToIssue = productToIssueDD.get(id);
createdCorrections.add(createCorrections(correctionDD, productToIssue));
}
helper.setField("corrections", createdCorrections);
form.setEntity(helper);
} else {
List<Entity> issues = helper.getHasManyField("corrections");
if (issues.stream().allMatch(issue -> issue.getId() != null)) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup group = ribbon.getGroupByName("actions");
RibbonActionItem saveItem = group.getItemByName("correct");
saveItem.setEnabled(false);
saveItem.requestUpdate(true);
}
fillQuantitiesInAdditionalUnit(view);
}
fillUnits(view);
setWarehouseCriteriaModifier(view, helper);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method changeButtonState.
void changeButtonState(final ViewDefinitionState view, final ProgressType progressType, final OrderState orderState) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup progressRibbonGroup = window.getRibbon().getGroupByName(PROGRESS_RIBBON_GROUP_NAME);
boolean isInCorrectionMode = progressType == ProgressType.CORRECTED && !UNSUPPORTED_ORDER_STATES.contains(orderState);
for (RibbonActionItem ribbonActionItem : progressRibbonGroup.getItems()) {
ribbonActionItem.setEnabled(isInCorrectionMode);
ribbonActionItem.requestUpdate(true);
}
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class GenerateBalanceViewHooks method toggleRibbonExportButtons.
private void toggleRibbonExportButtons(final ViewDefinitionState viewState) {
WindowComponent window = (WindowComponent) findComponent(viewState, QcadooViewConstants.L_WINDOW);
if (window == null) {
return;
}
Ribbon ribbon = window.getRibbon();
RibbonGroup genericExportGroup = ribbon.getGroupByName("genericExport");
if (genericExportGroup == null) {
return;
}
FormComponent form = (FormComponent) findComponent(viewState, QcadooViewConstants.L_FORM);
boolean hasGeneratedBalances = form.getEntityId() != null;
for (RibbonActionItem ribbonExportButton : genericExportGroup.getItems()) {
ribbonExportButton.setEnabled(hasGeneratedBalances);
ribbonExportButton.requestUpdate(true);
}
}
Aggregations