Search in sources :

Example 66 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class TimeUsageReportHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) {
    SelectComponentState workersSelection = (SelectComponentState) view.getComponentByReference("workersSelection");
    GridComponent workersGrid = (GridComponent) view.getComponentByReference("workers");
    String selected = (String) workersSelection.getFieldValue();
    if ("01all".equals(selected)) {
        workersGrid.setEntities(Collections.emptyList());
        workersGrid.setEnabled(false);
    } else {
        workersGrid.setEnabled(true);
    }
}
Also used : SelectComponentState(com.qcadoo.view.internal.components.select.SelectComponentState) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 67 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class TechnologiesListHooksCC method toggleGenerateCostCalculationButton.

public void toggleGenerateCostCalculationButton(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonActionItem generateCostCalculation = window.getRibbon().getGroupByName("costCalculation").getItemByName("createCostCalculation");
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    generateCostCalculation.setEnabled(!grid.getSelectedEntities().isEmpty());
    generateCostCalculation.requestUpdate(true);
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 68 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class TechnologiesListListenersCC method createCostCalculation.

public final void createCostCalculation(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Entity> selectedEntities = grid.getSelectedEntities();
    if (!selectedEntities.isEmpty()) {
        DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY);
        List<Entity> technologies = selectedEntities.stream().map(e -> technologyDD.get(e.getId())).collect(Collectors.toList());
        DataDefinition costCalculationDD = dataDefinitionService.get(CostCalculationConstants.PLUGIN_IDENTIFIER, CostCalculationConstants.MODEL_COST_CALCULATION);
        Entity costCalculation = costCalculationDD.create();
        costCalculation.setField(CostCalculationFields.TECHNOLOGIES, technologies);
        costCalculation.setField(CostCalculationFields.QUANTITY, BigDecimal.ONE);
        Entity parameter = parameterService.getParameter();
        costCalculation.setField(CostCalculationFields.MATERIAL_COSTS_USED, parameter.getStringField(CostCalculationFields.MATERIAL_COSTS_USED) != null ? parameter.getStringField(CostCalculationFields.MATERIAL_COSTS_USED) : MaterialCostsUsed.NOMINAL.getStringValue());
        costCalculation.setField(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED, parameter.getBooleanField(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED));
        costCalculation.setField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS, parameter.getStringField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS) != null ? parameter.getStringField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS) : SourceOfOperationCosts.TECHNOLOGY_OPERATION.getStringValue());
        costCalculation.setField(CostCalculationFields.STANDARD_LABOR_COST, parameter.getBelongsToField(CostCalculationFields.STANDARD_LABOR_COST));
        costCalculation.setField(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST));
        costCalculation.setField(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST));
        costCalculation.setField(CostCalculationFields.INCLUDE_TPZ, parameter.getBooleanField(CostCalculationFields.INCLUDE_TPZ));
        costCalculation.setField(CostCalculationFields.INCLUDE_ADDITIONAL_TIME, parameter.getBooleanField(CostCalculationFields.INCLUDE_ADDITIONAL_TIME));
        costCalculation.setField(CostCalculationFields.MATERIAL_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.MATERIAL_COST_MARGIN));
        costCalculation.setField(CostCalculationFields.PRODUCTION_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.PRODUCTION_COST_MARGIN));
        costCalculation.setField(CostCalculationFields.ADDITIONAL_OVERHEAD, parameter.getDecimalField(CostCalculationFields.ADDITIONAL_OVERHEAD));
        costCalculation.setField(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD, parameter.getDecimalField(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD));
        costCalculation.setField(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD, parameter.getDecimalField(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD));
        costCalculation.setField(CostCalculationFields.PROFIT, parameter.getDecimalField(CostCalculationFields.PROFIT));
        costCalculation.setField(CostCalculationFields.NUMBER, numberGeneratorService.generateNumber(CostCalculationConstants.PLUGIN_IDENTIFIER, CostCalculationConstants.MODEL_COST_CALCULATION));
        costCalculation = costCalculationDD.save(costCalculation);
        String url = "../page/costCalculation/costCalculationDetails.html";
        Map<String, Object> parameters = Maps.newHashMap();
        parameters.put("form.id", costCalculation.getId());
        view.redirectTo(url, false, true, parameters);
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) ComponentState(com.qcadoo.view.api.ComponentState) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) MaterialCostsUsed(com.qcadoo.mes.costCalculation.constants.MaterialCostsUsed) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) SourceOfOperationCosts(com.qcadoo.mes.costCalculation.constants.SourceOfOperationCosts) DataDefinition(com.qcadoo.model.api.DataDefinition) GridComponent(com.qcadoo.view.api.components.GridComponent) BigDecimal(java.math.BigDecimal) CostCalculationFields(com.qcadoo.mes.costCalculation.constants.CostCalculationFields) List(java.util.List) Entity(com.qcadoo.model.api.Entity) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) ParameterService(com.qcadoo.mes.basic.ParameterService) NumberGeneratorService(com.qcadoo.view.api.utils.NumberGeneratorService) Service(org.springframework.stereotype.Service) Map(java.util.Map) CostCalculationConstants(com.qcadoo.mes.costCalculation.constants.CostCalculationConstants) TechnologiesConstants(com.qcadoo.mes.technologies.constants.TechnologiesConstants) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 69 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class CostNormsForMaterialsService method fillInProductsGridInTechnology.

public void fillInProductsGridInTechnology(final ViewDefinitionState viewDefinitionState) {
    checkArgument(viewDefinitionState != null, L_VIEW_DEFINITION_STATE_IS_NULL);
    GridComponent grid = (GridComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_GRID);
    FormComponent technology = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    Long technologyId = technology.getEntityId();
    if (technologyId == null) {
        return;
    }
    List<Entity> inputProducts = Lists.newArrayList();
    for (Entity product : technologyService.getComponentsWithProductWithSizes(technologyId)) {
        Entity operationProductInComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT).create();
        operationProductInComponent.setField(OperationProductInComponentFields.PRODUCT, product);
        inputProducts.add(operationProductInComponent);
    }
    grid.setEntities(inputProducts);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 70 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class TechnologyInstOperProductInCompDetailsHooks method setCriteriaModifiersParameters.

public void setCriteriaModifiersParameters(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity technologyInstOperProductInComp = form.getEntity();
    Entity product = technologyInstOperProductInComp.getBelongsToField(TechnologyInstOperProductInCompFields.PRODUCT);
    Entity order = technologyInstOperProductInComp.getBelongsToField(TechnologyInstOperProductInCompFields.ORDER);
    GridComponent positions = (GridComponent) view.getComponentByReference("positions");
    FilterValueHolder filterValueHolder = positions.getFilterValue();
    filterValueHolder.put(PRODUCT_NUMBER, product.getStringField(ProductFields.NUMBER));
    filterValueHolder.put(ORDER_ID, order.getId().intValue());
    positions.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

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