Search in sources :

Example 96 with FieldComponent

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);
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 97 with FieldComponent

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);
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 98 with FieldComponent

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();
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 99 with FieldComponent

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);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 100 with FieldComponent

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();
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

FieldComponent (com.qcadoo.view.api.components.FieldComponent)443 Entity (com.qcadoo.model.api.Entity)201 FormComponent (com.qcadoo.view.api.components.FormComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)107 BigDecimal (java.math.BigDecimal)47 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)31 Date (java.util.Date)30 Optional (com.google.common.base.Optional)18 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)14 ComponentState (com.qcadoo.view.api.ComponentState)13 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)13 WindowComponent (com.qcadoo.view.api.components.WindowComponent)12 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)11 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)9 PossibleUnitConversions (com.qcadoo.model.api.units.PossibleUnitConversions)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)6 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)6 Collectors (java.util.stream.Collectors)6