Search in sources :

Example 11 with Notifications

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();
    }
}
Also used : ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) ListAction(com.haulmont.cuba.gui.components.actions.ListAction) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) ContainerDataUnit(com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit) Messages(com.haulmont.cuba.core.global.Messages) StudioPropertiesItem(com.haulmont.cuba.gui.meta.StudioPropertiesItem) Icons(com.haulmont.cuba.gui.icons.Icons) Collectors(java.util.stream.Collectors) Dialogs(com.haulmont.cuba.gui.Dialogs) Inject(javax.inject.Inject) List(java.util.List) ExcelExportFormat(com.haulmont.cuba.gui.export.ExcelExportFormat) Notifications(com.haulmont.cuba.gui.Notifications) BeanLocator(com.haulmont.cuba.core.global.BeanLocator) ComponentsHelper(com.haulmont.cuba.gui.ComponentsHelper) StudioAction(com.haulmont.cuba.gui.meta.StudioAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Entity(com.haulmont.cuba.core.entity.Entity) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) Entity(com.haulmont.cuba.core.entity.Entity) ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) Notifications(com.haulmont.cuba.gui.Notifications)

Example 12 with Notifications

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();
    }
}
Also used : ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) Type(com.haulmont.cuba.gui.components.DialogAction.Type) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) ComponentsHelper.getScreenContext(com.haulmont.cuba.gui.ComponentsHelper.getScreenContext) Messages(com.haulmont.cuba.core.global.Messages) AppBeans(com.haulmont.cuba.core.global.AppBeans) Icons(com.haulmont.cuba.gui.icons.Icons) Collectors(java.util.stream.Collectors) Dialogs(com.haulmont.cuba.gui.Dialogs) Scope(org.springframework.context.annotation.Scope) List(java.util.List) ExportMode(com.haulmont.cuba.gui.export.ExcelExporter.ExportMode) AppConfig(com.haulmont.cuba.gui.AppConfig) ExcelExportFormat(com.haulmont.cuba.gui.export.ExcelExportFormat) Notifications(com.haulmont.cuba.gui.Notifications) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Entity(com.haulmont.cuba.core.entity.Entity) Entity(com.haulmont.cuba.core.entity.Entity) ExcelExporter(com.haulmont.cuba.gui.export.ExcelExporter) Notifications(com.haulmont.cuba.gui.Notifications)

Example 13 with Notifications

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();
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) MetaClass(com.haulmont.chile.core.model.MetaClass) Notifications(com.haulmont.cuba.gui.Notifications)

Example 14 with Notifications

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));
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) LayoutTip(com.haulmont.cuba.gui.app.core.dev.LayoutTip) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer) Notifications(com.haulmont.cuba.gui.Notifications) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

Notifications (com.haulmont.cuba.gui.Notifications)14 Messages (com.haulmont.cuba.core.global.Messages)6 MetaClass (com.haulmont.chile.core.model.MetaClass)3 Entity (com.haulmont.cuba.core.entity.Entity)3 NotificationType (com.haulmont.cuba.gui.Notifications.NotificationType)3 ClientConfig (com.haulmont.cuba.client.ClientConfig)2 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)2 Dialogs (com.haulmont.cuba.gui.Dialogs)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 ExcelExportFormat (com.haulmont.cuba.gui.export.ExcelExportFormat)2 ExcelExporter (com.haulmont.cuba.gui.export.ExcelExporter)2 ExportDisplay (com.haulmont.cuba.gui.export.ExportDisplay)2 CubaIcon (com.haulmont.cuba.gui.icons.CubaIcon)2 Icons (com.haulmont.cuba.gui.icons.Icons)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Subscription (com.haulmont.bali.events.Subscription)1