Search in sources :

Example 21 with Notifications

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

the class NotificationFacetImpl method show.

@Override
public void show() {
    Frame owner = getOwner();
    if (owner == null) {
        throw new IllegalStateException("Notification is not attached to Frame");
    }
    Notifications notifications = UiControllerUtils.getScreenContext(owner.getFrameOwner()).getNotifications();
    String caption = this.caption;
    if (captionProvider != null) {
        caption = captionProvider.get();
    }
    String description = this.description;
    if (descriptionProvider != null) {
        description = descriptionProvider.get();
    }
    Notifications.NotificationBuilder builder = notifications.create(type).withCaption(caption).withDescription(description).withHideDelayMs(delayMs).withContentMode(contentMode).withHtmlSanitizer(htmlSanitizerEnabled).withStyleName(styleName).withPosition(position);
    for (Consumer<Notifications.CloseEvent> closeListener : closeListeners) {
        builder.withCloseListener(closeListener);
    }
    builder.show();
}
Also used : Notifications(io.jmix.ui.Notifications)

Example 22 with Notifications

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

the class MainTabSheetActionHandler method analyzeLayout.

protected void analyzeLayout(Object target) {
    Screen screen = findScreen((Layout) target);
    if (screen == null) {
        return;
    }
    LayoutAnalyzer analyzer = new LayoutAnalyzer();
    List<LayoutTip> layoutTips = analyzer.analyze(screen);
    ScreenContext screenContext = UiControllerUtils.getScreenContext(screen);
    if (layoutTips.isEmpty()) {
        Notifications notifications = screenContext.getNotifications();
        notifications.create(NotificationType.HUMANIZED).withCaption("No layout problems found").show();
    } else {
        Screens screens = screenContext.getScreens();
        LayoutAnalyzerScreen analyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
        analyzerScreen.setLayoutTips(layoutTips);
        analyzerScreen.show();
    }
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutTip(io.jmix.ui.app.core.dev.LayoutTip) Screen(io.jmix.ui.screen.Screen) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutAnalyzer(io.jmix.ui.app.core.dev.LayoutAnalyzer) Notifications(io.jmix.ui.Notifications) Screens(io.jmix.ui.Screens)

Example 23 with Notifications

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

the class LocalizedTaskWrapper method handleTimeoutException.

@Override
public boolean handleTimeoutException() {
    boolean handled = wrappedTask.handleTimeoutException();
    if (handled || wrappedTask.getOwnerScreen() == null) {
        Screens screens = getScreenContext().getScreens();
        screens.remove(screen);
    } else {
        Screens screens = getScreenContext().getScreens();
        screens.remove(screen);
        Notifications notifications = getScreenContext().getNotifications();
        notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeout")).withDescription(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeoutMessage")).show();
        handled = true;
    }
    return handled;
}
Also used : Screens(io.jmix.ui.Screens) Notifications(io.jmix.ui.Notifications)

Example 24 with Notifications

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

the class FolderEditWindow method commit.

protected void commit() {
    AppUI appUI = AppUI.getCurrent();
    if (appUI == null) {
        return;
    }
    Notifications notifications = appUI.getNotifications();
    SearchFolder folder = (SearchFolder) FolderEditWindow.this.folder;
    if (StringUtils.trimToNull(nameField.getValue()) == null) {
        String msg = messages.getMainMessage("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.getMainMessage("folders.folderEditWindow.invalidSortOrder");
            notifications.create(Notifications.NotificationType.WARNING).withCaption(msg).show();
            return;
        }
        folder.setSortOrder(sortOrder);
    }
    Object parent = parentSelect.getValue();
    if (parent instanceof Folder)
        folder.setParent((Folder) parent);
    else
        folder.setParent(null);
    folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
    if (globalCb != null) {
        if (BooleanUtils.isTrue(globalCb.getValue())) {
            folder.setUsername(null);
        } else {
            // todo user substitution
            // folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
            folder.setUsername(userSessionSource.getUserSession().getUser().getUsername());
        }
    } else {
        // todo user substitution
        // folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
        folder.setUsername(userSessionSource.getUserSession().getUser().getUsername());
    }
    if (presentation != null && presentation.getValue() != null) {
        folder.setPresentationId(((UiTablePresentation) presentation.getValue()).getId());
    }
    FolderEditWindow.this.commitHandler.run();
    forceClose();
}
Also used : AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Folder(com.haulmont.cuba.core.entity.Folder) AppUI(io.jmix.ui.AppUI) Notifications(io.jmix.ui.Notifications)

Aggregations

Notifications (io.jmix.ui.Notifications)24 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