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);
}
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);
}
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();
}
}
}
}
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);
}
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);
}
}
Aggregations