use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method enableFlowGrids.
private void enableFlowGrids(final ViewDefinitionState view, final boolean isEnabled, final boolean isEditable) {
GridComponent gridProductsComponent = (GridComponent) view.getComponentByReference(L_PRODUCTS_COMPONENT);
GridComponent gridProductsIntermediateIn = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_INTERMEDIATE_IN);
GridComponent gridProductsIntermediateOut = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_INTERMEDIATE_OUT);
GridComponent gridProductsFinal = (GridComponent) view.getComponentByReference(L_PRODUCTS_FINAL);
GridComponent gridProductsWaste = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_WASTE_RECEPTION_WAREHOUSE);
gridProductsComponent.setEnabled(isEnabled);
gridProductsIntermediateIn.setEnabled(isEnabled);
gridProductsIntermediateOut.setEnabled(isEnabled);
gridProductsFinal.setEnabled(isEnabled);
gridProductsWaste.setEnabled(isEnabled);
gridProductsComponent.setEditable(isEditable);
gridProductsIntermediateIn.setEditable(isEditable);
gridProductsIntermediateOut.setEditable(isEditable);
gridProductsFinal.setEditable(isEditable);
gridProductsWaste.setEditable(isEditable);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method hideWorkstationsTableForCumulatedProductionRecording.
private void hideWorkstationsTableForCumulatedProductionRecording(final ViewDefinitionState view) {
FieldComponent typeOfProductionRecordingFieldComponent = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
GridComponent workstationsTechnologyOperationComponent = (GridComponent) view.getComponentByReference(WORKSTATIONS_TECHNOLOGY_OPERATION_COMPONENT);
GridComponent workstations = (GridComponent) view.getComponentByReference(WORKSTATIONS);
ComponentState operationWorkstationsDescriptionLabel = view.getComponentByReference(OPERATION_WORKSTATIONS_DESCRIPTION);
if (Objects.nonNull(typeOfProductionRecordingFieldComponent) && TypeOfProductionRecording.FOR_EACH.getStringValue().equals(typeOfProductionRecordingFieldComponent.getFieldValue())) {
workstationsTechnologyOperationComponent.setVisible(true);
workstations.setVisible(true);
operationWorkstationsDescriptionLabel.setVisible(true);
} else {
workstationsTechnologyOperationComponent.setVisible(false);
workstations.setVisible(false);
operationWorkstationsDescriptionLabel.setVisible(false);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class DetailedProductionCountingAndProgressListenersBPC method resourceIssue.
public void resourceIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent formComponent = (FormComponent) view.getComponentByReference(L_ORDER);
Entity order = formComponent.getEntity().getDataDefinition().get(formComponent.getEntity().getId());
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> ids = grid.getSelectedEntitiesIds();
List<Entity> pcqs = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.in("id", ids)).list().getEntities();
if (!canIssueMaterials(order, pcqs)) {
formComponent.setEntity(order);
return;
}
try {
productionCountingDocumentService.createInternalOutboundDocument(order, pcqs, false);
if (order.isValid()) {
productionCountingDocumentService.updateProductionCountingQuantity(pcqs);
productionTrackingListenerServicePFTD.updateCostsForOrder(order);
view.addMessage("productFlowThruDivision.productionCountingQuantity.success.createInternalOutboundDocument", ComponentState.MessageType.SUCCESS);
}
} catch (DocumentBuildException documentBuildException) {
boolean errorsDisplayed = true;
for (ErrorMessage error : documentBuildException.getEntity().getGlobalErrors()) {
if (error.getMessage().equalsIgnoreCase(L_ERROR_NOT_ENOUGH_RESOURCES)) {
order.addGlobalError(error.getMessage(), false, error.getVars());
} else {
errorsDisplayed = false;
order.addGlobalError(error.getMessage(), error.getVars());
}
}
if (!errorsDisplayed) {
order.addGlobalError("productFlowThruDivision.productionCountingQuantity.productionCountingQuantityError.createInternalOutboundDocument");
}
formComponent.setEntity(order);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ModelCardDetailsListeners method generateModelCard.
@Transactional
public void generateModelCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent productsGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
if (productsGrid.getEntities().isEmpty()) {
view.addMessage("productFlowThruDivision.modelCard.generate.failure.noProducts", ComponentState.MessageType.INFO);
return;
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(ModelCardFields.GENERATED);
FieldComponent workerField = (FieldComponent) view.getComponentByReference(ModelCardFields.WORKER);
FieldComponent dateField = (FieldComponent) view.getComponentByReference(ModelCardFields.DATE);
workerField.setFieldValue(securityService.getCurrentUserName());
dateField.setFieldValue(DateUtils.toDateTimeString(new Date()));
generated.setChecked(true);
Entity modelCard = form.getEntity();
modelCard = modelCard.getDataDefinition().save(modelCard);
form.setEntity(modelCard);
Entity modelCardWithFileName = fileService.updateReportFileName(modelCard, ModelCardFields.DATE, "productFlowThruDivision.modelCard.report.fileName");
try {
modelCardPdfService.generateDocument(modelCardWithFileName, state.getLocale(), PageSize.A4.rotate());
} catch (IOException | DocumentException e) {
throw new IllegalStateException(e.getMessage(), e);
}
view.addMessage("productFlowThruDivision.modelCard.generate.success", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class OrderWithMaterialAvailabilityListListeners method showWarehouseResources.
public final void showWarehouseResources(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Entity entity = grid.getSelectedEntities().get(0);
Entity oma = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY).get(entity.getId());
String productNumber = oma.getBelongsToField(MaterialAvailabilityFields.PRODUCT).getStringField(ProductFields.NUMBER);
String locationNumber = oma.getBelongsToField(MaterialAvailabilityFields.LOCATION).getStringField(LocationFields.NUMBER);
Map<String, String> filters = Maps.newHashMap();
filters.put("productNumber", applyInOperator(productNumber));
filters.put("locationNumber", applyInOperator(locationNumber));
Map<String, Object> gridOptions = Maps.newHashMap();
gridOptions.put(L_FILTERS, filters);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put(L_GRID_OPTIONS, gridOptions);
parameters.put(L_WINDOW_ACTIVE_MENU, "materialFlow.resources");
String url = "../page/materialFlowResources/resourcesList.html";
view.redirectTo(url, false, true, parameters);
}
Aggregations