use of com.qcadoo.view.api.components.FormComponent 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);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionBalanceDetailsHooks method disableFieldsAndGridsWhenGenerated.
public void disableFieldsAndGridsWhenGenerated(final ViewDefinitionState view) {
CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(ProductionBalanceFields.GENERATED);
if (generatedCheckBox.isChecked()) {
productionCountingService.setComponentsState(view, L_FIELDS_AND_CHECKBOXES, false, true);
} else {
productionCountingService.setComponentsState(view, L_FIELDS, true, true);
}
if (generatedCheckBox.isChecked()) {
productionCountingService.setComponentsState(view, L_COST_FIELDS, false, true);
productionCountingService.setComponentsState(view, L_COST_GRIDS, false, false);
} else {
productionCountingService.setComponentsState(view, L_COST_FIELDS, true, true);
productionCountingService.setComponentsState(view, L_COST_GRIDS, true, false);
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() == null) {
productionCountingService.setComponentsState(view, L_COST_GRIDS, false, false);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class SubassemblyDetailsListenersPL method generateFactoryStructure.
public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity subassembly = form.getEntity();
EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForSubassembly(subassembly);
subassembly.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
form.setEntity(subassembly);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
window.setActiveTab("factoryStructureTab");
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class WorkstationDetailsListenersPL method generateFactoryStructure.
public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity workstation = form.getEntity();
EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForWorkstation(workstation);
workstation.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
form.setEntity(workstation);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
window.setActiveTab("factoryStructureTab");
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class DivisionDetailsHooksPL method fillCriteriaModifiers.
public void fillCriteriaModifiers(final ViewDefinitionState viewDefinitionState) {
GridComponent workstations = (GridComponent) viewDefinitionState.getComponentByReference("workstations");
FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() != null) {
FilterValueHolder filter = workstations.getFilterValue();
filter.put("division", form.getEntityId());
workstations.setFilterValue(filter);
}
workstations.reloadEntities();
}
Aggregations