use of io.jmix.ui.screen.OpenMode in project jmix-sneferu by mariodavid.
the class ScreenOpenModeInteractionTest method when_interactionIsPerformed_then_openModeIsReturned.
@Test
void when_interactionIsPerformed_then_openModeIsReturned(UiTestAPI uiTestAPI) {
// given:
final Visit expectedVisit = dataManager.create(Visit.class);
// and:
StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class, expectedVisit);
// when:
final OpenMode actualOpenMode = visitEdit.andThenGet(screenOpenMode());
// then:
assertThat(actualOpenMode).isEqualTo(OpenMode.DIALOG);
}
use of io.jmix.ui.screen.OpenMode in project jmix by jmix-framework.
the class LinkCellClickListener method accept.
@Override
public void accept(Table.Column.ClickEvent clickEvent) {
if (!clickEvent.isText()) {
return;
}
Table.Column<?> column = clickEvent.getSource();
Table owner = column.getOwner();
if (owner == null || owner.getFrame() == null) {
return;
}
Object rowItem = clickEvent.getItem();
MetaPropertyPath mpp = column.getMetaPropertyPathNN();
Object item = EntityValues.getValueEx(rowItem, mpp);
Entity entity;
if (EntityValues.isEntity(item)) {
entity = (Entity) item;
} else {
entity = (Entity) rowItem;
}
if (EntityValues.isSoftDeleted(entity)) {
ScreenContext context = ComponentsHelper.getScreenContext(owner);
context.getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(applicationContext.getBean(Messages.class).getMessage("OpenAction.objectIsDeleted")).show();
return;
}
entity = loadEntity(entity);
MetaClass metaClass = applicationContext.getBean(Metadata.class).getClass(entity);
String linkScreenId = loadLinkScreenId(column, metaClass);
OpenMode openMode = loadLinkScreenOpenMode(column);
Screen editor = applicationContext.getBean(ScreenBuilders.class).editor(metaClass.getJavaClass(), owner.getFrame().getFrameOwner()).withScreenId(linkScreenId).editEntity(entity).withOpenMode(openMode).build();
editor.addAfterCloseListener(afterCloseEvent -> {
// move focus to component
owner.focus();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && editor instanceof EditorScreen) {
onEditScreenAfterCommit(mpp, rowItem, (EditorScreen) editor, owner);
}
});
editor.show();
}
Aggregations