use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class WorkPlanDetailsHooks method disableFormForGeneratedWorkPlan.
final void disableFormForGeneratedWorkPlan(final ViewDefinitionState view) {
FormComponent workPlanForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generatedCheckbox = (CheckBoxComponent) view.getComponentByReference(WorkPlanFields.GENERATED);
if (workPlanForm == null) {
return;
}
if (workPlanForm.getEntityId() == null) {
view.getComponentByReference(WorkPlanFields.ORDERS).setEnabled(false);
view.getComponentByReference(WorkPlanFields.WORK_PLAN_ORDER_COLUMNS).setEnabled(false);
} else {
boolean isEnabled = !generatedCheckbox.isChecked();
view.getComponentByReference(WorkPlanFields.NAME).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.TYPE).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.DONT_PRINT_ORDERS_IN_WORK_PLANS).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.ORDERS).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.WORK_PLAN_ORDER_COLUMNS).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.INPUT_PRODUCT_COLUMN_TO_SORT_BY).setEnabled(isEnabled);
view.getComponentByReference(WorkPlanFields.ORDER_SORTING).setEnabled(isEnabled);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OrderParametersListenersBPC method onChangeLockProductionProgress.
public void onChangeLockProductionProgress(final ViewDefinitionState viewState, final ComponentState componentState, final String[] args) {
CheckBoxComponent lockProductionProgressCheckBox = (CheckBoxComponent) componentState;
CheckBoxComponent allowQuantityChangeInAcceptedOrderCheckBox = (CheckBoxComponent) viewState.getComponentByReference(ParameterFieldsO.ALLOW_QUANTITY_CHANGE_IN_ACCEPTED_ORDER);
if (allowQuantityChangeInAcceptedOrderCheckBox == null) {
if (LOG.isErrorEnabled()) {
LOG.error(String.format("orderParameters view: can't find component with reference='%s'", ParameterFieldsO.ALLOW_QUANTITY_CHANGE_IN_ACCEPTED_ORDER));
}
return;
}
if (!allowQuantityChangeInAcceptedOrderCheckBox.isEnabled() && lockProductionProgressCheckBox.isChecked()) {
allowQuantityChangeInAcceptedOrderCheckBox.setChecked(false);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class AttributeDetailsHooks method disableFormComponentsIfAttributeAssign.
private void disableFormComponentsIfAttributeAssign(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent dataType = (FieldComponent) view.getComponentByReference(AttributeFields.DATA_TYPE);
FieldComponent valueType = (FieldComponent) view.getComponentByReference(AttributeFields.VALUE_TYPE);
FieldComponent precision = (FieldComponent) view.getComponentByReference(AttributeFields.PRECISION);
FieldComponent unit = (FieldComponent) view.getComponentByReference(AttributeFields.UNIT);
CheckBoxComponent forProduct = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_PRODUCT);
CheckBoxComponent forResource = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_RESOURCE);
CheckBoxComponent forQualityControl = (CheckBoxComponent) view.getComponentByReference(AttributeFields.FOR_QUALITY_CONTROL);
dataType.setEnabled(true);
valueType.setEnabled(true);
precision.setEnabled(true);
unit.setEnabled(true);
forProduct.setEnabled(true);
forResource.setEnabled(true);
forQualityControl.setEnabled(true);
if (Objects.nonNull(form.getEntityId())) {
Entity attribute = form.getEntity().getDataDefinition().get(form.getEntity().getId());
if (!attribute.getHasManyField(AttributeFields.PRODUCT_ATTRIBUTE_VALUES).isEmpty()) {
dataType.setEnabled(false);
valueType.setEnabled(false);
precision.setEnabled(false);
unit.setEnabled(false);
forProduct.setEnabled(false);
}
if (!attribute.getHasManyField(AttributeFields.RESOURCE_ATTRIBUTE_VALUES).isEmpty()) {
dataType.setEnabled(false);
valueType.setEnabled(false);
precision.setEnabled(false);
unit.setEnabled(false);
forResource.setEnabled(false);
}
if (!attribute.getHasManyField(AttributeFields.QUALITY_CONTROL_ATTRIBUTE).isEmpty()) {
dataType.setEnabled(false);
valueType.setEnabled(false);
precision.setEnabled(false);
unit.setEnabled(false);
forQualityControl.setEnabled(false);
}
if (!attribute.getHasManyField(AttributeFields.ATTRIBUTE_VALUES).isEmpty()) {
dataType.setEnabled(false);
valueType.setEnabled(false);
precision.setEnabled(false);
}
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class CompanyDetailsHooks method fillDefaultCountry.
public void fillDefaultCountry(final ViewDefinitionState view) {
FormComponent companyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (companyForm.getEntityId() != null) {
return;
}
CheckBoxComponent isSetFieldsFromParameter = (CheckBoxComponent) view.getComponentByReference(CompanyFields.IS_SET_FIELDS_FROM_PARAMETER);
if (isSetFieldsFromParameter.isChecked()) {
return;
}
LookupComponent countryField = (LookupComponent) view.getComponentByReference(CompanyFields.COUNTRY);
LookupComponent taxCountryField = (LookupComponent) view.getComponentByReference(CompanyFields.TAX_COUNTRY_CODE);
Entity defaultCountry = parameterService.getParameter().getBelongsToField(CompanyFields.COUNTRY);
if (defaultCountry != null) {
countryField.setFieldValue(defaultCountry.getId());
taxCountryField.setFieldValue(defaultCountry.getId());
taxCountryField.requestComponentUpdateState();
countryField.requestComponentUpdateState();
}
isSetFieldsFromParameter.setFieldValue(true);
isSetFieldsFromParameter.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class AttributeValueImportListeners method importProductAttrValues.
public void importProductAttrValues(final ViewDefinitionState view, final ComponentState state, final String[] args) {
CheckBoxComponent importedCheckBoxComponent = (CheckBoxComponent) view.getComponentByReference(IMPORTED);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity formEntity = form.getPersistedEntityWithIncludedFormValues();
String positionsFilePath = formEntity.getStringField(L_POSITIONS_FILE);
if (canImportPositions(view, positionsFilePath)) {
return;
}
try {
boolean imported = attributeImportService.importProductAttributeValues(positionsFilePath, view);
importedCheckBoxComponent.setChecked(imported);
} catch (IOException e) {
view.addMessage("basic.attributeValuesImport.error", ComponentState.MessageType.FAILURE);
}
}
Aggregations