use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method removeOnlySelectedOperation.
public void removeOnlySelectedOperation(final ViewDefinitionState view, final ComponentState state, final String[] args) {
final TreeComponent technologyTree = (TreeComponent) view.getComponentByReference(L_TECHNOLOGY_TREE_REFERENCE);
final Long selectedEntityId = technologyTree.getSelectedEntityId();
Entity selectedOperation = getTechnologyOperationComponentDD().get(selectedEntityId);
boolean removed = removeTOCService.removeOnlySelectedOperation(selectedOperation, view);
if (removed) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
technologyForm.performEvent(view, "reset");
view.addMessage("technologies.technologyDetails.window.treeTab.technologyTree.success", ComponentState.MessageType.SUCCESS);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method acceptTemplate.
public void acceptTemplate(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent isTemplateAcceptedCheckBox = (CheckBoxComponent) view.getComponentByReference(TechnologyFields.IS_TEMPLATE_ACCEPTED);
Entity technology = technologyForm.getEntity();
Long technologyId = technology.getId();
boolean isTemplateAccepted = isTemplateAcceptedCheckBox.isChecked();
if (Objects.nonNull(technologyId)) {
technology = technology.getDataDefinition().save(technology);
if (isTemplateAccepted || validateTemplate(technologyForm, technology.getDataDefinition().get(technologyId))) {
isTemplateAcceptedCheckBox.setChecked(!isTemplateAccepted);
technologyForm.performEvent(view, "save");
if (technologyForm.isHasError()) {
isTemplateAcceptedCheckBox.setChecked(isTemplateAccepted);
}
}
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method openOperationProductInComponentsImportPage.
public void openOperationProductInComponentsImportPage(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
Long technologyId = technology.getId();
if (Objects.nonNull(technologyId)) {
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", technologyId);
JSONObject context = new JSONObject(parameters);
String url = "../page/technologies/operationProductInComponentsImport.html?context=" + context.toString();
view.openModal(url);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ModifyTechnologyListeners method createTechnologies.
public void createTechnologies(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
componentState.performEvent(view, L_SAVE, args);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(L_GENERATED);
FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (!formComponent.isValid()) {
return;
}
Entity mt = formComponent.getEntity().getDataDefinition().get(formComponent.getEntityId());
ModifyTechnologyResult modifyTechnologyResult = new ModifyTechnologyResult();
createModifiedTechnology(view, componentState, mt, modifyTechnologyResult);
if (!modifyTechnologyResult.getCreatedTechnologies().isEmpty()) {
view.addMessage("technologies.modifyTechnology.createdTechnologies", ComponentState.MessageType.SUCCESS, String.join(",", modifyTechnologyResult.getCreatedTechnologies()));
}
if (!modifyTechnologyResult.getNotCreatedTechnologies().isEmpty()) {
view.addMessage("technologies.modifyTechnology.notCreatedTechnologies", ComponentState.MessageType.FAILURE, String.join(",", modifyTechnologyResult.getNotCreatedTechnologies()));
}
generated.setChecked(true);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class OperationDetailsListeners method addUpTheNumberOfWorkstations.
public void addUpTheNumberOfWorkstations(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
int size = form.getPersistedEntityWithIncludedFormValues().getHasManyField(OperationFields.WORKSTATIONS).size();
FieldComponent quantityOfWorkstations = (FieldComponent) view.getComponentByReference(OperationFields.QUANTITY_OF_WORKSTATIONS);
quantityOfWorkstations.setFieldValue(size);
quantityOfWorkstations.requestComponentUpdateState();
}
Aggregations