use of com.qcadoo.view.api.ribbon.Ribbon 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.Ribbon 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.Ribbon 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);
}
}
use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.
the class WorkPlansListViewTest method shouldBuildFromViewDefinitionState.
@Test
public final void shouldBuildFromViewDefinitionState() {
// given
ViewDefinitionState viewDefinitionState = mock(ViewDefinitionState.class);
given(viewDefinitionState.getComponentByReference(QcadooViewConstants.L_WINDOW)).willReturn(windowComponent);
Ribbon ribbon = mock(Ribbon.class);
given((windowComponent).getRibbon()).willReturn(ribbon);
RibbonGroup actionsRibbonGroup = mock(RibbonGroup.class);
given(ribbon.getGroupByName("actions")).willReturn(actionsRibbonGroup);
given(actionsRibbonGroup.getItemByName("delete")).willReturn(deleteButton);
given(viewDefinitionState.getComponentByReference(QcadooViewConstants.L_GRID)).willReturn(workPlansGrid);
// when
WorkPlansListView workPlansListView = WorkPlansListView.from(viewDefinitionState);
workPlansListView.setUpDeleteButton(true, null);
workPlansListView.getSelectedWorkPlans();
// then
verify(deleteButton).setEnabled(anyBoolean());
verify(workPlansGrid).getSelectedEntities();
}
use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.
the class DetailedProductionCountingAndProgressListHooksBPC method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
String releaseOfMaterials = parameterService.getParameter().getStringField(ParameterFieldsPC.RELEASE_OF_MATERIALS);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup issueRibbonGroup = ribbon.getGroupByName(L_ISSUE);
RibbonActionItem resourceIssueRibbonActionItem = issueRibbonGroup.getItemByName(L_RESOURCE_ISSUE);
if (!ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials)) {
resourceIssueRibbonActionItem.setEnabled(false);
resourceIssueRibbonActionItem.setMessage("basicProductionCounting.detailedProductionCountingAndProgressList.resourceIssue.description");
resourceIssueRibbonActionItem.requestUpdate(true);
}
}
Aggregations