Search in sources :

Example 36 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent 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 37 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent 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 38 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class OperationDurationInOrderDetailsHooksOFSPG method setSaveButtonState.

private void setSaveButtonState(final ViewDefinitionState view) {
    WindowComponent windowComponent = ((WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW));
    RibbonActionItem ribbonActionItem = windowComponent.getRibbon().getGroupByName("subOrders").getItemByName(CoverageForOrderFieldsOFSPG.SAVE_DATE_IN_SUBORDERS);
    String dateStart = (String) view.getComponentByReference(CoverageForOrderFieldsOFSPG.CALCULATED_START_ALL_ORDERS).getFieldValue();
    String dateEnd = (String) view.getComponentByReference(CoverageForOrderFieldsOFSPG.CALCULATED_FINISH_ALL_ORDERS).getFieldValue();
    if (dateStart.isEmpty() || dateEnd.isEmpty()) {
        ribbonActionItem.setEnabled(false);
    } else {
        ribbonActionItem.setEnabled(true);
    }
    ribbonActionItem.requestUpdate(true);
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 39 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent 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 40 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent 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)

Aggregations

WindowComponent (com.qcadoo.view.api.components.WindowComponent)105 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)93 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)75 FormComponent (com.qcadoo.view.api.components.FormComponent)51 Entity (com.qcadoo.model.api.Entity)46 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)31 GridComponent (com.qcadoo.view.api.components.GridComponent)28 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 EntityTree (com.qcadoo.model.api.EntityTree)4 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)3 JSONObject (org.json.JSONObject)3 Optional (com.google.common.base.Optional)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 TreeComponent (com.qcadoo.view.api.components.TreeComponent)2 Date (java.util.Date)2 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1