/** * Show validation alert with passed errors and first problem UI component. * * @param origin screen controller * @param errors validation error */ public void showValidationErrors(FrameOwner origin, ValidationErrors errors) { checkNotNullArgument(origin); checkNotNullArgument(errors); if (errors.isEmpty()) { return; } StringBuilder buffer = new StringBuilder(); for (ValidationErrors.Item error : errors.getAll()) { buffer.append(error.description).append("\n"); } ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); String validationNotificationType = clientConfig.getValidationNotificationType(); if (validationNotificationType.endsWith("_HTML")) { // HTML validation notification types are not supported validationNotificationType = validationNotificationType.replace("_HTML", ""); } Notifications notifications = getScreenContext(origin).getNotifications(); notifications.create(NotificationType.valueOf(validationNotificationType)) .withCaption(messages.getMainMessage("validationFail.caption")) .withDescription(buffer.toString()) .show(); focusProblemComponent(errors); }
/** * Export via {@link ExcelExporter}. */ protected void export(ExportMode exportMode) { ExcelExporter exporter = new ExcelExporter(); exporter.setExportAggregation(exportAggregation); if (listComponent instanceof Table) { Table<Entity> table = (Table<Entity>) listComponent; exporter.exportTable(table, table.getNotCollapsedColumns(), false, display, null, fileName, exportMode); } if (listComponent instanceof DataGrid) { DataGrid<Entity> dataGrid = (DataGrid<Entity>) listComponent; List<DataGrid.Column> columns = dataGrid.getVisibleColumns().stream() .filter(col -> !col.isCollapsed()) .collect(Collectors.toList()); exporter.exportDataGrid(dataGrid, columns, display, null, fileName, exportMode); } if (exporter.isXlsMaxRowNumberExceeded()) { Notifications notifications = getScreenContext(listComponent).getNotifications(); notifications.create(NotificationType.WARNING) .withCaption(messages.getMainMessage("actions.warningExport.title")) .withDescription(messages.getMainMessage("actions.warningExport.message")) .show(); } }
.withDescription(messages.getMainMessage("actions.warningExport.message")) .show();
.withDescription( messages.formatMainMessage("entityLocked.desc", lockInfo.getUser().getLogin(),
.withDescription(messages.getMainMessage("OpenAction.objectIsDeleted")) .show();
/** * Pessimistic lock before start of editing, if it is configured for the entity. */ protected boolean lockIfNeeded(Entity entity) { LockService lockService = getBeanLocator().get(LockService.class); LockInfo lockInfo = lockService.lock(getLockName(), entity.getId().toString()); if (lockInfo == null) { justLocked = true; } else if (!(lockInfo instanceof LockNotSupported)) { Messages messages = getBeanLocator().get(Messages.class); DatatypeFormatter datatypeFormatter = getBeanLocator().get(DatatypeFormatter.class); Notifications notifications = getScreenContext().getNotifications(); notifications.create(NotificationType.HUMANIZED) .withCaption(messages.getMainMessage("entityLocked.msg")) .withDescription(String.format(messages.getMainMessage("entityLocked.desc"), lockInfo.getUser().getLogin(), datatypeFormatter.formatDateTime(lockInfo.getSince()))) .show(); return false; } return true; }
@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(); Messages messages = AppBeans.get(Messages.NAME); notifications.create(Notifications.NotificationType.WARNING) .withCaption(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeout")) .withDescription(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeoutMessage")) .show(); handled = true; } return handled; }
protected void showParseErrorNotification(String message) { ScreenContext screenContext = UiControllerUtils.getScreenContext(getFrame().getFrameOwner()); screenContext.getNotifications().create(Notifications.NotificationType.TRAY) .withDescription(message) .show(); } }
@SuppressWarnings("deprecation") @Override public void showNotification(String caption, String description, Frame.NotificationType type) { ui.getNotifications().create() .withCaption(caption) .withDescription(description) .withContentMode(Frame.NotificationType.isHTML(type) ? ContentMode.HTML : ContentMode.TEXT) .withType(convertNotificationType(type)) .show(); }
protected void showWarnNotification() { notifications.create(NotificationType.WARNING) .withCaption(messages.getMainMessage("actions.warningExport.title")) .withDescription(messages.getMainMessage("actions.warningExport.message")) .withPosition(Notifications.Position.MIDDLE_CENTER) .show(); }