Search in sources :

Example 76 with CheckBoxComponent

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

the class OPICDetailsHooks method setStateForVariousQuantitiesInProductsBySize.

private void setStateForVariousQuantitiesInProductsBySize(ViewDefinitionState view) {
    CheckBoxComponent differentProductsInDifferentSizesCheckBox = (CheckBoxComponent) view.getComponentByReference(OperationProductInComponentFields.DIFFERENT_PRODUCTS_IN_DIFFERENT_SIZES);
    CheckBoxComponent variousQuantitiesInProductsBySizeCheckBox = (CheckBoxComponent) view.getComponentByReference(OperationProductInComponentFields.VARIOUS_QUANTITIES_IN_PRODUCTS_BY_SIZE);
    if (differentProductsInDifferentSizesCheckBox.isChecked()) {
        variousQuantitiesInProductsBySizeCheckBox.setEnabled(Boolean.TRUE);
        FieldComponent quantityField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.QUANTITY);
        FieldComponent unitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.UNIT);
        FieldComponent quantityFormulaField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.QUANTITY_FORMULA);
        FieldComponent givenQuantityField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_QUANTITY);
        FieldComponent givenUnitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_UNIT);
        if (variousQuantitiesInProductsBySizeCheckBox.isChecked()) {
            quantityField.setFieldValue(null);
            if (Objects.nonNull(quantityFormulaField)) {
                quantityFormulaField.setFieldValue(null);
                quantityFormulaField.setEnabled(false);
            }
            unitField.setFieldValue(null);
            givenQuantityField.setFieldValue(null);
            givenUnitField.setFieldValue(null);
            givenQuantityField.setEnabled(false);
            givenUnitField.setEnabled(false);
        } else {
            if (Objects.nonNull(quantityFormulaField)) {
                quantityFormulaField.setEnabled(true);
            }
            givenQuantityField.setEnabled(true);
            givenUnitField.setEnabled(true);
        }
    } else {
        variousQuantitiesInProductsBySizeCheckBox.setEnabled(Boolean.FALSE);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 77 with CheckBoxComponent

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

the class OperationDetailsHooks method disableCreateOperationOutput.

private void disableCreateOperationOutput(final ViewDefinitionState view) {
    CheckBoxComponent createOperationOutput = (CheckBoxComponent) view.getComponentByReference(L_CREATE_OPERATION_OUTPUT);
    LookupComponent productLookupComponent = (LookupComponent) view.getComponentByReference(L_PRODUCT);
    createOperationOutput.setEnabled(productLookupComponent.isEmpty() || !Objects.nonNull(productLookupComponent.getEntity()));
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 78 with CheckBoxComponent

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

the class TechnologicalProcessDetailsHooks 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();
    LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(WORKSTATION);
    LookupComponent workstationTypeLookup = (LookupComponent) view.getComponentByReference(WORKSTATION_TYPE);
    FilterValueHolder filterValueHolder = workstationLookup.getFilterValue();
    if (workstationTypeLookup.getFieldValue() != null) {
        filterValueHolder.put(WorkstationFields.WORKSTATION_TYPE, workstationTypeLookup.getEntity().getId());
    } else {
        filterValueHolder.remove(WorkstationFields.WORKSTATION_TYPE);
    }
    workstationLookup.setFilterValue(filterValueHolder);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long technologicalProcessId = form.getEntityId();
    if (Objects.nonNull(technologicalProcessId)) {
        Entity workstationType = workstationTypeLookup.getEntity();
        Entity workstationTypeFromDB = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS).get(technologicalProcessId).getBelongsToField(WORKSTATION_TYPE);
        if (workstationType == null && workstationTypeFromDB != null || workstationType != null && workstationTypeFromDB == null || workstationType != null && !workstationType.getId().equals(workstationTypeFromDB.getId())) {
            workstationLookup.setFieldValue(null);
            workstationLookup.requestComponentUpdateState();
        }
    }
}
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) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 79 with CheckBoxComponent

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

the class WorkTimeForUserListHooks method fillDefaultFilters.

public void fillDefaultFilters(final ViewDefinitionState view) {
    CheckBoxComponent initialized = (CheckBoxComponent) view.getComponentByReference("initialized");
    if (initialized.isChecked()) {
        return;
    }
    initialized.setChecked(true);
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Entity currentUser = userService.getCurrentUserEntity();
    Map<String, String> filters = Maps.newHashMap();
    DateTime currentDate = getCurrentDate();
    filters.put("startDate", ">=" + currentDate.toString("yyyy-MM-dd hh:mm:ss"));
    filters.put("finishDate", "=<" + currentDate.plusDays(1).toString("yyyy-MM-dd hh:mm:ss"));
    filters.put("username", currentUser.getStringField("userName"));
    grid.setFilters(filters);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DateTime(org.joda.time.DateTime) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 80 with CheckBoxComponent

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

the class CostCalculationDetailsHooks method fillOverheadsFromParameters.

private void fillOverheadsFromParameters(ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() == null) {
        CheckBoxComponent isSetFieldsFromParameter = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.IS_SET_FIELDS_FROM_PARAMETER);
        if (isSetFieldsFromParameter.isChecked()) {
            return;
        }
        Entity parameter = parameterService.getParameter();
        fillWithProperty(CostCalculationFields.MATERIAL_COSTS_USED, parameter.getStringField(CostCalculationFields.MATERIAL_COSTS_USED), view);
        fillCheckboxWithProperty(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED, parameter.getBooleanField(CostCalculationFields.USE_NOMINAL_COST_PRICE_NOT_SPECIFIED), view);
        fillWithProperty(CostCalculationFields.SOURCE_OF_OPERATION_COSTS, parameter.getStringField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS), view);
        fillLookupWithProperty(CostCalculationFields.STANDARD_LABOR_COST, parameter.getBelongsToField(CostCalculationFields.STANDARD_LABOR_COST), view);
        fillWithPropertyOrZero(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_MACHINE_HOURLY_COST), view, false);
        fillWithPropertyOrZero(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST, parameter.getDecimalField(CostCalculationFields.AVERAGE_LABOR_HOURLY_COST), view, false);
        fillCheckboxWithProperty(CostCalculationFields.INCLUDE_TPZ, parameter.getBooleanField(CostCalculationFields.INCLUDE_TPZ), view);
        fillCheckboxWithProperty(CostCalculationFields.INCLUDE_ADDITIONAL_TIME, parameter.getBooleanField(CostCalculationFields.INCLUDE_ADDITIONAL_TIME), view);
        fillWithPropertyOrZero(CostCalculationFields.MATERIAL_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.MATERIAL_COST_MARGIN), view, true);
        fillWithPropertyOrZero(CostCalculationFields.PRODUCTION_COST_MARGIN, parameter.getDecimalField(CostCalculationFields.PRODUCTION_COST_MARGIN), view, true);
        fillWithPropertyOrZero(CostCalculationFields.ADDITIONAL_OVERHEAD, parameter.getDecimalField(CostCalculationFields.ADDITIONAL_OVERHEAD), view, true);
        fillWithPropertyOrZero(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD, parameter.getDecimalField(CostCalculationFields.REGISTRATION_PRICE_OVERHEAD), view, true);
        fillWithPropertyOrZero(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD, parameter.getDecimalField(CostCalculationFields.TECHNICAL_PRODUCTION_COST_OVERHEAD), view, true);
        fillWithPropertyOrZero(CostCalculationFields.PROFIT, parameter.getDecimalField(CostCalculationFields.PROFIT), view, true);
        isSetFieldsFromParameter.setFieldValue(true);
        isSetFieldsFromParameter.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) 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