use of com.haulmont.cuba.gui.Notifications in project cuba by cuba-platform.
the class ExcelAction method export.
/**
* Export via {@link ExcelExporter}.
*/
protected void export(ExcelExporter.ExportMode exportMode) {
ExcelExporter exporter = new ExcelExporter(exportFormat);
exporter.setExportAggregation(exportAggregation);
Window window = ComponentsHelper.getWindowNN(target);
ExportDisplay display = beanLocator.get(ExportDisplay.NAME);
display.setFrame(window);
if (target instanceof Table) {
@SuppressWarnings("unchecked") Table<Entity> table = (Table<Entity>) target;
exporter.exportTable(table, table.getNotCollapsedColumns(), false, display, null, fileName, exportMode);
}
if (target instanceof DataGrid) {
@SuppressWarnings("unchecked") DataGrid<Entity> dataGrid = (DataGrid<Entity>) target;
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 = ComponentsHelper.getScreenContext(target).getNotifications();
notifications.create(NotificationType.WARNING).withCaption(messages.getMainMessage("actions.warningExport.title")).withDescription(messages.getMainMessage("actions.warningExport.message")).show();
}
}
use of com.haulmont.cuba.gui.Notifications in project cuba by cuba-platform.
the class ExcelAction method export.
/**
* Export via {@link ExcelExporter}.
*/
protected void export(ExportMode exportMode) {
ExcelExporter exporter = new ExcelExporter(exportFormat);
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();
}
}
use of com.haulmont.cuba.gui.Notifications in project cuba by cuba-platform.
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 = getScreenContext(pickerField).getNotifications();
notifications.create(NotificationType.WARNING).withCaption(messages.getMainMessage("dynamicAttributes.entity.filter.filterNotFound")).show();
}
AbstractWindow controller = (AbstractWindow) (lookupWindow).getFrameOwner();
((DsContextImplementation) controller.getDsContext()).resumeSuspended();
}
use of com.haulmont.cuba.gui.Notifications in project cuba by cuba-platform.
the class MainTabSheetActionHandler method analyzeLayout.
protected void analyzeLayout(Object target) {
Window window = findWindow((Layout) target);
if (window != null) {
LayoutAnalyzer analyzer = new LayoutAnalyzer();
List<LayoutTip> tipsList = analyzer.analyze(window);
if (tipsList.isEmpty()) {
Notifications notifications = ComponentsHelper.getScreenContext(window).getNotifications();
notifications.create(NotificationType.HUMANIZED).withCaption("No layout problems found").show();
} else {
WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(window).getScreens();
WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("layoutAnalyzer");
wm.openWindow(windowInfo, WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
}
}
}
Aggregations