Search in sources :

Example 1 with OpenMode

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);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OpenMode(io.jmix.ui.screen.OpenMode) Interactions.screenOpenMode(de.diedavids.sneferu.Interactions.screenOpenMode) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 2 with OpenMode

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();
}
Also used : Entity(io.jmix.core.Entity) Table(io.jmix.ui.component.Table) Messages(io.jmix.core.Messages) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) Metadata(io.jmix.core.Metadata) OpenMode(io.jmix.ui.screen.OpenMode) ScreenContext(io.jmix.ui.screen.ScreenContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) EditorScreen(io.jmix.ui.screen.EditorScreen) ScreenBuilders(io.jmix.ui.ScreenBuilders)

Aggregations

OpenMode (io.jmix.ui.screen.OpenMode)2 Interactions.screenOpenMode (de.diedavids.sneferu.Interactions.screenOpenMode)1 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)1 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 Metadata (io.jmix.core.Metadata)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 Visit (io.jmix.petclinic.entity.visit.Visit)1 VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Table (io.jmix.ui.component.Table)1 EditorScreen (io.jmix.ui.screen.EditorScreen)1 Screen (io.jmix.ui.screen.Screen)1 ScreenContext (io.jmix.ui.screen.ScreenContext)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1