Search in sources :

Example 1 with CheckBoxComponent

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

the class ModelCardDetailsListeners method generateModelCard.

@Transactional
public void generateModelCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent productsGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    if (productsGrid.getEntities().isEmpty()) {
        view.addMessage("productFlowThruDivision.modelCard.generate.failure.noProducts", ComponentState.MessageType.INFO);
        return;
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(ModelCardFields.GENERATED);
    FieldComponent workerField = (FieldComponent) view.getComponentByReference(ModelCardFields.WORKER);
    FieldComponent dateField = (FieldComponent) view.getComponentByReference(ModelCardFields.DATE);
    workerField.setFieldValue(securityService.getCurrentUserName());
    dateField.setFieldValue(DateUtils.toDateTimeString(new Date()));
    generated.setChecked(true);
    Entity modelCard = form.getEntity();
    modelCard = modelCard.getDataDefinition().save(modelCard);
    form.setEntity(modelCard);
    Entity modelCardWithFileName = fileService.updateReportFileName(modelCard, ModelCardFields.DATE, "productFlowThruDivision.modelCard.report.fileName");
    try {
        modelCardPdfService.generateDocument(modelCardWithFileName, state.getLocale(), PageSize.A4.rotate());
    } catch (IOException | DocumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    view.addMessage("productFlowThruDivision.modelCard.generate.success", ComponentState.MessageType.SUCCESS);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) DocumentException(com.lowagie.text.DocumentException) IOException(java.io.IOException) Date(java.util.Date) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CheckBoxComponent

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

the class SupplyParametersListenersPFTD method toggleAutomaticReleaseAfterGeneration.

private void toggleAutomaticReleaseAfterGeneration(boolean checked, ViewDefinitionState view) {
    CheckBoxComponent automaticReleaseAfterGeneration = (CheckBoxComponent) view.getComponentByReference("automaticReleaseAfterGeneration");
    if (checked) {
        automaticReleaseAfterGeneration.setEnabled(true);
    } else {
        automaticReleaseAfterGeneration.setChecked(Boolean.FALSE);
        automaticReleaseAfterGeneration.setEnabled(false);
    }
    automaticReleaseAfterGeneration.requestComponentUpdateState();
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 3 with CheckBoxComponent

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

the class SupplyParametersHooksPFTD method toggleStateReservation.

private void toggleStateReservation(ViewDefinitionState view) {
    CheckBoxComponent warehouseIssuesReserveStatesCheckbox = (CheckBoxComponent) view.getComponentByReference(ParameterFieldsPFTD.WAREHOUSE_ISSUES_RESERVE_STATES);
    boolean shouldBeEnabled = draftOrInProgressWarehouseIssuesDoesntExist();
    warehouseIssuesReserveStatesCheckbox.setEnabled(shouldBeEnabled);
    warehouseIssuesReserveStatesCheckbox.requestComponentUpdateState();
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 4 with CheckBoxComponent

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

the class AnomalyProductionTrackingDetailsListeners method perform.

@Transactional(propagation = Propagation.REQUIRES_NEW)
private boolean perform(ViewDefinitionState view) {
    boolean valid = validate(view);
    if (valid) {
        createAnomalies(view);
        clearQuantitiesInRR(view);
        view.addMessage("productionCounting.anomalyProductionTrackingDetails.reasonsCreated", ComponentState.MessageType.SUCCESS);
        CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
        generated.setChecked(true);
        return true;
    } else {
        view.addMessage(new ErrorMessage("productionCounting.anomalyReasonDetails.reasonIsRequired", false));
        return false;
    }
}
Also used : ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with CheckBoxComponent

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

the class ProductionTrackingDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    setCriteriaModifierParameters(view);
    productionTrackingService.fillProductionLineLookup(view);
    if ((view.isViewAfterRedirect() || view.isViewAfterReload()) && !((CheckBoxComponent) view.getComponentByReference(ProductionTrackingFields.ADD_BATCH)).isChecked()) {
        FieldComponent batchNumber = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.BATCH_NUMBER);
        batchNumber.setEnabled(false);
    }
    if (Objects.isNull(productionTrackingForm.getEntityId())) {
        setStateFieldValueToDraft(view);
    } else {
        Entity productionTracking = getProductionTrackingFromDB(productionTrackingForm.getEntityId());
        initializeProductionTrackingDetailsView(view);
        showLastStateChangeFailNotification(productionTrackingForm, productionTracking);
        changeFieldComponentsEnabledAndGridsEditable(view);
        updateRibbonState(view);
        toggleCorrectButton(view, productionTracking);
        toggleCorrectionFields(view, productionTracking);
        fetchNumberFromDatabase(view, productionTracking);
    }
    fillBatchOrderedProductLabel(view);
    changeStoppagesTabVisible(view);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Aggregations

CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)100 FormComponent (com.qcadoo.view.api.components.FormComponent)38 Entity (com.qcadoo.model.api.Entity)33 FieldComponent (com.qcadoo.view.api.components.FieldComponent)30 GridComponent (com.qcadoo.view.api.components.GridComponent)19 LookupComponent (com.qcadoo.view.api.components.LookupComponent)11 Date (java.util.Date)7 JSONObject (org.json.JSONObject)7 BigDecimal (java.math.BigDecimal)6 ComponentState (com.qcadoo.view.api.ComponentState)4 WindowComponent (com.qcadoo.view.api.components.WindowComponent)4 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)4 IOException (java.io.IOException)4 MaterialFlowResourcesConstants (com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)2 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)2