Search in sources :

Example 26 with Ribbon

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);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 27 with Ribbon

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);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) OptionalLong(java.util.OptionalLong) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 28 with Ribbon

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);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 29 with Ribbon

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();
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Test(org.junit.Test)

Example 30 with Ribbon

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);
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

Ribbon (com.qcadoo.view.api.ribbon.Ribbon)40 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)37 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)36 WindowComponent (com.qcadoo.view.api.components.WindowComponent)31 FormComponent (com.qcadoo.view.api.components.FormComponent)16 Entity (com.qcadoo.model.api.Entity)10 GridComponent (com.qcadoo.view.api.components.GridComponent)8 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)4 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)3 Optional (com.google.common.base.Optional)2 Lists (com.google.common.collect.Lists)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 FieldComponent (com.qcadoo.view.api.components.FieldComponent)2 BigDecimal (java.math.BigDecimal)2 Arrays (java.util.Arrays)2 Service (org.springframework.stereotype.Service)2 HashMultimap (com.google.common.collect.HashMultimap)1