Search in sources :

Example 1 with Screen

use of io.jmix.ui.screen.Screen in project jmix-sneferu by mariodavid.

the class VisitBrowse method onCalendarCalendarEventClick.

@Subscribe("calendar")
protected void onCalendarCalendarEventClick(Calendar.CalendarEventClickEvent<LocalDateTime> event) {
    Screen visitEditor = screenBuilders.editor(Visit.class, this).editEntity((Visit) event.getEntity()).withOpenMode(OpenMode.DIALOG).build();
    visitEditor.addAfterCloseListener(afterCloseEvent -> {
        if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            getScreenData().loadAll();
        }
    });
    visitEditor.show();
}
Also used : Screen(io.jmix.ui.screen.Screen) Visit(io.jmix.petclinic.entity.visit.Visit) Subscribe(io.jmix.ui.screen.Subscribe)

Example 2 with Screen

use of io.jmix.ui.screen.Screen in project jmix-sneferu by mariodavid.

the class VisitBrowse method onCalendarCalendarDayClick.

// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// Calendar Visit Event Click
// ///////////////////////////////////////////////////////////////////////////////////////////////////////
@Subscribe("calendar")
protected void onCalendarCalendarDayClick(Calendar.CalendarDayClickEvent<LocalDateTime> event) {
    Screen visitEditor = screenBuilders.editor(Visit.class, this).newEntity().withInitializer(visit -> {
        visit.setVisitStart(event.getDate());
        visit.setVisitEnd(event.getDate().plusHours(1));
    }).withOpenMode(OpenMode.DIALOG).build();
    visitEditor.addAfterCloseListener(afterCloseEvent -> {
        if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            getScreenData().loadAll();
        }
    });
    visitEditor.show();
}
Also used : Screen(io.jmix.ui.screen.Screen) Subscribe(io.jmix.ui.screen.Subscribe)

Example 3 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class RelatedEntitiesBean method openRelatedScreen.

@Override
public void openRelatedScreen(Collection<? extends Entity> selectedEntities, MetaClass metaClass, MetaProperty metaProperty, @Nullable RelatedScreenDescriptor descriptor) {
    checkNotNullArgument(metaClass, "MetaClass can't be null");
    checkNotNullArgument(metaProperty, "MetaProperty can't be null");
    WindowManager windowManager = windowManagerProvider.get();
    if (!selectedEntities.isEmpty()) {
        Map<String, Object> params = new HashMap<>();
        WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
        WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
        if (descriptor != null && descriptor.getScreenParams() != null) {
            params.putAll(descriptor.getScreenParams());
        }
        String screenId;
        if (descriptor != null && StringUtils.isNotEmpty(descriptor.getScreenId())) {
            screenId = descriptor.getScreenId();
        } else {
            screenId = windowConfig.getBrowseScreenId(metaProperty.getRange().asClass());
        }
        if (StringUtils.isEmpty(screenId)) {
            String message = String.format("Can't show related entities: passed screenId is null and " + "there is no default browse screen for %s", metaClass.getName());
            throw new IllegalStateException(message);
        }
        WindowManager.OpenType openType = WindowManager.OpenType.THIS_TAB;
        if (descriptor != null) {
            openType = descriptor.getOpenType();
        }
        Screen screen = ((CubaScreens) windowManager).create(screenId, openType.getOpenMode(), new MapScreenOptions(params));
        boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> {
            if (!(screenComponent instanceof Filter)) {
                return false;
            } else {
                MetaClass actualMetaClass = ((FilterImplementation) screenComponent).getEntityMetaClass();
                MetaClass relatedMetaClass = metaProperty.getRange().asClass();
                MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(relatedMetaClass);
                if (Objects.equals(actualMetaClass, effectiveMetaClass)) {
                    MetaDataDescriptor metaDataDescriptor = new MetaDataDescriptor(metaClass, metaProperty);
                    applyFilter(((Filter) screenComponent), selectedEntities, descriptor, metaDataDescriptor);
                    return true;
                }
                return false;
            }
        });
        screen.show();
        if (!found) {
            windowManager.showNotification(messages.getMainMessage("actions.Related.FilterNotFound"), NotificationType.WARNING);
        }
        if (screen instanceof LegacyFrame) {
            LegacyFrame legacyFrame = (LegacyFrame) screen;
            ((DsContextImplementation) legacyFrame.getDsContext()).resumeSuspended();
        }
    } else {
        windowManager.showNotification(messages.getMainMessage("actions.Related.NotSelected"), NotificationType.HUMANIZED);
    }
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) Screen(io.jmix.ui.screen.Screen) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) CubaScreens(com.haulmont.cuba.web.sys.CubaScreens) WindowManager(com.haulmont.cuba.gui.WindowManager) FilterImplementation(io.jmix.ui.component.FilterImplementation) MetaClass(io.jmix.core.metamodel.model.MetaClass) Filter(com.haulmont.cuba.gui.components.Filter) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions)

Example 4 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class UserActionsButtonImpl method openSettings.

protected void openSettings() {
    if (AppUI.getCurrent() != null) {
        Screen settingsScreen = AppUI.getCurrent().getScreens().create("settings", OpenMode.NEW_TAB);
        settingsScreen.show();
    }
}
Also used : Screen(io.jmix.ui.screen.Screen)

Example 5 with Screen

use of io.jmix.ui.screen.Screen 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

Screen (io.jmix.ui.screen.Screen)82 EditorScreen (io.jmix.ui.screen.EditorScreen)20 LookupScreen (io.jmix.ui.screen.LookupScreen)15 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)11 Nullable (javax.annotation.Nullable)9 Messages (io.jmix.core.Messages)6 WindowImpl (io.jmix.ui.component.impl.WindowImpl)6 Screens (io.jmix.ui.Screens)5 io.jmix.ui.component (io.jmix.ui.component)5 NavigationState (io.jmix.ui.navigation.NavigationState)5 FrameOwner (io.jmix.ui.screen.FrameOwner)5 UiControllerUtils (io.jmix.ui.screen.UiControllerUtils)5 java.util (java.util)5 Collectors (java.util.stream.Collectors)5 LoggerFactory (org.slf4j.LoggerFactory)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 BaseAction (io.jmix.ui.action.BaseAction)4