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