Search in sources :

Example 1 with ScreenContext

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

Example 2 with ScreenContext

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

the class SearchFieldImpl method performSearch.

public void performSearch() {
    Screen frameOwner = ComponentsHelper.getWindowNN(this).getFrameOwner();
    String searchText = getValue();
    ScreenContext screenContext = getScreenContext(frameOwner);
    if (StringUtils.isBlank(searchText)) {
        Notifications notifications = screenContext.getNotifications();
        notifications.create(HUMANIZED).withCaption(messages.getMessage("io.jmix.searchui.noSearchText")).show();
    } else {
        String preparedSearchText = searchText.trim();
        SearchContext searchContext = new SearchContext(preparedSearchText).setSize(searchProperties.getSearchResultPageSize()).setEntities(getEntities());
        SearchResult searchResult = entitySearcher.search(searchContext, searchStrategy);
        if (searchCompletedHandler != null) {
            searchCompletedHandler.accept(new SearchCompletedEvent(this, searchResult));
        }
    }
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) UiControllerUtils.getScreenContext(io.jmix.ui.screen.UiControllerUtils.getScreenContext) SearchResultsScreen(io.jmix.searchui.screen.result.SearchResultsScreen) Screen(io.jmix.ui.screen.Screen) SearchContext(io.jmix.search.searching.SearchContext) SearchResult(io.jmix.search.searching.SearchResult) Notifications(io.jmix.ui.Notifications)

Example 3 with ScreenContext

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

the class AbstractTable method showParseErrorNotification.

protected void showParseErrorNotification(String message) {
    ScreenContext screenContext = UiControllerUtils.getScreenContext(getFrame().getFrameOwner());
    screenContext.getNotifications().create(Notifications.NotificationType.TRAY).withDescription(message).show();
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext)

Example 4 with ScreenContext

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

the class RelatedEntitiesSupportImpl method buildScreen.

protected Screen buildScreen(RelatedEntitiesBuilder builder) {
    MetaClass metaClass = getMetaClass(builder);
    MetaProperty metaProperty = getMetaProperty(builder, metaClass);
    Screen screen = createScreen(builder, metaClass, metaProperty);
    boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> {
        if (screenComponent instanceof Filter) {
            Filter filter = (Filter) screenComponent;
            DataLoader dataLoader = filter.getDataLoader();
            MetaClass actualMetaClass = dataLoader.getContainer().getEntityMetaClass();
            MetaClass relatedMetaClass = metaProperty.getRange().asClass();
            MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(relatedMetaClass);
            if (Objects.equals(actualMetaClass, effectiveMetaClass)) {
                Collection selectedEntities = builder.getSelectedEntities() == null ? Collections.emptyList() : builder.getSelectedEntities();
                String configurationName = generateConfigurationName(builder, metaProperty);
                DesignTimeConfiguration configuration = createFilterConfiguration((Filter) screenComponent, configurationName);
                JpqlFilter jpqlFilter = createJpqlFilter(filter.getDataLoader(), metaProperty, metaClass, selectedEntities);
                configuration.getRootLogicalFilterComponent().add(jpqlFilter);
                configuration.setFilterComponentDefaultValue(jpqlFilter.getParameterName(), jpqlFilter.getValue());
                filter.setCurrentConfiguration(configuration);
                return true;
            }
        }
        return false;
    });
    if (!found) {
        screen.addAfterShowListener(event -> {
            ScreenContext screenContext = UiControllerUtils.getScreenContext(event.getSource());
            screenContext.getNotifications().create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage("actions.Related.FilterNotFound")).show();
        });
    }
    return screen;
}
Also used : DataLoader(io.jmix.ui.model.DataLoader) ScreenContext(io.jmix.ui.screen.ScreenContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) JpqlFilter(io.jmix.ui.component.JpqlFilter) Filter(io.jmix.ui.component.Filter) Screen(io.jmix.ui.screen.Screen) JpqlFilter(io.jmix.ui.component.JpqlFilter) DesignTimeConfiguration(io.jmix.ui.component.filter.configuration.DesignTimeConfiguration) Collection(java.util.Collection) MetaProperty(io.jmix.core.metamodel.model.MetaProperty)

Example 5 with ScreenContext

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

the class FilterRemoveAction method execute.

@Override
public void execute() {
    ScreenContext screenContext = ComponentsHelper.getScreenContext(filter);
    Dialogs dialogs = screenContext.getDialogs();
    dialogs.createOptionDialog().withCaption(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.caption")).withMessage(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.message")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(actionPerformedEvent -> filterSupport.removeCurrentFilterConfiguration(filter)), new DialogAction(DialogAction.Type.NO)).show();
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction)

Aggregations

ScreenContext (io.jmix.ui.screen.ScreenContext)9 Screen (io.jmix.ui.screen.Screen)4 Notifications (io.jmix.ui.Notifications)3 DialogAction (io.jmix.ui.action.DialogAction)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 Dialogs (io.jmix.ui.Dialogs)2 UiControllerUtils.getScreenContext (io.jmix.ui.screen.UiControllerUtils.getScreenContext)2 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 Metadata (io.jmix.core.Metadata)1 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 AbstractPrintFormAction (io.jmix.reportsui.action.AbstractPrintFormAction)1 SearchContext (io.jmix.search.searching.SearchContext)1 SearchResult (io.jmix.search.searching.SearchResult)1 SearchResultsScreen (io.jmix.searchui.screen.result.SearchResultsScreen)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Screens (io.jmix.ui.Screens)1 AbstractAction (io.jmix.ui.action.AbstractAction)1 Action (io.jmix.ui.action.Action)1