Search in sources :

Example 91 with FieldComponent

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

the class ProductDetailsHooks method disableEntityTypeWhenProductFamilyHasChildren.

public void disableEntityTypeWhenProductFamilyHasChildren(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);
    Entity product = productForm.getPersistedEntityWithIncludedFormValues();
    entityTypeField.setEnabled(product.getHasManyField(ProductFields.CHILDREN).isEmpty());
    if (ProductFamilyElementType.PRODUCTS_FAMILY.getStringValue().equals(product.getField(ProductFields.ENTITY_TYPE))) {
        parentField.setFieldValue(null);
        parentField.setEnabled(false);
    } else {
        parentField.setEnabled(true);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 92 with FieldComponent

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

the class SkillStaffDetails method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity opSkill = form.getEntity();
    FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
    maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(StaffSkillsFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
    LookupComponent staffLookup = (LookupComponent) view.getComponentByReference(StaffSkillsFields.STAFF);
    FilterValueHolder filterValueHolder = staffLookup.getFilterValue();
    Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
    if (Objects.isNull(skillId)) {
        filterValueHolder.remove(L_SKILL_ID);
    } else {
        filterValueHolder.put(L_SKILL_ID, skillId);
    }
    staffLookup.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) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 93 with FieldComponent

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

the class StaffSkillDetailsHooks method fillMaxSkill.

private void fillMaxSkill(final ViewDefinitionState view, final LookupComponent skillLookup) {
    Entity skill = skillLookup.getEntity();
    if (Objects.nonNull(skill)) {
        FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
        maxSkillLevelField.setFieldValue(skill.getIntegerField(SkillFields.MAXIMUM_LEVEL));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 94 with FieldComponent

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

the class SubassemblyToWorkstationHelperHooks method refreshTypeComponentValue.

private void refreshTypeComponentValue(ViewDefinitionState view) {
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity subassemblyToWorkstationHelper = formComponent.getEntity();
    Entity subassemly = subassemblyToWorkstationHelper.getBelongsToField(SubassemblyToWorkstationHelperFields.SUBASSEMBLY);
    if (subassemly != null) {
        subassemblyToWorkstationHelper.setField(SubassemblyToWorkstationHelperFields.TYPE, subassemly.getField(SubassemblyFields.TYPE));
        final FieldComponent typeComponent = (FieldComponent) view.getComponentByReference("type");
        typeComponent.setFieldValue(subassemly.getField(SubassemblyFields.TYPE));
        typeComponent.setEnabled(true);
        typeComponent.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 95 with FieldComponent

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

the class PalletNumberDetailsHooks method generatePalletNumber.

private void generatePalletNumber(final ViewDefinitionState view) {
    FieldComponent numberField = (FieldComponent) view.getComponentByReference(PalletNumberFields.NUMBER);
    if (palletNumberGenerator.checkIfShouldInsertNumber(view)) {
        String number = palletNumberGenerator.generate();
        numberField.setFieldValue(number);
        numberField.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