use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelper method getFormField.
public FieldDefinition getFormField(String fieldId) {
FieldDefinition result = content.getDefinition().getFieldById(fieldId);
if (result == null) {
result = availableFields.get(fieldId);
if (result == null) {
if (unbindedFields.containsKey(fieldId)) {
Pair<EditorFieldLayoutComponent, FieldDefinition> pair = unbindedFields.get(fieldId);
result = pair.getK2();
result.setLabel(result.getFieldType().getTypeName());
if (result instanceof HasPlaceHolder) {
((HasPlaceHolder) result).setPlaceHolder(result.getFieldType().getTypeName());
}
unbindedFields.remove(result.getId());
FieldDefinition newField = fieldManager.getDefinitionByFieldType(result.getFieldType());
newField.setName(generateUnboundFieldName(newField));
EditorFieldLayoutComponent component = pair.getK1();
component.init(content.getRenderingContext(), newField);
unbindedFields.put(newField.getId(), new Pair<>(component, newField));
}
}
}
return result;
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelper method switchToFieldType.
public FieldDefinition switchToFieldType(FieldDefinition field, String fieldCode) {
FieldDefinition resultDefinition = fieldManager.getFieldFromProvider(fieldCode, field.getFieldTypeInfo());
resultDefinition.copyFrom(field);
resultDefinition.setId(field.getId());
resultDefinition.setName(field.getName());
removeField(field.getId(), false);
return resultDefinition;
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelper method removeField.
public void removeField(String fieldId, boolean addToAvailables) {
FormDefinition formDefinition = content.getDefinition();
FieldDefinition fieldToRemove = formDefinition.getFieldById(fieldId);
if (fieldToRemove != null) {
formDefinition.getFields().remove(fieldToRemove);
if (addToAvailables) {
FieldDefinition originalField = fieldToRemove;
if (fieldToRemove.getBinding() == null) {
return;
}
ModelProperty property = formDefinition.getModel().getProperty(fieldToRemove.getBinding());
fieldToRemove = fieldManager.getDefinitionByModelProperty(property);
fieldToRemove.setId(originalField.getId());
availableFields.put(fieldToRemove.getId(), fieldToRemove);
}
}
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorPresenter method addAllDraggableGroupComponent.
protected void addAllDraggableGroupComponent(Collection<FieldDefinition> fields) {
String groupId = translationService.getTranslation(FormEditorConstants.FormEditorPresenterModelFields);
Iterator<FieldDefinition> it = fields.iterator();
while (it.hasNext()) {
FieldDefinition field = it.next();
EditorFieldLayoutComponent layoutFieldComponent = editorFieldLayoutComponents.get();
if (layoutFieldComponent != null) {
layoutFieldComponent.init(editorHelper.getRenderingContext(), field);
layoutDragComponentPalette.addDraggableComponent(groupId, field.getId(), layoutFieldComponent);
}
}
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class ChangesNotificationDisplayer method checkNewModelFields.
protected void checkNewModelFields() {
FormModelSynchronizationResult synchronizationResult = content.getSynchronizationResult();
if (synchronizationResult != null && synchronizationResult.hasNewProperties()) {
Set<FieldDefinition> modelFields = synchronizationResult.getNewProperties().stream().filter(modelProperty -> content.getDefinition().getFieldByBinding(modelProperty.getName()) == null).map(fieldManager::getDefinitionByModelProperty).collect(Collectors.toSet());
if (!modelFields.isEmpty()) {
this.canDisplay = true;
newPropertiesDisplayer.showAvailableFields(modelFields);
view.getElement().appendChild(newPropertiesDisplayer.getElement());
}
}
}
Aggregations