use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class TrackingOperationProductInComponentDetailsHooks method toggleEnabledForWastes.
private void toggleEnabledForWastes(final ViewDefinitionState view) {
CheckBoxComponent wasteUsed = (CheckBoxComponent) view.getComponentByReference(L_WASTE_USED);
CheckBoxComponent wasteUsedOnly = (CheckBoxComponent) view.getComponentByReference(L_WASTE_USED_ONLY);
FieldComponent wasteUsedQuantity = (FieldComponent) view.getComponentByReference(L_WASTE_USED_QUANTITY);
FieldComponent wasteUnit = (FieldComponent) view.getComponentByReference(L_WASTE_UNIT);
if (wasteUsed.isChecked()) {
wasteUsedOnly.setEnabled(true);
wasteUsedQuantity.setEnabled(true);
wasteUnit.setEnabled(true);
} else {
wasteUsedOnly.setEnabled(false);
wasteUsedQuantity.setEnabled(false);
wasteUnit.setEnabled(false);
}
FieldComponent usedQuantity = (FieldComponent) view.getComponentByReference(L_USED_QUANTITY);
FieldComponent givenQuantity = (FieldComponent) view.getComponentByReference(L_GIVEN_QUANTITY);
if (wasteUsedOnly.isChecked()) {
usedQuantity.setEnabled(false);
givenQuantity.setEnabled(false);
} else {
usedQuantity.setEnabled(true);
givenQuantity.setEnabled(true);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ParametersHooksPC method setStateConsumptionOfRawMaterialsBasedOnStandards.
private void setStateConsumptionOfRawMaterialsBasedOnStandards(ViewDefinitionState view) {
CheckBoxComponent consumptionOfRawMaterialsBasedOnStandards = (CheckBoxComponent) view.getComponentByReference(ParameterFieldsPC.CONSUMPTION_OF_RAW_MATERIALS_BASED_ON_STANDARDS);
FieldComponent releaseOfMaterials = (FieldComponent) view.getComponentByReference(ParameterFieldsPC.RELEASE_OF_MATERIALS);
if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials.getFieldValue().toString())) {
consumptionOfRawMaterialsBasedOnStandards.setEnabled(false);
} else {
consumptionOfRawMaterialsBasedOnStandards.setEnabled(true);
}
consumptionOfRawMaterialsBasedOnStandards.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ChangeTechnologyParametersListeners method changeTechnologyParameters.
public void changeTechnologyParameters(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(L_TECHNOLOGY_GROUP);
String code = lookupComponent.getCurrentCode();
if (StringUtils.isNoneEmpty(code) && Objects.isNull(lookupComponent.getFieldValue())) {
form.findFieldComponentByName(L_TECHNOLOGY_GROUP).addMessage("qcadooView.lookup.noMatchError", ComponentState.MessageType.FAILURE);
generated.setChecked(false);
return;
}
Entity group = null;
Entity entity = form.getPersistedEntityWithIncludedFormValues();
if (entity.getBooleanField(L_CHANGE_GROUP) && Objects.nonNull(entity.getLongField(L_TECHNOLOGY_GROUP))) {
group = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_GROUP).get(entity.getLongField(L_TECHNOLOGY_GROUP));
entity.setField(L_TECHNOLOGY_GROUP, group);
}
try {
entity = entity.getDataDefinition().validate(entity);
if (!entity.isValid()) {
form.setEntity(entity);
return;
}
} catch (IllegalArgumentException e) {
form.findFieldComponentByName(L_STANDARD_PERFORMANCE).addMessage("qcadooView.validate.field.error.invalidNumericFormat", ComponentState.MessageType.FAILURE);
generated.setChecked(false);
return;
}
JSONObject context = view.getJsonContext();
Set<Long> ids = Arrays.stream(context.getString("window.mainTab.form.gridLayout.selectedEntities").replaceAll("[\\[\\]]", "").split(",")).map(Long::valueOf).collect(Collectors.toSet());
BigDecimal standardPerformance = null;
if (entity.getBooleanField(L_CHANGE_PERFORMANCE_NORM)) {
standardPerformance = entity.getDecimalField(L_STANDARD_PERFORMANCE);
}
try {
createCustomizedTechnologies(view, state, ids, entity, group, standardPerformance);
} catch (Exception exc) {
view.addMessage("technologies.changeTechnologyParameters.error.technologiesNotCreated", ComponentState.MessageType.FAILURE);
}
generated.setChecked(true);
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ChangeTechnologyParametersListeners method onChangeChangeGroup.
public void onChangeChangeGroup(final ViewDefinitionState view, final ComponentState state, final String[] args) {
CheckBoxComponent changeGroup = (CheckBoxComponent) state;
FieldComponent technologyGroup = (FieldComponent) view.getComponentByReference(L_TECHNOLOGY_GROUP);
if (changeGroup.isChecked()) {
technologyGroup.setEnabled(true);
} else {
technologyGroup.setEnabled(false);
technologyGroup.setFieldValue(null);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class TOCDetailsListenersPFTD method onProductionLineChange.
public void onProductionLineChange(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
CheckBoxComponent productionLineChange = (CheckBoxComponent) view.getComponentByReference("productionLineChange");
productionLineChange.setChecked(true);
productionLineChange.requestComponentUpdateState();
}
Aggregations