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();
}
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();
}
}
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;
}
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();
}
Aggregations