use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OPICDetailsHooks method setStateForVariousQuantitiesInProductsBySize.
private void setStateForVariousQuantitiesInProductsBySize(ViewDefinitionState view) {
CheckBoxComponent differentProductsInDifferentSizesCheckBox = (CheckBoxComponent) view.getComponentByReference(OperationProductInComponentFields.DIFFERENT_PRODUCTS_IN_DIFFERENT_SIZES);
CheckBoxComponent variousQuantitiesInProductsBySizeCheckBox = (CheckBoxComponent) view.getComponentByReference(OperationProductInComponentFields.VARIOUS_QUANTITIES_IN_PRODUCTS_BY_SIZE);
if (differentProductsInDifferentSizesCheckBox.isChecked()) {
variousQuantitiesInProductsBySizeCheckBox.setEnabled(Boolean.TRUE);
FieldComponent quantityField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.QUANTITY);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.UNIT);
FieldComponent quantityFormulaField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.QUANTITY_FORMULA);
FieldComponent givenQuantityField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_QUANTITY);
FieldComponent givenUnitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_UNIT);
if (variousQuantitiesInProductsBySizeCheckBox.isChecked()) {
quantityField.setFieldValue(null);
if (Objects.nonNull(quantityFormulaField)) {
quantityFormulaField.setFieldValue(null);
quantityFormulaField.setEnabled(false);
}
unitField.setFieldValue(null);
givenQuantityField.setFieldValue(null);
givenUnitField.setFieldValue(null);
givenQuantityField.setEnabled(false);
givenUnitField.setEnabled(false);
} else {
if (Objects.nonNull(quantityFormulaField)) {
quantityFormulaField.setEnabled(true);
}
givenQuantityField.setEnabled(true);
givenUnitField.setEnabled(true);
}
} else {
variousQuantitiesInProductsBySizeCheckBox.setEnabled(Boolean.FALSE);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OperationDetailsHooks method disableCreateOperationOutput.
private void disableCreateOperationOutput(final ViewDefinitionState view) {
CheckBoxComponent createOperationOutput = (CheckBoxComponent) view.getComponentByReference(L_CREATE_OPERATION_OUTPUT);
LookupComponent productLookupComponent = (LookupComponent) view.getComponentByReference(L_PRODUCT);
createOperationOutput.setEnabled(productLookupComponent.isEmpty() || !Objects.nonNull(productLookupComponent.getEntity()));
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class TechnologicalProcessDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
CheckBoxComponent extendedTimeForSizeGroupField = (CheckBoxComponent) view.getComponentByReference(EXTENDED_TIME_FOR_SIZE_GROUP);
FieldComponent increasePercentField = (FieldComponent) view.getComponentByReference(INCREASE_PERCENT);
LookupComponent sizeGroupLookup = (LookupComponent) view.getComponentByReference(SIZE_GROUP);
if (extendedTimeForSizeGroupField.isChecked()) {
increasePercentField.setEnabled(true);
increasePercentField.setRequired(true);
sizeGroupLookup.setEnabled(true);
sizeGroupLookup.setRequired(true);
} else {
increasePercentField.setEnabled(false);
increasePercentField.setFieldValue(null);
increasePercentField.setRequired(false);
sizeGroupLookup.setEnabled(false);
sizeGroupLookup.setFieldValue(null);
sizeGroupLookup.setRequired(false);
}
increasePercentField.requestComponentUpdateState();
sizeGroupLookup.requestComponentUpdateState();
LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(WORKSTATION);
LookupComponent workstationTypeLookup = (LookupComponent) view.getComponentByReference(WORKSTATION_TYPE);
FilterValueHolder filterValueHolder = workstationLookup.getFilterValue();
if (workstationTypeLookup.getFieldValue() != null) {
filterValueHolder.put(WorkstationFields.WORKSTATION_TYPE, workstationTypeLookup.getEntity().getId());
} else {
filterValueHolder.remove(WorkstationFields.WORKSTATION_TYPE);
}
workstationLookup.setFilterValue(filterValueHolder);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long technologicalProcessId = form.getEntityId();
if (Objects.nonNull(technologicalProcessId)) {
Entity workstationType = workstationTypeLookup.getEntity();
Entity workstationTypeFromDB = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS).get(technologicalProcessId).getBelongsToField(WORKSTATION_TYPE);
if (workstationType == null && workstationTypeFromDB != null || workstationType != null && workstationTypeFromDB == null || workstationType != null && !workstationType.getId().equals(workstationTypeFromDB.getId())) {
workstationLookup.setFieldValue(null);
workstationLookup.requestComponentUpdateState();
}
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class WorkTimeForUserListHooks method fillDefaultFilters.
public void fillDefaultFilters(final ViewDefinitionState view) {
CheckBoxComponent initialized = (CheckBoxComponent) view.getComponentByReference("initialized");
if (initialized.isChecked()) {
return;
}
initialized.setChecked(true);
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Entity currentUser = userService.getCurrentUserEntity();
Map<String, String> filters = Maps.newHashMap();
DateTime currentDate = getCurrentDate();
filters.put("startDate", ">=" + currentDate.toString("yyyy-MM-dd hh:mm:ss"));
filters.put("finishDate", "=<" + currentDate.plusDays(1).toString("yyyy-MM-dd hh:mm:ss"));
filters.put("username", currentUser.getStringField("userName"));
grid.setFilters(filters);
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class CostCalculationDetailsHooks method fillOverheadsFromParameters.
private void fillOverheadsFromParameters(ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() == null) {
CheckBoxComponent isSetFieldsFromParameter = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.IS_SET_FIELDS_FROM_PARAMETER);
if (isSetFieldsFromParameter.isChecked()) {
return;
}
Entity parameter = parameterService.getParameter();
fillWithProperty(CostCalculationFields.MATERIAL_COSTS_USED, parameter.getStringField(CostCalculationFields.MATERIAL_COSTS_USED), view);
fillCheckboxWithProperty(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED, parameter.getBooleanField(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED), view);
fillWithProperty(CostCalculationFields.SOURCE_OF_OPERATION_COSTS, parameter.getStringField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS), view);
fillLookupWithProperty(CostCalculationFields.STANDARD_LABOR_COST, parameter.getBelongsToField(CostCalculationFields.STANDARD_LABOR_COST), view);
fillWithPropertyOrZero(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST), view, false);
fillWithPropertyOrZero(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST), view, false);
fillCheckboxWithProperty(CostCalculationFields.INCLUDE_TPZ, parameter.getBooleanField(CostCalculationFields.INCLUDE_TPZ), view);
fillCheckboxWithProperty(CostCalculationFields.INCLUDE_ADDITIONAL_TIME, parameter.getBooleanField(CostCalculationFields.INCLUDE_ADDITIONAL_TIME), view);
fillWithPropertyOrZero(CostCalculationFields.MATERIAL_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.MATERIAL_COST_MARGIN), view, true);
fillWithPropertyOrZero(CostCalculationFields.PRODUCTION_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.PRODUCTION_COST_MARGIN), view, true);
fillWithPropertyOrZero(CostCalculationFields.ADDITIONAL_OVERHEAD, parameter.getDecimalField(CostCalculationFields.ADDITIONAL_OVERHEAD), view, true);
fillWithPropertyOrZero(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD, parameter.getDecimalField(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD), view, true);
fillWithPropertyOrZero(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD, parameter.getDecimalField(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD), view, true);
fillWithPropertyOrZero(CostCalculationFields.PROFIT, parameter.getDecimalField(CostCalculationFields.PROFIT), view, true);
isSetFieldsFromParameter.setFieldValue(true);
isSetFieldsFromParameter.requestComponentUpdateState();
}
}
Aggregations