Search in sources :

Example 31 with RibbonGroup

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

Example 32 with RibbonGroup

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

Example 33 with RibbonGroup

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

Example 34 with RibbonGroup

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

Example 35 with RibbonGroup

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