use of com.qcadoo.view.api.components.FieldComponent 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.FieldComponent in project mes by qcadoo.
the class AttributeDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
numberGeneratorService.generateAndInsertNumber(view, BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.ATTRIBUTE, QcadooViewConstants.L_FORM, AttributeFields.NUMBER);
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);
if (Objects.nonNull(valueType.getFieldValue()) && AttributeValueType.NUMERIC.getStringValue().equals(valueType.getFieldValue())) {
precision.setEnabled(true);
unit.setEnabled(true);
if (Objects.isNull(precision.getFieldValue()) || StringUtils.isEmpty((String) precision.getFieldValue())) {
precision.setFieldValue("0");
precision.requestComponentUpdateState();
}
} else {
unit.setEnabled(false);
unit.setFieldValue(null);
precision.setEnabled(false);
precision.setFieldValue(null);
precision.requestComponentUpdateState();
}
unit.requestComponentUpdateState();
GridComponent attributeValues = (GridComponent) view.getComponentByReference(AttributeFields.ATTRIBUTE_VALUES);
if (Objects.nonNull(dataType.getFieldValue()) && AttributeDataType.CONTINUOUS.getStringValue().equals(dataType.getFieldValue())) {
attributeValues.setEditable(false);
attributeValues.setEnabled(false);
} else {
attributeValues.setEditable(true);
attributeValues.setEnabled(true);
}
disableFormComponentsIfAttributeAssign(view);
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class CompanyDetailsHooks method disabledField.
private void disabledField(final ViewDefinitionState view, final String reference) {
FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(reference);
fieldComponent.setEnabled(false);
fieldComponent.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class FaultTypeDetailsHooks method disableActionsWhenDefault.
public void disableActionsWhenDefault(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actions = window.getRibbon().getGroupByName("actions");
for (RibbonActionItem item : actions.getItems()) {
item.setEnabled(false);
item.requestUpdate(true);
}
GridComponent workstationsGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATIONS);
GridComponent subassembliesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.SUBASSEMBLIES);
GridComponent workstationTypesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATION_TYPES);
workstationsGrid.setEnabled(false);
subassembliesGrid.setEnabled(false);
workstationTypesGrid.setEnabled(false);
FieldComponent nameField = (FieldComponent) view.getComponentByReference(FaultTypeFields.NAME);
FieldComponent appliesToField = (FieldComponent) view.getComponentByReference(FaultTypeFields.APPLIES_TO);
nameField.setEnabled(false);
appliesToField.setEnabled(false);
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class FormDetailsHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) {
FieldComponent size = (FieldComponent) view.getComponentByReference("size");
FieldComponent unit = (FieldComponent) view.getComponentByReference("unit");
if (size.getFieldValue() != null) {
unit.setRequired(true);
unit.requestComponentUpdateState();
} else {
unit.setRequired(false);
unit.requestComponentUpdateState();
}
}
Aggregations