Search in sources :

Example 61 with RibbonGroup

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

the class ProductDetailsViewHooksT method updateRibbonState.

// TODO lupo fix when problem with navigation will be done
public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity product = productForm.getEntity();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup technologies = window.getRibbon().getGroupByName("technologies");
    RibbonActionItem showTechnologiesWithTechnologyGroup = technologies.getItemByName("showTechnologiesWithTechnologyGroup");
    RibbonActionItem showTechnologiesWithProduct = technologies.getItemByName("showTechnologiesWithProduct");
    RibbonActionItem showProductGroupTechnologies = technologies.getItemByName("showProductGroupTechnologies");
    RibbonActionItem showTechnologiesWithFamilyProduct = technologies.getItemByName("showTechnologiesWithFamilyProduct");
    if (product.getId() != null) {
        Entity technologyGroup = product.getBelongsToField("technologyGroup");
        updateButtonState(showTechnologiesWithTechnologyGroup, technologyGroup != null);
        updateButtonState(showTechnologiesWithProduct, true);
        updateButtonState(showProductGroupTechnologies, true);
    } else {
        updateButtonState(showTechnologiesWithTechnologyGroup, false);
        updateButtonState(showTechnologiesWithProduct, false);
        updateButtonState(showProductGroupTechnologies, false);
    }
    Entity parent = product.getBelongsToField(ProductFields.PARENT);
    updateButtonState(showTechnologiesWithFamilyProduct, Objects.nonNull(parent));
}
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 62 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 63 with RibbonGroup

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

the class OrderDetailsHooksCNFM method updateViewCostsButtonState.

public void updateViewCostsButtonState(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup materials = window.getRibbon().getGroupByName("materials");
    RibbonActionItem viewCosts = materials.getItemByName("viewCosts");
    Long orderId = orderForm.getEntityId();
    if (orderId != null) {
        Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(orderId);
        if ((order != null) && orderStateService.isSynchronized(order)) {
            Entity technology = order.getBelongsToField(TECHNOLOGY);
            if ((technology != null)) {
                viewCosts.setEnabled(true);
                viewCosts.requestUpdate(true);
                return;
            }
        }
    }
    viewCosts.setEnabled(false);
    viewCosts.requestUpdate(true);
}
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 64 with RibbonGroup

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

the class MasterOrderDetailsHooks method toggleGenerateButton.

private void toggleGenerateButton(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName(L_ORDERS);
    RibbonActionItem createOrder = (RibbonActionItem) orders.getItemByName("generateOrders");
    createOrder.setMessage("qcadooView.ribbon.orders.generateOrders.message");
    GridComponent masterOrderProductsGrid = (GridComponent) view.getComponentByReference(MasterOrderFields.MASTER_ORDER_PRODUCTS);
    createOrder.setEnabled(!masterOrderProductsGrid.getSelectedEntities().isEmpty());
    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 65 with RibbonGroup

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

the class MasterOrderPositionsListHooks method disableButton.

public void disableButton(final ViewDefinitionState view) {
    GridComponent masterOrderPositionComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup ordersRibbonGroup = window.getRibbon().getGroupByName(L_ORDERS);
    RibbonGroup groupingRibbonGroup = window.getRibbon().getGroupByName("grouping");
    RibbonActionItem createOrderRibbonActionItem = ordersRibbonGroup.getItemByName(L_CREATE_ORDER);
    RibbonActionItem showGroupedByProduct = groupingRibbonGroup.getItemByName("showGroupedByProduct");
    RibbonActionItem showGroupedByProductAndDate = groupingRibbonGroup.getItemByName("showGroupedByProductAndDate");
    RibbonActionItem generateOrders = ordersRibbonGroup.getItemByName("generateOrders");
    generateOrders.setMessage("qcadooView.ribbon.orders.generateOrders.message");
    List<Entity> selectedEntities = masterOrderPositionComponent.getSelectedEntities();
    if (selectedEntities.isEmpty()) {
        generateOrders.setEnabled(false);
        showGroupedByProduct.setEnabled(false);
        showGroupedByProductAndDate.setEnabled(false);
    } else {
        generateOrders.setEnabled(true);
        showGroupedByProduct.setEnabled(true);
        showGroupedByProductAndDate.setEnabled(true);
    }
    generateOrders.requestUpdate(true);
    showGroupedByProduct.setMessage("masterOrders.masterOrderPositionsList.window.ribbon.grouping.showGroupedByProduct.description");
    showGroupedByProduct.requestUpdate(true);
    showGroupedByProductAndDate.setMessage("masterOrders.masterOrderPositionsList.window.ribbon.grouping.showGroupedByProductAndDate.description");
    showGroupedByProductAndDate.requestUpdate(true);
    boolean isEnabled = (selectedEntities.size() == 1);
    createOrderRibbonActionItem.setEnabled(isEnabled);
    createOrderRibbonActionItem.requestUpdate(true);
    window.requestRibbonRender();
    createOrderRibbonActionItem.setMessage("masterOrders.masterOrder.masterOrdersPosition.lessEntitiesSelectedThanAllowed");
}
Also used : Entity(com.qcadoo.model.api.Entity) 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)

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