Search in sources :

Example 71 with LookupComponent

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

the class EventHooks method toggleEnabledForWorkstation.

private void toggleEnabledForWorkstation(final ViewDefinitionState view, final Entity event) {
    boolean enabled = event.getBelongsToField(MaintenanceEventFields.PRODUCTION_LINE) != null;
    LookupComponent workstation = (LookupComponent) view.getComponentByReference(MaintenanceEventFields.WORKSTATION);
    workstation.setEnabled(enabled);
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 72 with LookupComponent

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

the class EventHooks method toggleEnabledForFactory.

private void toggleEnabledForFactory(final ViewDefinitionState view, final Entity event, String contextField) {
    if (event.getBelongsToField(contextField) == null) {
        return;
    }
    boolean enabled = event.getBelongsToField(contextField).getBelongsToField(MaintenanceEventContextFields.FACTORY) == null;
    LookupComponent factoryLookup = (LookupComponent) view.getComponentByReference(MaintenanceEventFields.FACTORY);
    factoryLookup.setEnabled(enabled);
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 73 with LookupComponent

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

the class EventHooks method fillDefaultFieldsFromContext.

public void fillDefaultFieldsFromContext(final ViewDefinitionState view, String contextField) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() == null) {
        Entity event = form.getEntity();
        Entity eventContext = event.getBelongsToField(contextField);
        if (eventContext != null) {
            Entity factoryEntity = eventContext.getBelongsToField(MaintenanceEventContextFields.FACTORY);
            if (factoryEntity != null) {
                FieldComponent factoryField = (FieldComponent) view.getComponentByReference(MaintenanceEventFields.FACTORY);
                factoryField.setFieldValue(factoryEntity.getId());
                factoryField.requestComponentUpdateState();
                fillSourceCost(view, factoryEntity);
            } else {
                LookupComponent sc = (LookupComponent) view.getComponentByReference("sourceCost");
                if (sc.isEmpty()) {
                    fillSourceCost(view);
                }
            }
            Entity divisionEntity = eventContext.getBelongsToField(MaintenanceEventContextFields.DIVISION);
            if (divisionEntity != null) {
                FieldComponent divisionField = (FieldComponent) view.getComponentByReference(MaintenanceEventFields.DIVISION);
                divisionField.setFieldValue(divisionEntity.getId());
                divisionField.requestComponentUpdateState();
            }
        }
    }
}
Also used : 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)

Example 74 with LookupComponent

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

the class EventHooks method setUpFaultTypeLookup.

private void setUpFaultTypeLookup(final ViewDefinitionState view) {
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent faultTypeLookup = (LookupComponent) view.getComponentByReference(MaintenanceEventFields.FAULT_TYPE);
    Entity event = formComponent.getPersistedEntityWithIncludedFormValues();
    Entity workstation = event.getBelongsToField(MaintenanceEventFields.WORKSTATION);
    Entity subassembly = event.getBelongsToField(MaintenanceEventFields.SUBASSEMBLY);
    FilterValueHolder filter = faultTypeLookup.getFilterValue();
    if (workstation == null) {
        filter.remove(MaintenanceEventFields.WORKSTATION);
        filter.remove(WorkstationFields.WORKSTATION_TYPE);
        filter.remove(MaintenanceEventFields.SUBASSEMBLY);
    } else {
        filter.put(MaintenanceEventFields.WORKSTATION, workstation.getId());
        if (subassembly == null) {
            filter.remove(MaintenanceEventFields.SUBASSEMBLY);
            Entity workstationType = workstation.getBelongsToField(WorkstationFields.WORKSTATION_TYPE);
            filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
        } else {
            Entity workstationType = subassembly.getBelongsToField(SubassemblyFields.WORKSTATION_TYPE);
            filter.put(MaintenanceEventFields.SUBASSEMBLY, subassembly.getId());
            filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
        }
    }
    faultTypeLookup.setFilterValue(filter);
}
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)

Example 75 with LookupComponent

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

the class EventHooks method setEventCriteriaModifier.

private void setEventCriteriaModifier(ViewDefinitionState view, Entity event, String fieldFrom, String fieldTo) {
    LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(fieldTo);
    Entity value = event.getBelongsToField(fieldFrom);
    if (value != null) {
        FilterValueHolder holder = lookupComponent.getFilterValue();
        holder.put(fieldFrom, value.getId());
        lookupComponent.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Aggregations

LookupComponent (com.qcadoo.view.api.components.LookupComponent)277 Entity (com.qcadoo.model.api.Entity)182 FieldComponent (com.qcadoo.view.api.components.FieldComponent)105 FormComponent (com.qcadoo.view.api.components.FormComponent)102 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)69 BigDecimal (java.math.BigDecimal)16 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)12 GridComponent (com.qcadoo.view.api.components.GridComponent)11 WindowComponent (com.qcadoo.view.api.components.WindowComponent)8 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)7 Date (java.util.Date)6 JSONObject (org.json.JSONObject)6 ComponentState (com.qcadoo.view.api.ComponentState)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)5 JSONException (org.json.JSONException)5 DataDefinition (com.qcadoo.model.api.DataDefinition)3 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)3 Optional (com.google.common.base.Optional)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2