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));
}
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();
}
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);
}
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);
}
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");
}
Aggregations