Search in sources :

Example 1 with ProductionTrackingState

use of com.qcadoo.mes.productionCounting.states.constants.ProductionTrackingState in project mes by qcadoo.

the class ProductionTrackingServiceImpl method setTimeAndPieceworkComponentsVisible.

@Override
public void setTimeAndPieceworkComponentsVisible(final ViewDefinitionState view, final Entity order) {
    String recordingType = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    boolean recordingTypeEqualsForEach = TypeOfProductionRecording.FOR_EACH.getStringValue().equals(recordingType);
    boolean recordingTypeEqualsBasic = TypeOfProductionRecording.BASIC.getStringValue().equals(recordingType);
    LookupComponent tocComponent = (LookupComponent) view.getComponentByReference(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT);
    tocComponent.setVisible(recordingTypeEqualsForEach);
    tocComponent.setRequired(recordingTypeEqualsForEach);
    boolean registerProductionTime = order.getBooleanField(OrderFieldsPC.REGISTER_PRODUCTION_TIME);
    view.getComponentByReference(L_TIME_TAB).setVisible(registerProductionTime && !recordingTypeEqualsBasic);
    ProductionTrackingState recordState = getTrackingState(view);
    final FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() != null) {
        WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
        RibbonActionItem calcTotalLaborTimeBtn = window.getRibbon().getGroupByName(L_WORK_TIME_RIBBON_GROUP).getItemByName(L_CALC_LABOR_TOTAL_TIME_RIBBON_BUTTON);
        calcTotalLaborTimeBtn.setEnabled(registerProductionTime && !recordingTypeEqualsBasic && ProductionTrackingState.DRAFT.equals(recordState));
        calcTotalLaborTimeBtn.requestUpdate(true);
    }
    boolean registerPiecework = order.getBooleanField(OrderFieldsPC.REGISTER_PIECEWORK);
    view.getComponentByReference(L_PIECEWORK_TAB).setVisible(registerPiecework && recordingTypeEqualsForEach);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) ProductionTrackingState(com.qcadoo.mes.productionCounting.states.constants.ProductionTrackingState) LookupComponent(com.qcadoo.view.api.components.LookupComponent) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

ProductionTrackingState (com.qcadoo.mes.productionCounting.states.constants.ProductionTrackingState)1 FormComponent (com.qcadoo.view.api.components.FormComponent)1 LookupComponent (com.qcadoo.view.api.components.LookupComponent)1 WindowComponent (com.qcadoo.view.api.components.WindowComponent)1 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)1