use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class UseReplacementListeners method fillUnitField.
public void fillUnitField(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(PRODUCT);
Entity product = productLookup.getEntity();
String unit = "";
if (product != null) {
unit = product.getStringField(ProductFields.UNIT);
}
FieldComponent field = (FieldComponent) view.getComponentByReference("unit");
field.setFieldValue(unit);
field.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProdOutResourceAttrValDetailsListeners method onChangeAttribute.
public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ResourceAttributeValueFields.ATTRIBUTE_VALUE);
FieldComponent valueField = (FieldComponent) view.getComponentByReference(ResourceAttributeValueFields.VALUE);
attributeValueLookup.setFieldValue(null);
attributeValueLookup.requestComponentUpdateState();
valueField.setFieldValue(null);
valueField.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProductionCountingQuantitySetDetailsListeners method fillUnitFields.
public void fillUnitFields(final ViewDefinitionState view, final ComponentState state, final String[] args) {
Entity product = ((LookupComponent) state).getEntity();
String unit = "";
if (product != null) {
unit = product.getStringField(ProductFields.UNIT);
}
FieldComponent field = (FieldComponent) view.getComponentByReference(L_PRODUCT_UNIT);
field.setFieldValue(unit);
field.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProductionTrackingDetailsListeners method fillDivisionFieldFromOrder.
private void fillDivisionFieldFromOrder(final ViewDefinitionState view) {
LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(ProductionTrackingFields.DIVISION);
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(ProductionTrackingFields.ORDER);
Entity order = orderLookup.getEntity();
if (Objects.nonNull(order) && Objects.nonNull(order.getBelongsToField(OrderFields.DIVISION))) {
divisionLookup.setFieldValue(order.getBelongsToField(OrderFields.DIVISION).getId());
divisionLookup.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class AnomalyExplanationDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity entity = form.getEntity();
if (view.isViewAfterRedirect()) {
initializeFormValues(view, entity);
}
boolean useWaste = ((CheckBoxComponent) view.getComponentByReference("useWaste")).isChecked();
LookupComponent productLookup = ((LookupComponent) view.getComponentByReference("product"));
productLookup.setEnabled(!useWaste);
view.getComponentByReference("location").setEnabled(!useWaste);
ComponentState givenUnitComponent = view.getComponentByReference("givenUnit");
String givenUnit = (String) givenUnitComponent.getFieldValue();
Entity selectedProduct = productLookup.getEntity();
boolean shouldAdditionalUnitBeEnabled = true;
if (selectedProduct != null) {
String selectedProductAdditionalUnit = selectedProduct.getStringField(ProductFields.ADDITIONAL_UNIT);
if (isNotBlank(selectedProductAdditionalUnit) && isNotBlank(givenUnit) && selectedProductAdditionalUnit.equals(givenUnit)) {
shouldAdditionalUnitBeEnabled = false;
}
}
givenUnitComponent.setEnabled(shouldAdditionalUnitBeEnabled);
}
Aggregations