Search in sources :

Example 56 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class ProductionCountingQuantityAdvancedDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent productionCountingQuantityForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent technologyOperationComponentLookup = (LookupComponent) view.getComponentByReference(ProductionCountingQuantityFields.TECHNOLOGY_OPERATION_COMPONENT);
    Entity productionCountingQuantity = productionCountingQuantityForm.getEntity();
    Entity order = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.ORDER);
    Entity basicProductionCounting = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING);
    if (order != null) {
        Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
        if (technology != null) {
            FilterValueHolder filterValueHolder = technologyOperationComponentLookup.getFilterValue();
            filterValueHolder.put(OrderFields.TECHNOLOGY, technology.getId());
            technologyOperationComponentLookup.setFilterValue(filterValueHolder);
            return;
        }
    }
    if (basicProductionCounting != null) {
        Entity basicProductionCountingOrder = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.ORDER);
        if (basicProductionCountingOrder != null) {
            Entity technology = basicProductionCountingOrder.getBelongsToField(OrderFields.TECHNOLOGY);
            if (technology != null) {
                FilterValueHolder filterValueHolder = technologyOperationComponentLookup.getFilterValue();
                filterValueHolder.put(OrderFields.TECHNOLOGY, technology.getId());
                technologyOperationComponentLookup.setFilterValue(filterValueHolder);
            }
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 57 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class ProductionCountingQuantityAdvancedDetailsHooks method fillProductField.

private void fillProductField(final ViewDefinitionState view) {
    FormComponent productionCountingQuantityForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(ProductionCountingQuantityFields.PRODUCT);
    Long productionCountingQuantityId = productionCountingQuantityForm.getEntityId();
    if (productionCountingQuantityId != null) {
        return;
    }
    Entity productionCountingQuantity = productionCountingQuantityForm.getEntity();
    Entity basicProductionCounting = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING);
    if (basicProductionCounting != null) {
        Entity product = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.PRODUCT);
        if (product != null) {
            productLookup.setFieldValue(product.getId());
            productLookup.setEnabled(false);
            productLookup.requestComponentUpdateState();
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 58 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class ProductionCountingAttributeValueDetailsListeners method onChangeAttribute.

public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.VALUE);
    attributeValueLookup.setFieldValue(null);
    attributeValueLookup.requestComponentUpdateState();
    valueField.setFieldValue(null);
    valueField.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 59 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class ProductAttributeValueDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    setValueBold(view);
    setFilters(view);
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductAttributeValueFields.VALUE);
    if (Objects.nonNull(attributeLookup.getEntity())) {
        Entity attribute = attributeLookup.getEntity();
        FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
        unitField.setFieldValue(attribute.getStringField(AttributeFields.UNIT));
        unitField.requestComponentUpdateState();
        if (AttributeDataType.CONTINUOUS.getStringValue().equals(attribute.getStringField(AttributeFields.DATA_TYPE))) {
            valueField.setVisible(true);
            attributeValueLookup.setVisible(false);
        } else {
            valueField.setVisible(false);
            attributeValueLookup.setVisible(true);
        }
    } else {
        valueField.setVisible(false);
        attributeValueLookup.setVisible(false);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 60 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class ProductDetailsHooks method disableProductFormForExternalItems.

public void disableProductFormForExternalItems(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent entityTypeField = (FieldComponent) view.getComponentByReference(ProductFields.ENTITY_TYPE);
    FieldComponent parentField = (FieldComponent) view.getComponentByReference(ProductFields.PARENT);
    FieldComponent categoryField = (FieldComponent) view.getComponentByReference(ProductFields.CATEGORY);
    LookupComponent supplierLookup = (LookupComponent) view.getComponentByReference(ProductFields.SUPPLIER);
    LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ProductFields.ASSORTMENT);
    LookupComponent modelLookup = (LookupComponent) view.getComponentByReference(ProductFields.MODEL);
    Long productId = productForm.getEntityId();
    if (Objects.isNull(productId)) {
        productForm.setFormEnabled(true);
        return;
    }
    Entity product = getProductDD().get(productId);
    if (Objects.isNull(product)) {
        return;
    }
    String externalNumber = product.getStringField(ProductFields.EXTERNAL_NUMBER);
    if (StringUtils.isEmpty(externalNumber)) {
        productForm.setFormEnabled(true);
    } else {
        productForm.setFormEnabled(false);
        entityTypeField.setEnabled(true);
        parentField.setEnabled(true);
        categoryField.setEnabled(true);
        supplierLookup.setEnabled(true);
        assortmentLookup.setEnabled(true);
        modelLookup.setEnabled(true);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

LookupComponent (com.qcadoo.view.api.components.LookupComponent)277 Entity (com.qcadoo.model.api.Entity)182 FieldComponent (com.qcadoo.view.api.components.FieldComponent)105 FormComponent (com.qcadoo.view.api.components.FormComponent)102 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)69 BigDecimal (java.math.BigDecimal)16 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)12 GridComponent (com.qcadoo.view.api.components.GridComponent)11 WindowComponent (com.qcadoo.view.api.components.WindowComponent)8 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)7 Date (java.util.Date)6 JSONObject (org.json.JSONObject)6 ComponentState (com.qcadoo.view.api.ComponentState)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)5 JSONException (org.json.JSONException)5 DataDefinition (com.qcadoo.model.api.DataDefinition)3 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)3 Optional (com.google.common.base.Optional)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2