use of com.qcadoo.view.api.components.WindowComponent 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.components.WindowComponent 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.components.WindowComponent 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");
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class MatchingChangeoverNormsDetailsListeners method enabledButtonAfterSelectionTechnologies.
public void enabledButtonAfterSelectionTechnologies(final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) {
WindowComponent window = (WindowComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem matchingChangeoverNorm = window.getRibbon().getGroupByName("matching").getItemByName("matchingChangeoverNorm");
Entity fromTechnology = ((LookupComponent) viewDefinitionState.getComponentByReference(MATCHING_FROM_TECHNOLOGY)).getEntity();
Entity toTechnology = ((LookupComponent) viewDefinitionState.getComponentByReference(MATCHING_TO_TECHNOLOGY)).getEntity();
if ((fromTechnology == null) || (toTechnology == null)) {
matchingChangeoverNorm.setEnabled(false);
} else {
matchingChangeoverNorm.setEnabled(true);
}
matchingChangeoverNorm.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrderDetailsViewHooks method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FieldComponent productionLineField = (FieldComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
LookupComponent lineChangeoverNormLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.LINE_CHANGEOVER_NORM);
FieldComponent previousOrderTechnologyGroupNumberField = (FieldComponent) view.getComponentByReference("previousOrderTechnologyGroupNumber");
FieldComponent technologyGroupNumberField = (FieldComponent) view.getComponentByReference("technologyGroupNumber");
FieldComponent previousOrderTechnologyNumberField = (FieldComponent) view.getComponentByReference("previousOrderTechnologyNumber");
FieldComponent technologyNumberField = (FieldComponent) view.getComponentByReference("technologyNumber");
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup orders = window.getRibbon().getGroupByName("orders");
RibbonGroup lineChangeoverNorms = window.getRibbon().getGroupByName("lineChangeoverNorms");
RibbonActionItem showPreviousOrder = orders.getItemByName("showPreviousOrder");
RibbonActionItem showBestFittingLineChangeoverNorm = lineChangeoverNorms.getItemByName("showBestFittingLineChangeoverNorm");
RibbonActionItem showChangeoverNormForGroup = lineChangeoverNorms.getItemByName("showLineChangeoverNormForGroup");
RibbonActionItem showChangeoverNormForTechnology = lineChangeoverNorms.getItemByName("showLineChangeoverNormForTechnology");
Entity productionLine = lineChangeoverNormsForOrdersService.getProductionLineFromDB((Long) productionLineField.getFieldValue());
boolean hasDefinedPreviousOrder = !previousOrderLookup.isEmpty();
updateButtonState(showPreviousOrder, hasDefinedPreviousOrder);
boolean hasMatchingChangeoverNorm = !lineChangeoverNormLookup.isEmpty();
updateButtonState(showBestFittingLineChangeoverNorm, hasMatchingChangeoverNorm);
if (StringUtils.isEmpty((String) previousOrderTechnologyGroupNumberField.getFieldValue()) || StringUtils.isEmpty((String) technologyGroupNumberField.getFieldValue())) {
updateButtonState(showChangeoverNormForGroup, false);
} else {
Entity fromTechnologyGroup = lineChangeoverNormsForOrdersService.getTechnologyGroupByNumberFromDB((String) previousOrderTechnologyGroupNumberField.getFieldValue());
Entity toTechnologyGroup = lineChangeoverNormsForOrdersService.getTechnologyGroupByNumberFromDB((String) technologyGroupNumberField.getFieldValue());
if ((changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyGroupWithLine(fromTechnologyGroup, toTechnologyGroup, productionLine) == null) && (changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyGroupWithLine(fromTechnologyGroup, toTechnologyGroup, null) == null)) {
updateButtonState(showChangeoverNormForGroup, false);
} else {
updateButtonState(showChangeoverNormForGroup, true);
}
}
if (StringUtils.isEmpty((String) previousOrderTechnologyNumberField.getFieldValue()) || StringUtils.isEmpty((String) technologyNumberField.getFieldValue())) {
updateButtonState(showChangeoverNormForTechnology, false);
} else {
Entity fromTechnology = lineChangeoverNormsForOrdersService.getTechnologyByNumberFromDB((String) previousOrderTechnologyNumberField.getFieldValue());
Entity toTechnology = lineChangeoverNormsForOrdersService.getTechnologyByNumberFromDB((String) technologyNumberField.getFieldValue());
if ((changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyWithLine(fromTechnology, toTechnology, productionLine) == null) && (changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyWithLine(fromTechnology, toTechnology, null) == null)) {
updateButtonState(showChangeoverNormForTechnology, false);
} else {
updateButtonState(showChangeoverNormForTechnology, true);
}
}
}
Aggregations