Search in sources :

Example 26 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class MasterOrdersMaterialRequirementDetailsHooks method setRibbonEnabled.

private void setRibbonEnabled(final ViewDefinitionState view) {
    FormComponent masterOrdersMaterialRequirementForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.GENERATED);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup generateRibbonGroup = ribbon.getGroupByName(L_GENERATE);
    RibbonActionItem generateRibbonActionItem = generateRibbonGroup.getItemByName(L_GENERATE_MASTER_ORDERS_MATERIAL_REQUIREMENT);
    Long masterOrdersMaterialRequirementId = masterOrdersMaterialRequirementForm.getEntityId();
    boolean isEnabled = Objects.nonNull(masterOrdersMaterialRequirementId);
    boolean isGenerated = generatedCheckBox.isChecked();
    generateRibbonActionItem.setEnabled(isEnabled && !isGenerated);
    generateRibbonActionItem.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) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 27 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class SalesPlanDetailsHooks method setRibbonEnabled.

private void setRibbonEnabled(final ViewDefinitionState view) {
    FormComponent salesPlanForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity salesPlan = salesPlanForm.getEntity();
    String state = salesPlan.getStringField(SalesPlanFields.STATE);
    GridComponent productsGrid = (GridComponent) view.getComponentByReference(SalesPlanFields.PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup salesPlanMaterialRequirementRibbonGroup = ribbon.getGroupByName(L_SALES_PLAN_MATERIAL_REQUIREMENT);
    RibbonActionItem createSalesPlanMaterialRequirementRibbonActionItem = salesPlanMaterialRequirementRibbonGroup.getItemByName(L_CREATE_SALES_PLAN_MATERIAL_REQUIREMENT);
    RibbonActionItem openPositionsImportPageRibbonActionItem = window.getRibbon().getGroupByName(L_IMPORT).getItemByName(L_OPEN_POSITIONS_IMPORT_PAGE);
    RibbonGroup technologiesRibbonGroup = ribbon.getGroupByName("technologies");
    RibbonActionItem useOtherTechnologyActionItem = technologiesRibbonGroup.getItemByName("useOtherTechnology");
    RibbonActionItem fillTechnologyActionItem = technologiesRibbonGroup.getItemByName("fillTechnology");
    boolean isEnabled = Objects.nonNull(salesPlanForm.getEntityId()) && state.equals(SalesPlanStateStringValues.DRAFT);
    createSalesPlanMaterialRequirementRibbonActionItem.setEnabled(isEnabled);
    createSalesPlanMaterialRequirementRibbonActionItem.requestUpdate(true);
    openPositionsImportPageRibbonActionItem.setEnabled(isEnabled);
    openPositionsImportPageRibbonActionItem.requestUpdate(true);
    useOtherTechnologyActionItem.setEnabled(isEnabled && !productsGrid.getSelectedEntitiesIds().isEmpty() && productsGrid.getSelectedEntities().stream().noneMatch(e -> e.getStringField(TECHNOLOGY_NUMBER) == null) && productsGrid.getSelectedEntities().stream().map(e -> e.getStringField(TECHNOLOGY_NUMBER)).distinct().count() == 1L);
    useOtherTechnologyActionItem.requestUpdate(true);
    fillTechnologyActionItem.setEnabled(isEnabled && !productsGrid.getSelectedEntitiesIds().isEmpty() && productsGrid.getSelectedEntities().stream().allMatch(e -> e.getStringField(TECHNOLOGY_NUMBER) == null && e.getStringField("productFamily") != null) && productsGrid.getSelectedEntities().stream().map(e -> e.getStringField("productFamily")).distinct().count() == 1L);
    fillTechnologyActionItem.requestUpdate(true);
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) SalesPlanFields(com.qcadoo.mes.masterOrders.constants.SalesPlanFields) GridComponent(com.qcadoo.view.api.components.GridComponent) Objects(java.util.Objects) Entity(com.qcadoo.model.api.Entity) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Service(org.springframework.stereotype.Service) SalesPlanStateStringValues(com.qcadoo.mes.masterOrders.states.constants.SalesPlanStateStringValues) FormComponent(com.qcadoo.view.api.components.FormComponent) 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) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 28 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class SalesPlanMaterialRequirementDetailsHooks method setRibbonEnabled.

private void setRibbonEnabled(final ViewDefinitionState view) {
    FormComponent salesPlanMaterialRequirementForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent salesPlanMaterialRequirementProductsGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(SalesPlanMaterialRequirementFields.GENERATED);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup generateRibbonGroup = ribbon.getGroupByName(L_GENERATE);
    RibbonGroup deliveriesRibbonGroup = ribbon.getGroupByName(L_DELIVERIES);
    RibbonGroup technologiesRibbonGroup = ribbon.getGroupByName(TECHNOLOGIES);
    RibbonActionItem generateRibbonActionItem = generateRibbonGroup.getItemByName(L_GENERATE_SALES_PLAN_MATERIAL_REQUIREMENT);
    RibbonActionItem createDeliveryRibbonActionItem = deliveriesRibbonGroup.getItemByName(L_CREATE_DELIVERY);
    RibbonActionItem showSalesPlanDeliveriesRibbonActionItem = deliveriesRibbonGroup.getItemByName(SHOW_SALES_PLAN_DELIVERIES);
    RibbonActionItem showTechnologiesWithUsingProductRibbonActionItem = technologiesRibbonGroup.getItemByName(SHOW_TECHNOLOGIES_WITH_USING_PRODUCT);
    Long salesPlanMaterialRequirementId = salesPlanMaterialRequirementForm.getEntityId();
    boolean isEnabled = Objects.nonNull(salesPlanMaterialRequirementId);
    boolean isGenerated = generatedCheckBox.isChecked();
    boolean isSalesPlanMaterialRequirementProductsSelected = !salesPlanMaterialRequirementProductsGrid.getSelectedEntities().isEmpty();
    generateRibbonActionItem.setEnabled(isEnabled && !isGenerated);
    generateRibbonActionItem.requestUpdate(true);
    createDeliveryRibbonActionItem.setEnabled(isEnabled && isGenerated && isSalesPlanMaterialRequirementProductsSelected);
    createDeliveryRibbonActionItem.requestUpdate(true);
    showTechnologiesWithUsingProductRibbonActionItem.setEnabled(salesPlanMaterialRequirementProductsGrid.getSelectedEntities().size() == 1);
    showTechnologiesWithUsingProductRibbonActionItem.requestUpdate(true);
    showSalesPlanDeliveriesRibbonActionItem.setEnabled(isEnabled);
    showSalesPlanDeliveriesRibbonActionItem.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) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 29 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class MasterOrderDetailsListeners method onProductsChange.

public void onProductsChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent masterOrderProductsGrid = (GridComponent) view.getComponentByReference(MasterOrderFields.MASTER_ORDER_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = window.getRibbon().getGroupByName("orders");
    RibbonActionItem createOrder = orders.getItemByName("createOrder");
    if (masterOrderProductsGrid.getSelectedEntities().isEmpty()) {
        createOrder.setEnabled(false);
    } else {
        createOrder.setEnabled(masterOrderProductsGrid.getSelectedEntities().size() == 1);
    }
    createOrder.requestUpdate(true);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 30 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class ProductDetailsHooksMFR method setEnabledForStorageLocationHistory.

public void setEnabledForStorageLocationHistory(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName("storageLocationHistory");
    RibbonActionItem history = group.getItemByName("showHistory");
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    history.setEnabled(form.getEntityId() != null);
    history.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