Search in sources :

Example 46 with LookupComponent

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

the class TOCProcessListDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    Long operationId = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getPersistedEntityWithIncludedFormValues().getBelongsToField(TechnologyOperationComponentFields.OPERATION).getId();
    LookupComponent technologicalProcessList = (LookupComponent) view.getComponentByReference(TechnologyOperationComponentFields.TECHNOLOGICAL_PROCESS_LIST);
    FilterValueHolder filterValueHolder = technologicalProcessList.getFilterValue();
    filterValueHolder.put(TechnologicalProcessListFields.OPERATION, operationId);
    technologicalProcessList.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 47 with LookupComponent

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

the class TechnologicalProcessComponentDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    CheckBoxComponent extendedTimeForSizeGroupField = (CheckBoxComponent) view.getComponentByReference(EXTENDED_TIME_FOR_SIZE_GROUP);
    FieldComponent increasePercentField = (FieldComponent) view.getComponentByReference(INCREASE_PERCENT);
    LookupComponent sizeGroupLookup = (LookupComponent) view.getComponentByReference(SIZE_GROUP);
    if (extendedTimeForSizeGroupField.isChecked()) {
        increasePercentField.setEnabled(true);
        increasePercentField.setRequired(true);
        sizeGroupLookup.setEnabled(true);
        sizeGroupLookup.setRequired(true);
    } else {
        increasePercentField.setEnabled(false);
        increasePercentField.setFieldValue(null);
        increasePercentField.setRequired(false);
        sizeGroupLookup.setEnabled(false);
        sizeGroupLookup.setFieldValue(null);
        sizeGroupLookup.setRequired(false);
    }
    increasePercentField.requestComponentUpdateState();
    sizeGroupLookup.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 48 with LookupComponent

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

the class TechnologyDetailsListeners method fillQualityCard.

public void fillQualityCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(TechnologyFields.PRODUCT);
    Entity product = productLookup.getEntity();
    if (Objects.nonNull(product)) {
        LookupComponent qualityCardLookup = (LookupComponent) view.getComponentByReference(TechnologyFields.QUALITY_CARD);
        List<Entity> entities = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_QUALITY_CARD).find().add(SearchRestrictions.eq(QualityCardFields.STATE, "02accepted")).createAlias(QualityCardFields.PRODUCTS, QualityCardFields.PRODUCTS, JoinType.INNER).add(SearchRestrictions.eq(QualityCardFields.PRODUCTS + ".id", product.getId())).list().getEntities();
        if (entities.size() == 1) {
            qualityCardLookup.setFieldValue(entities.get(0).getId());
        } else {
            qualityCardLookup.setFieldValue(null);
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 49 with LookupComponent

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

the class OPICDetailsListeners method fillUnitForTechnologyType.

private void fillUnitForTechnologyType(ViewDefinitionState view) {
    LookupComponent technologyInputProductTypeLookup = (LookupComponent) view.getComponentByReference(OperationProductInComponentFields.TECHNOLOGY_INPUT_PRODUCT_TYPE);
    FieldComponent unitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.UNIT);
    FieldComponent givenUnitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_UNIT);
    Entity technologyInputProductType = technologyInputProductTypeLookup.getEntity();
    String givenUnit = (String) givenUnitField.getFieldValue();
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OperationProductInComponentFields.PRODUCT);
    if (productLookup.isEmpty() && Objects.nonNull(technologyInputProductType) && StringUtils.isNoneEmpty(givenUnit)) {
        unitField.setFieldValue(givenUnit);
        unitField.requestComponentUpdateState();
    }
    unitService.fillProductUnitBeforeRenderIfEmpty(view, OperationProductInComponentFields.UNIT);
    unitService.fillProductUnitBeforeRenderIfEmpty(view, OperationProductInComponentFields.GIVEN_UNIT);
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 50 with LookupComponent

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

the class GenerateTimeGapsListeners method clearOtherLineCriteriaLookupComponents.

public void clearOtherLineCriteriaLookupComponents(final ViewDefinitionState viewState, final ComponentState eventPerformer, final String[] arguments) {
    if (((LookupComponent) eventPerformer).getEntity() == null) {
        return;
    }
    LookupComponent techLookup = (LookupComponent) findComponentByReferenceName(viewState, "supportedTechnology");
    LookupComponent techGroupLookup = (LookupComponent) findComponentByReferenceName(viewState, "supportedTechnologyGroup");
    Iterable<LookupComponent> lookupComponents = Lists.newArrayList(techLookup, techGroupLookup);
    for (LookupComponent lookupComponent : lookupComponents) {
        if (lookupComponent.getName().equals(eventPerformer.getName())) {
            continue;
        }
        lookupComponent.setFieldValue(null);
    }
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

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