Search in sources :

Example 1 with Notifications

use of io.jmix.ui.Notifications in project jmix-docs by Haulmont.

the class ShowSelectedAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (getTarget() != null) {
        Object selected = getTarget().getSingleSelected();
        if (selected != null) {
            Notifications notifications = ComponentsHelper.getScreenContext(target).getNotifications();
            notifications.create().withType(Notifications.NotificationType.TRAY).withDescription(description).withCaption(metadataTools.getInstanceName(selected)).show();
        }
    }
}
Also used : Notifications(io.jmix.ui.Notifications)

Example 2 with Notifications

use of io.jmix.ui.Notifications in project jmix by jmix-framework.

the class FilteringLookupAction method afterLookupWindowOpened.

@Override
protected void afterLookupWindowOpened(Window lookupWindow) {
    boolean found = ComponentsHelper.walkComponents(lookupWindow, screenComponent -> {
        if (!(screenComponent instanceof Filter)) {
            return false;
        } else {
            MetaClass actualMetaClass = ((FilterImplementation) screenComponent).getEntityMetaClass();
            MetaClass propertyMetaClass = extendedEntities.getEffectiveMetaClass(pickerField.getMetaClass());
            if (Objects.equals(actualMetaClass, propertyMetaClass)) {
                applyFilter(((Filter) screenComponent));
                return true;
            }
            return false;
        }
    });
    if (!found) {
        Notifications notifications = ComponentsHelper.getScreenContext(pickerField).getNotifications();
        notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMainMessage("dynamicAttributes.entity.filter.filterNotFound")).show();
    }
    AbstractWindow controller = (AbstractWindow) (lookupWindow).getFrameOwner();
    ((DsContextImplementation) controller.getDsContext()).resumeSuspended();
}
Also used : AbstractWindow(com.haulmont.cuba.gui.components.AbstractWindow) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) MetaClass(io.jmix.core.metamodel.model.MetaClass) Filter(com.haulmont.cuba.gui.components.Filter) Notifications(io.jmix.ui.Notifications) FilterImplementation(io.jmix.ui.component.FilterImplementation)

Example 3 with Notifications

use of io.jmix.ui.Notifications in project jmix by jmix-framework.

the class AppFolderEditWindow method commit.

@Override
protected void commit() {
    AppUI appUI = AppUI.getCurrent();
    if (appUI == null) {
        return;
    }
    Notifications notifications = appUI.getNotifications();
    AppFolder folder = (AppFolder) AppFolderEditWindow.this.folder;
    if (StringUtils.trimToNull(nameField.getValue()) == null) {
        String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.emptyName");
        notifications.create(Notifications.NotificationType.TRAY).withCaption(msg).show();
        return;
    }
    folder.setName(nameField.getValue());
    folder.setTabName(tabNameField.getValue());
    if (sortOrderField.getValue() == null || "".equals(sortOrderField.getValue())) {
        folder.setSortOrder(null);
    } else {
        String value = sortOrderField.getValue();
        int sortOrder;
        try {
            sortOrder = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.invalidSortOrder");
            notifications.create(Notifications.NotificationType.TRAY).withCaption(msg).show();
            return;
        }
        folder.setSortOrder(sortOrder);
    }
    Object parent = parentSelect.getValue();
    if (parent instanceof Folder) {
        folder.setParent((Folder) parent);
    } else {
        folder.setParent(null);
    }
    if (visibilityScriptField != null) {
        String scriptText = visibilityScriptField.getValue();
        folder.setVisibilityScript(scriptText);
    }
    if (quantityScriptField != null) {
        String scriptText = quantityScriptField.getValue();
        folder.setQuantityScript(scriptText);
    }
    folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
    AppFolderEditWindow.this.commitHandler.run();
    forceClose();
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AppFolder(com.haulmont.cuba.core.entity.AppFolder) Folder(com.haulmont.cuba.core.entity.Folder) AppUI(io.jmix.ui.AppUI) Notifications(io.jmix.ui.Notifications)

Example 4 with Notifications

use of io.jmix.ui.Notifications 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 5 with Notifications

use of io.jmix.ui.Notifications in project jmix by jmix-framework.

the class BulkEditAction method execute.

/**
 * Executes the action.
 */
@SuppressWarnings("unchecked")
@Override
public void execute() {
    if (!(target.getItems() instanceof EntityDataUnit)) {
        throw new IllegalStateException("BulkEditAction target Items is null " + "or does not implement EntityDataUnit");
    }
    MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    if (metaClass == null) {
        throw new IllegalStateException("Target is not bound to entity");
    }
    UiBulkEditContext context = new UiBulkEditContext();
    accessManager.applyRegisteredConstraints(context);
    if (!context.isPermitted()) {
        if (target.getFrame() != null) {
            Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
            notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("accessDenied.message")).show();
        }
        return;
    }
    if (target.getSelected().isEmpty() && target.getFrame() != null) {
        Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
        notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("actions.BulkEdit.emptySelection")).show();
        return;
    }
    Window window = ComponentsHelper.getWindowNN(target);
    BulkEditorBuilder<?> builder = bulkEditors.builder(metaClass, target.getSelected(), window.getFrameOwner()).withListComponent(target);
    if (columnsMode != null) {
        builder = builder.withColumnsMode(columnsMode);
    }
    if (exclude != null) {
        builder = builder.withExclude(exclude);
    }
    if (fieldSorter != null) {
        builder = builder.withFieldSorter(fieldSorter);
    }
    if (includeProperties != null) {
        builder = builder.withIncludeProperties(includeProperties);
    }
    if (openMode != null) {
        builder = builder.withOpenMode(openMode);
    }
    if (useConfirmDialog != null) {
        builder = builder.withUseConfirmDialog(useConfirmDialog);
    }
    builder.create().show();
}
Also used : Window(io.jmix.ui.component.Window) UiBulkEditContext(io.jmix.ui.accesscontext.UiBulkEditContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) Notifications(io.jmix.ui.Notifications)

Aggregations

Notifications (io.jmix.ui.Notifications)23 MetaClass (io.jmix.core.metamodel.model.MetaClass)5 Screens (io.jmix.ui.Screens)4 Folder (com.haulmont.cuba.core.entity.Folder)2 Messages (io.jmix.core.Messages)2 ReportingException (io.jmix.reports.exception.ReportingException)2 AppUI (io.jmix.ui.AppUI)2 ScreenContext (io.jmix.ui.screen.ScreenContext)2 Nullable (javax.annotation.Nullable)2 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 Security (com.haulmont.cuba.core.global.Security)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 AbstractWindow (com.haulmont.cuba.gui.components.AbstractWindow)1 Filter (com.haulmont.cuba.gui.components.Filter)1 Window (com.haulmont.cuba.gui.components.Window)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)1 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)1