Search in sources :

Example 16 with LookupComponent

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

the class UseReplacementListeners method fillUnitField.

public void fillUnitField(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(PRODUCT);
    Entity product = productLookup.getEntity();
    String unit = "";
    if (product != null) {
        unit = product.getStringField(ProductFields.UNIT);
    }
    FieldComponent field = (FieldComponent) view.getComponentByReference("unit");
    field.setFieldValue(unit);
    field.requestComponentUpdateState();
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 17 with LookupComponent

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

the class ProdOutResourceAttrValDetailsListeners method onChangeAttribute.

public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ResourceAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ResourceAttributeValueFields.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 18 with LookupComponent

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

the class ProductionCountingQuantitySetDetailsListeners method fillUnitFields.

public void fillUnitFields(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    Entity product = ((LookupComponent) state).getEntity();
    String unit = "";
    if (product != null) {
        unit = product.getStringField(ProductFields.UNIT);
    }
    FieldComponent field = (FieldComponent) view.getComponentByReference(L_PRODUCT_UNIT);
    field.setFieldValue(unit);
    field.requestComponentUpdateState();
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 19 with LookupComponent

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

the class ProductionTrackingDetailsListeners method fillDivisionFieldFromOrder.

private void fillDivisionFieldFromOrder(final ViewDefinitionState view) {
    LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(ProductionTrackingFields.DIVISION);
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(ProductionTrackingFields.ORDER);
    Entity order = orderLookup.getEntity();
    if (Objects.nonNull(order) && Objects.nonNull(order.getBelongsToField(OrderFields.DIVISION))) {
        divisionLookup.setFieldValue(order.getBelongsToField(OrderFields.DIVISION).getId());
        divisionLookup.requestComponentUpdateState();
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 20 with LookupComponent

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

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