Search in sources :

Example 1 with Screens

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

the class BulkEditors method buildEditor.

protected <E> BulkEditorWindow<E> buildEditor(BulkEditorBuilder<E> builder) {
    FrameOwner origin = builder.getOrigin();
    Screens screens = getScreenContext(origin).getScreens();
    if (CollectionUtils.isEmpty(builder.getEntities())) {
        throw new IllegalStateException(String.format("BulkEditor of %s cannot be open with no entities were set", builder.getMetaClass()));
    }
    // noinspection unchecked
    BulkEditorWindow<E> bulkEditorWindow = screens.create(BulkEditorWindow.class, builder.openMode);
    BulkEditorContext<E> context = createBulkEditorContext(builder);
    bulkEditorWindow.setBulkEditorContext(context);
    bulkEditorWindow.addAfterCloseListener(createAfterCloseHandler(builder));
    return bulkEditorWindow;
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) Screens(io.jmix.ui.Screens)

Example 2 with Screens

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

the class RelatedEntitiesSupportImpl method createScreen.

protected Screen createScreen(RelatedEntitiesBuilder builder, MetaClass metaClass, MetaProperty metaProperty) {
    FrameOwner origin = builder.getOrigin();
    Screens screens = UiControllerUtils.getScreenContext(origin).getScreens();
    if (builder instanceof RelatedEntitiesClassBuilder) {
        return screens.create(((RelatedEntitiesClassBuilder<?>) builder).getScreenClass(), builder.getOpenMode(), builder.getOptions());
    } else {
        String screenId = builder.getScreenId();
        if (Strings.isNullOrEmpty(screenId)) {
            // try to get default browse screen id
            screenId = windowConfig.getBrowseScreenId(metaProperty.getRange().asClass());
            if (Strings.isNullOrEmpty(screenId)) {
                String message = String.format("Can't create related entities screen: passed screen id is null and " + "there is no default browse screen for %s", metaClass.getName());
                throw new IllegalStateException(message);
            }
        }
        return screens.create(screenId, builder.getOpenMode(), builder.getOptions());
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) Screens(io.jmix.ui.Screens)

Example 3 with Screens

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

the class BackgroundWorkProgressWindow method show.

/**
 * Show modal window with message which will last until task completes.
 * Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution.
 *
 * @param task            background task containing long operation
 * @param title           window title, optional
 * @param message         window message, optional
 * @param total           total number of items, that will be processed
 * @param cancelAllowed   show or not cancel button
 * @param percentProgress show progress in percents
 * @param <V>             task result type
 */
public static <T extends Number, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, Number total, boolean cancelAllowed, boolean percentProgress) {
    if (task.getOwnerScreen() == null) {
        throw new IllegalArgumentException("Task without owner cannot be run");
    }
    Map<String, Object> params = new HashMap<>();
    params.put("task", task);
    params.put("title", title);
    params.put("message", message);
    params.put("total", total);
    params.put("cancelAllowed", cancelAllowed);
    params.put("percentProgress", percentProgress);
    Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens();
    WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkProgressWindow");
    ((WindowManager) screens).openWindow(windowInfo, OpenType.DIALOG, params);
}
Also used : WindowConfig(io.jmix.ui.WindowConfig) HashMap(java.util.HashMap) Screens(io.jmix.ui.Screens) WindowInfo(io.jmix.ui.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager)

Example 4 with Screens

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

the class AddToSetAction method actionPerform.

@Override
public void actionPerform(Component component) {
    MetaClass entityMetaClass;
    if (target.getItems() instanceof EntityDataUnit) {
        entityMetaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    } else {
        throw new UnsupportedOperationException("Unsupported data unit " + target.getItems());
    }
    String query;
    if (filter.getDatasource() != null) {
        query = filter.getDatasource().getQuery();
    } else {
        query = filter.getDataLoader().getQuery();
    }
    String[] strings = ValuePathHelper.parse(CubaComponentsHelper.getFilterComponentPath(filter));
    String componentId = ValuePathHelper.pathSuffix(strings);
    Set ownerSelection = target.getSelected();
    Map<String, Object> params = new HashMap<>();
    params.put("entityType", entityMetaClass.getName());
    params.put("items", ownerSelection);
    params.put("componentPath", CubaComponentsHelper.getFilterComponentPath(filter));
    params.put("componentId", componentId);
    params.put("foldersPane", filterHelper.getFoldersPane());
    params.put("entityClass", entityMetaClass.getJavaClass().getName());
    params.put("query", query);
    params.put("username", userSessionSource.getUserSession().getUser().getUsername());
    Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
    screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
Also used : Set(java.util.Set) MetaClass(io.jmix.core.metamodel.model.MetaClass) HashMap(java.util.HashMap) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Screens(io.jmix.ui.Screens)

Example 5 with Screens

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

the class LayoutAnalyzerContextMenuProvider method initContextMenu.

public void initContextMenu(Screen screen, io.jmix.ui.component.Component contextMenuTarget) {
    if (screenProperties.isLayoutAnalyzerEnabled()) {
        ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
        MenuBar.MenuItem menuItem = contextMenu.addItem(messages.getMessage("actions.analyzeLayout"), c -> {
            LayoutAnalyzer analyzer = new LayoutAnalyzer();
            List<LayoutTip> tipsList = analyzer.analyze(screen);
            if (tipsList.isEmpty()) {
                Notifications notifications = UiControllerUtils.getScreenContext(screen).getNotifications();
                notifications.create(Notifications.NotificationType.HUMANIZED).withCaption("No layout problems found").show();
            } else {
                Screens screens = UiControllerUtils.getScreenContext(screen).getScreens();
                LayoutAnalyzerScreen layoutAnalyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
                layoutAnalyzerScreen.setLayoutTips(tipsList);
                layoutAnalyzerScreen.show();
            }
        });
        menuItem.setStyleName("jmix-cm-item");
    }
}
Also used : AbstractComponent(com.vaadin.ui.AbstractComponent) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutTip(io.jmix.ui.app.core.dev.LayoutTip) MenuBar(com.vaadin.ui.MenuBar) ContextMenu(io.jmix.ui.widget.addon.contextmenu.ContextMenu) LayoutAnalyzer(io.jmix.ui.app.core.dev.LayoutAnalyzer) Notifications(io.jmix.ui.Notifications) Screens(io.jmix.ui.Screens)

Aggregations

Screens (io.jmix.ui.Screens)18 FrameOwner (io.jmix.ui.screen.FrameOwner)5 Screen (io.jmix.ui.screen.Screen)4 Notifications (io.jmix.ui.Notifications)3 HashMap (java.util.HashMap)3 WindowManager (com.haulmont.cuba.gui.WindowManager)2 EntityInfoWindow (io.jmix.datatoolsui.screen.entityinfo.EntityInfoWindow)2 WindowConfig (io.jmix.ui.WindowConfig)2 WindowInfo (io.jmix.ui.WindowInfo)2 LayoutAnalyzer (io.jmix.ui.app.core.dev.LayoutAnalyzer)2 LayoutAnalyzerScreen (io.jmix.ui.app.core.dev.LayoutAnalyzerScreen)2 LayoutTip (io.jmix.ui.app.core.dev.LayoutTip)2 io.jmix.ui.component (io.jmix.ui.component)2 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)2 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)2 CubaLegacySettings (com.haulmont.cuba.settings.CubaLegacySettings)1 AbstractComponent (com.vaadin.ui.AbstractComponent)1 MenuBar (com.vaadin.ui.MenuBar)1 DevelopmentException (io.jmix.core.DevelopmentException)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1