Search in sources :

Example 46 with FormComponent

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

the class DivisionDetailsListenersPL method onAddExistingEntity.

public void onAddExistingEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    if (args.length < 1) {
        return;
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity division = form.getPersistedEntityWithIncludedFormValues();
    List<Long> addedWorkstationIds = lookupUtils.parseIds(args[0]);
    for (Long addedWorkstationId : addedWorkstationIds) {
        Entity workstation = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION).get(addedWorkstationId);
        workstation.setField(WorkstationFields.DIVISION, division);
        workstation.getDataDefinition().save(workstation);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 47 with FormComponent

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

the class ProductionLineDetailsListeners method onAddExistingEntity.

public void onAddExistingEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    if (args.length < 1) {
        return;
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productionLine = form.getPersistedEntityWithIncludedFormValues();
    List<Long> addedWorkstationIds = lookupUtils.parseIds(args[0]);
    for (Long addedWorkstationId : addedWorkstationIds) {
        Entity workstation = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION).get(addedWorkstationId);
        workstation.setField(WorkstationFieldsPL.PRODUCTION_LINE, productionLine);
        workstation.getDataDefinition().save(workstation);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 48 with FormComponent

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

the class ProductionPerShiftDetailsHooks method disableReasonOfCorrection.

void disableReasonOfCorrection(final ViewDefinitionState view, final ProgressType progressType, final OrderState orderState) {
    boolean enabled = progressType != ProgressType.PLANNED && !UNSUPPORTED_ORDER_STATES.contains(orderState);
    AwesomeDynamicListComponent plannedProgressCorrectionTypes = (AwesomeDynamicListComponent) view.getComponentByReference(CORRECTION_CAUSE_TYPES_ADL_REF);
    plannedProgressCorrectionTypes.setEnabled(enabled);
    for (FormComponent plannedProgressCorrectionTypeForm : plannedProgressCorrectionTypes.getFormComponents()) {
        plannedProgressCorrectionTypeForm.setFormEnabled(enabled);
    }
    view.getComponentByReference(CORRECTION_COMMENT_TEXT_AREA_REF).setEnabled(enabled);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 49 with FormComponent

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

the class ProductionPerShiftDetailsHooks method fillProgressesUnitFields.

private void fillProgressesUnitFields(final AwesomeDynamicListComponent progressForDaysADL, final Optional<Entity> maybeMainOperationProduct) {
    String unit = FluentOptional.wrap(maybeMainOperationProduct).flatMap(EntityUtils.<String>getSafeFieldExtractor(ProductFields.UNIT)).toOpt().orNull();
    for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) {
        AwesomeDynamicListComponent dailyProgressADL = (AwesomeDynamicListComponent) progressForDayForm.findFieldComponentByName(DAILY_PROGRESS_ADL_REF);
        for (FormComponent dailyProgressForm : dailyProgressADL.getFormComponents()) {
            FieldComponent unitField = dailyProgressForm.findFieldComponentByName(UNIT_COMPONENT_NAME);
            unitField.setFieldValue(unit);
            unitField.requestComponentUpdateState();
        }
        dailyProgressADL.requestComponentUpdateState();
    }
    progressForDaysADL.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 50 with FormComponent

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

the class ProductionPerShiftDetailsHooks method setProductAndFillProgressForDays.

public void setProductAndFillProgressForDays(final ViewDefinitionState view, final AwesomeDynamicListComponent progressForDaysADL, final OrderState orderState, final ProgressType progressType) {
    FormComponent productionPerShiftForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity pps = productionPerShiftForm.getPersistedEntityWithIncludedFormValues();
    Optional<Entity> maybeMainOperationProduct = getMainOutProductFor(pps);
    fillOperationProductLookup(view, maybeMainOperationProduct);
    fillProgressForDays(progressForDaysADL, pps, maybeMainOperationProduct, progressType, orderState);
    fillProgressesUnitFields(progressForDaysADL, maybeMainOperationProduct);
    disableComponents(progressForDaysADL, progressType, orderState);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

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