use of org.kie.workbench.common.forms.editor.model.FormModelerContentError in project kie-wb-common by kiegroup.
the class ErrorMessageDisplayerTest method fullMessageTest.
@Test
public void fullMessageTest() {
verify(view).init(displayer);
FormModelerContentError error = new FormModelerContentError(MESSAGE, new String[1], FULL_MESSAGE, new String[1], SOURCE_TYPE);
displayer.show(error, closeCommand);
verify(translationService).format(eq(MESSAGE), any());
verify(translationService).format(eq(FULL_MESSAGE), any());
verify(translationService).getTranslation(eq(SOURCE_TYPE));
verify(view).setSourceType(eq(SOURCE_TYPE));
verify(view).displayShowMoreAnchor(true);
verify(translationService, times(1)).getTranslation(FormEditorConstants.ShowMoreLabel);
verify(view, times(1)).setShowMoreLabel(any());
verify(view).show(MESSAGE);
displayer.notifyShowMorePressed();
verify(view, times(1)).show(eq(FULL_MESSAGE));
verify(translationService, times(1)).getTranslation(FormEditorConstants.ShowLessLabel);
verify(view, times(2)).setShowMoreLabel(any());
displayer.notifyShowMorePressed();
verify(view, times(2)).show(eq(MESSAGE));
verify(translationService, times(2)).getTranslation(FormEditorConstants.ShowMoreLabel);
verify(view, times(3)).setShowMoreLabel(any());
displayer.notifyShowMorePressed();
verify(view, times(2)).show(eq(FULL_MESSAGE));
verify(translationService, times(2)).getTranslation(FormEditorConstants.ShowLessLabel);
verify(view, times(4)).setShowMoreLabel(any());
displayer.notifyClose();
verify(closeCommand, never()).execute();
when(view.isClose()).thenReturn(true);
displayer.notifyClose();
verify(closeCommand).execute();
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContentError in project kie-wb-common by kiegroup.
the class FormEditorPresenter method doLoadContent.
public void doLoadContent(final FormModelerContent content) {
busyIndicatorView.hideBusyIndicator();
// Clear LayoutEditor before loading new content.
if (editorHelper.getContent() != null) {
layoutEditor.clear();
}
editorHelper.initHelper(content);
resetEditorPages(content.getOverview());
view.init(this);
if (content.getError() != null) {
FormModelerContentError error = content.getError();
errorMessageDisplayer.show(error, () -> placeManager.forceClosePlace(place));
errorMessageDisplayer.enableContinue(content.getDefinition() != null);
}
if (content.getDefinition() != null) {
loadEditor(content);
}
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContentError in project kie-wb-common by kiegroup.
the class FormEditorServiceImpl method constructContent.
@Override
protected FormModelerContent constructContent(Path path, Overview overview) {
FormModelerContent formModelConent = new FormModelerContent();
try {
org.uberfire.java.nio.file.Path kiePath = Paths.convert(path);
FormDefinition form = findForm(kiePath);
formModelConent.setDefinition(form);
formModelConent.setPath(path);
formModelConent.setOverview(overview);
FormEditorRenderingContext context = createRenderingContext(form, path);
formModelConent.setRenderingContext(context);
if (Optional.ofNullable(form.getModel()).isPresent()) {
FormModel formModel = form.getModel();
Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form);
if (modelHandlerOptional.isPresent()) {
try {
FormModelHandler formModelHandler = modelHandlerOptional.get();
formModelHandler.init(formModel, path);
formModelHandler.checkSourceModel();
FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel();
formModel.getProperties().forEach(property -> {
Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName()));
if (!fieldOptional.isPresent()) {
synchronizationResult.resolveConflict(property.getName());
}
});
formModelConent.setSynchronizationResult(synchronizationResult);
} catch (SourceFormModelNotFoundException ex) {
formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey()));
}
}
}
} catch (Exception e) {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] { writer.toString() }, null));
log.warn("Error loading form " + path.toURI(), e);
}
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo));
return formModelConent;
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContentError in project kie-wb-common by kiegroup.
the class ErrorMessageDisplayerTest method simpleMessageTest.
@Test
public void simpleMessageTest() {
verify(view).init(displayer);
FormModelerContentError error = new FormModelerContentError(MESSAGE, null, null, null, SOURCE_TYPE);
displayer.show(error, closeCommand);
verify(translationService).getTranslation(MESSAGE);
verify(translationService).getTranslation(SOURCE_TYPE);
verify(view).setSourceType(eq(SOURCE_TYPE));
verify(view).displayShowMoreAnchor(false);
verify(view, never()).setShowMoreLabel(any());
verify(view).show(eq(MESSAGE));
displayer.notifyShowMorePressed();
verify(view, times(1)).show(any());
verify(translationService, never()).getTranslation(FormEditorConstants.ShowLessLabel);
verify(view, never()).setShowMoreLabel(any());
displayer.notifyShowMorePressed();
verify(view, times(1)).show(any());
verify(translationService, never()).getTranslation(FormEditorConstants.ShowMoreLabel);
verify(view, never()).setShowMoreLabel(any());
}
Aggregations