Search in sources :

Example 56 with RibbonGroup

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

Example 57 with RibbonGroup

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) JSONObject(org.json.JSONObject) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 58 with RibbonGroup

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);
}
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 59 with RibbonGroup

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

Example 60 with RibbonGroup

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);
    }
}
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)

Aggregations

RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)92 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)86 WindowComponent (com.qcadoo.view.api.components.WindowComponent)75 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)37 FormComponent (com.qcadoo.view.api.components.FormComponent)36 Entity (com.qcadoo.model.api.Entity)34 GridComponent (com.qcadoo.view.api.components.GridComponent)23 FieldComponent (com.qcadoo.view.api.components.FieldComponent)9 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)3 LookupComponent (com.qcadoo.view.api.components.LookupComponent)3 JSONObject (org.json.JSONObject)3 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)2 Optional (com.google.common.base.Optional)1 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1