Search in sources :

Example 41 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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)

Example 42 with FormComponent

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

the class ProductionBalanceDetailsHooks method disableFieldsAndGridsWhenGenerated.

public void disableFieldsAndGridsWhenGenerated(final ViewDefinitionState view) {
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(ProductionBalanceFields.GENERATED);
    if (generatedCheckBox.isChecked()) {
        productionCountingService.setComponentsState(view, L_FIELDS_AND_CHECKBOXES, false, true);
    } else {
        productionCountingService.setComponentsState(view, L_FIELDS, true, true);
    }
    if (generatedCheckBox.isChecked()) {
        productionCountingService.setComponentsState(view, L_COST_FIELDS, false, true);
        productionCountingService.setComponentsState(view, L_COST_GRIDS, false, false);
    } else {
        productionCountingService.setComponentsState(view, L_COST_FIELDS, true, true);
        productionCountingService.setComponentsState(view, L_COST_GRIDS, true, false);
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() == null) {
        productionCountingService.setComponentsState(view, L_COST_GRIDS, false, false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 43 with FormComponent

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

the class SubassemblyDetailsListenersPL method generateFactoryStructure.

public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity subassembly = form.getEntity();
    EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForSubassembly(subassembly);
    subassembly.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
    form.setEntity(subassembly);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    window.setActiveTab("factoryStructureTab");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) EntityTree(com.qcadoo.model.api.EntityTree)

Example 44 with FormComponent

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

the class WorkstationDetailsListenersPL method generateFactoryStructure.

public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity workstation = form.getEntity();
    EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForWorkstation(workstation);
    workstation.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
    form.setEntity(workstation);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    window.setActiveTab("factoryStructureTab");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) EntityTree(com.qcadoo.model.api.EntityTree)

Example 45 with FormComponent

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

the class DivisionDetailsHooksPL method fillCriteriaModifiers.

public void fillCriteriaModifiers(final ViewDefinitionState viewDefinitionState) {
    GridComponent workstations = (GridComponent) viewDefinitionState.getComponentByReference("workstations");
    FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() != null) {
        FilterValueHolder filter = workstations.getFilterValue();
        filter.put("division", form.getEntityId());
        workstations.setFilterValue(filter);
    }
    workstations.reloadEntities();
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16