Search in sources :

Example 6 with ComponentState

use of com.qcadoo.view.api.ComponentState in project qcadoo by qcadoo.

the class ViewDefinitionStateImpl method getComponentByPath.

private ComponentState getComponentByPath(final String path) {
    ComponentState componentState = this;
    String[] pathParts = path.split("\\.");
    for (int i = 0; i < pathParts.length; i++) {
        ContainerState container = (ContainerState) componentState;
        componentState = container.getChild(pathParts[i]);
        if (componentState == null) {
            return null;
        }
    }
    return componentState;
}
Also used : AbstractContainerState(com.qcadoo.view.internal.states.AbstractContainerState) ContainerState(com.qcadoo.view.internal.api.ContainerState) ComponentState(com.qcadoo.view.api.ComponentState) InternalComponentState(com.qcadoo.view.internal.api.InternalComponentState)

Example 7 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class WarehouseIssueDetailHooks method hideComponents.

private void hideComponents(final ViewDefinitionState view, final String... names) {
    for (String name : names) {
        ComponentState component = view.getComponentByReference(name);
        component.setVisible(false);
    }
}
Also used : ComponentState(com.qcadoo.view.api.ComponentState)

Example 8 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class TechnologyDetailsHooksPFTD method showHideDivisionField.

public void showHideDivisionField(final ViewDefinitionState view) {
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    FieldComponent divisionField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
    String range = (String) rangeField.getFieldValue();
    GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
    ComponentState operationRangeDescriptionLabel = view.getComponentByReference(OPERATION_RANGE_DESCRIPTION);
    if (Range.ONE_DIVISION.getStringValue().equals(range)) {
        showField(divisionField, true);
        rangeTechnologyOperationComponent.setVisible(false);
        operationRangeDescriptionLabel.setVisible(false);
    } else {
        showField(divisionField, false);
        rangeTechnologyOperationComponent.setVisible(true);
        operationRangeDescriptionLabel.setVisible(true);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 9 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class TechnologyDetailsHooksPFTD method hideWorkstationsTableForCumulatedProductionRecording.

private void hideWorkstationsTableForCumulatedProductionRecording(final ViewDefinitionState view) {
    FieldComponent typeOfProductionRecordingFieldComponent = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    GridComponent workstationsTechnologyOperationComponent = (GridComponent) view.getComponentByReference(WORKSTATIONS_TECHNOLOGY_OPERATION_COMPONENT);
    GridComponent workstations = (GridComponent) view.getComponentByReference(WORKSTATIONS);
    ComponentState operationWorkstationsDescriptionLabel = view.getComponentByReference(OPERATION_WORKSTATIONS_DESCRIPTION);
    if (Objects.nonNull(typeOfProductionRecordingFieldComponent) && TypeOfProductionRecording.FOR_EACH.getStringValue().equals(typeOfProductionRecordingFieldComponent.getFieldValue())) {
        workstationsTechnologyOperationComponent.setVisible(true);
        workstations.setVisible(true);
        operationWorkstationsDescriptionLabel.setVisible(true);
    } else {
        workstationsTechnologyOperationComponent.setVisible(false);
        workstations.setVisible(false);
        operationWorkstationsDescriptionLabel.setVisible(false);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 10 with ComponentState

use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.

the class ProductionTrackingServiceImpl method changeProducedQuantityFieldState.

@Override
public void changeProducedQuantityFieldState(final ViewDefinitionState viewDefinitionState) {
    final FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity order = null;
    if (form.getEntityId() != null) {
        order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
    }
    FieldComponent typeOfProductionRecording = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    ComponentState doneQuantity = viewDefinitionState.getComponentByReference(L_DONE_QUANTITY);
    ComponentState amountOfPP = viewDefinitionState.getComponentByReference(L_AMOUNT_OF_PRODUCT_PRODUCED);
    if (order == null || order.getStringField(OrderFields.STATE).equals(OrderState.PENDING.getStringValue()) || order.getStringField(OrderFields.STATE).equals(OrderState.ACCEPTED.getStringValue())) {
        doneQuantity.setEnabled(false);
        amountOfPP.setEnabled(false);
    } else if ("".equals(typeOfProductionRecording.getFieldValue()) || TypeOfProductionRecording.BASIC.getStringValue().equals(typeOfProductionRecording.getFieldValue())) {
        doneQuantity.setEnabled(true);
        amountOfPP.setEnabled(true);
    } else {
        doneQuantity.setEnabled(false);
        amountOfPP.setEnabled(false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Aggregations

ComponentState (com.qcadoo.view.api.ComponentState)68 Entity (com.qcadoo.model.api.Entity)33 FormComponent (com.qcadoo.view.api.components.FormComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)23 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)21 Autowired (org.springframework.beans.factory.annotation.Autowired)17 FieldComponent (com.qcadoo.view.api.components.FieldComponent)16 Test (org.junit.Test)16 Service (org.springframework.stereotype.Service)16 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)15 Collectors (java.util.stream.Collectors)14 List (java.util.List)13 DataDefinition (com.qcadoo.model.api.DataDefinition)12 Lists (com.google.common.collect.Lists)11 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)11 Map (java.util.Map)11 BigDecimal (java.math.BigDecimal)10 Maps (com.google.common.collect.Maps)8 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 Transactional (org.springframework.transaction.annotation.Transactional)8