use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TOCProcessListDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
Long operationId = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getPersistedEntityWithIncludedFormValues().getBelongsToField(TechnologyOperationComponentFields.OPERATION).getId();
LookupComponent technologicalProcessList = (LookupComponent) view.getComponentByReference(TechnologyOperationComponentFields.TECHNOLOGICAL_PROCESS_LIST);
FilterValueHolder filterValueHolder = technologicalProcessList.getFilterValue();
filterValueHolder.put(TechnologicalProcessListFields.OPERATION, operationId);
technologicalProcessList.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechnologicalProcessComponentDetailsHooks 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();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method fillQualityCard.
public void fillQualityCard(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(TechnologyFields.PRODUCT);
Entity product = productLookup.getEntity();
if (Objects.nonNull(product)) {
LookupComponent qualityCardLookup = (LookupComponent) view.getComponentByReference(TechnologyFields.QUALITY_CARD);
List<Entity> entities = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_QUALITY_CARD).find().add(SearchRestrictions.eq(QualityCardFields.STATE, "02accepted")).createAlias(QualityCardFields.PRODUCTS, QualityCardFields.PRODUCTS, JoinType.INNER).add(SearchRestrictions.eq(QualityCardFields.PRODUCTS + ".id", product.getId())).list().getEntities();
if (entities.size() == 1) {
qualityCardLookup.setFieldValue(entities.get(0).getId());
} else {
qualityCardLookup.setFieldValue(null);
}
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class OPICDetailsListeners method fillUnitForTechnologyType.
private void fillUnitForTechnologyType(ViewDefinitionState view) {
LookupComponent technologyInputProductTypeLookup = (LookupComponent) view.getComponentByReference(OperationProductInComponentFields.TECHNOLOGY_INPUT_PRODUCT_TYPE);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.UNIT);
FieldComponent givenUnitField = (FieldComponent) view.getComponentByReference(OperationProductInComponentFields.GIVEN_UNIT);
Entity technologyInputProductType = technologyInputProductTypeLookup.getEntity();
String givenUnit = (String) givenUnitField.getFieldValue();
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OperationProductInComponentFields.PRODUCT);
if (productLookup.isEmpty() && Objects.nonNull(technologyInputProductType) && StringUtils.isNoneEmpty(givenUnit)) {
unitField.setFieldValue(givenUnit);
unitField.requestComponentUpdateState();
}
unitService.fillProductUnitBeforeRenderIfEmpty(view, OperationProductInComponentFields.UNIT);
unitService.fillProductUnitBeforeRenderIfEmpty(view, OperationProductInComponentFields.GIVEN_UNIT);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class GenerateTimeGapsListeners method clearOtherLineCriteriaLookupComponents.
public void clearOtherLineCriteriaLookupComponents(final ViewDefinitionState viewState, final ComponentState eventPerformer, final String[] arguments) {
if (((LookupComponent) eventPerformer).getEntity() == null) {
return;
}
LookupComponent techLookup = (LookupComponent) findComponentByReferenceName(viewState, "supportedTechnology");
LookupComponent techGroupLookup = (LookupComponent) findComponentByReferenceName(viewState, "supportedTechnologyGroup");
Iterable<LookupComponent> lookupComponents = Lists.newArrayList(techLookup, techGroupLookup);
for (LookupComponent lookupComponent : lookupComponents) {
if (lookupComponent.getName().equals(eventPerformer.getName())) {
continue;
}
lookupComponent.setFieldValue(null);
}
}
Aggregations