Search in sources :

Example 6 with GridComponent

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);
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 7 with GridComponent

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);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 8 with GridComponent

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);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) DocumentBuildException(com.qcadoo.mes.materialFlowResources.exceptions.DocumentBuildException)

Example 9 with GridComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) DocumentException(com.lowagie.text.DocumentException) IOException(java.io.IOException) Date(java.util.Date) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with GridComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) JSONObject(org.json.JSONObject)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12