Search in sources :

Example 1 with MapScreenOptions

use of com.haulmont.cuba.gui.screen.MapScreenOptions in project cuba by cuba-platform.

the class DynamicAttributesGuiTools method initPickerField.

protected void initPickerField(LookupAction<?> lookupAction, @Nullable String screen, MetaClass metaClass, Class javaClass) {
    if (StringUtils.isNotBlank(screen)) {
        lookupAction.setScreenId(screen);
    } else {
        screen = windowConfig.getBrowseScreenId(metaClass);
        Map<String, String> screensMap = screensHelper.getAvailableBrowserScreens(javaClass);
        if (windowConfig.findWindowInfo(screen) != null && screensMap.containsValue(screen)) {
            lookupAction.setScreenId(screen);
            lookupAction.setOpenMode(OpenMode.THIS_TAB);
        } else {
            lookupAction.setScreenId(CommonLookupController.SCREEN_ID);
            lookupAction.setScreenOptionsSupplier(() -> new MapScreenOptions(ParamsMap.of(CommonLookupController.CLASS_PARAMETER, metaClass)));
            lookupAction.setOpenMode(OpenMode.DIALOG);
        }
    }
}
Also used : MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions)

Example 2 with MapScreenOptions

use of com.haulmont.cuba.gui.screen.MapScreenOptions in project cuba by cuba-platform.

the class ScreenNavigationHandler method createEditor.

protected Screen createEditor(WindowInfo windowInfo, String screenRoute, NavigationState requestedState, AppUI ui) {
    Map<String, Object> options = createEditorScreenOptions(windowInfo, requestedState, ui);
    if (MapUtils.isEmpty(options)) {
        log.info("Unable to load entity for editor: '{}'. " + "Subscribe for 'UrlParamsChangedEvent' to obtain its serialized id", windowInfo.getId());
    }
    Screen editor;
    OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
    if (isLegacyScreen(windowInfo.getControllerClass())) {
        editor = ui.getScreens().create(windowInfo.getId(), openMode, new MapScreenOptions(options));
    } else {
        editor = ui.getScreens().create(windowInfo.getId(), openMode);
    }
    if (MapUtils.isNotEmpty(options)) {
        Entity entity = (Entity) options.get(WindowParams.ITEM.name());
        // noinspection unchecked
        ((EditorScreen<Entity>) editor).setEntityToEdit(entity);
    }
    return editor;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 3 with MapScreenOptions

use of com.haulmont.cuba.gui.screen.MapScreenOptions in project cuba by cuba-platform.

the class RootNavigationHandler method handle404.

protected void handle404(String route, AppUI ui) {
    RootWindow topWindow = ui.getTopLevelWindow();
    Screen rootScreen = topWindow != null ? topWindow.getFrameOwner() : null;
    if (rootScreen instanceof Window.HasWorkArea) {
        MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
        ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options).show();
    } else {
        ui.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(messages.formatMainMessage("navigation.screenNotFound", route)).show();
    }
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) RootWindow(com.haulmont.cuba.gui.components.RootWindow) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)

Example 4 with MapScreenOptions

use of com.haulmont.cuba.gui.screen.MapScreenOptions in project cuba by cuba-platform.

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(ComponentsHelper.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", ComponentsHelper.getFilterComponentPath(filter));
    params.put("componentId", componentId);
    params.put("foldersPane", filterHelper.getFoldersPane());
    params.put("entityClass", entityMetaClass.getJavaClass().getName());
    params.put("query", query);
    Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
    screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
Also used : Set(java.util.Set) MetaClass(com.haulmont.chile.core.model.MetaClass) HashMap(java.util.HashMap) EntityDataUnit(com.haulmont.cuba.gui.components.data.meta.EntityDataUnit) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) Screens(com.haulmont.cuba.gui.Screens)

Example 5 with MapScreenOptions

use of com.haulmont.cuba.gui.screen.MapScreenOptions in project cuba by cuba-platform.

the class DataGridEditorComponentGenerationStrategy method setupPickerFieldActions.

protected void setupPickerFieldActions(PickerField<?> pickerField) {
    Map<String, Object> lookupScreenParams = ParamsMap.of("dataGridEditor", true);
    PickerField.LookupAction legacyLookupAction = (PickerField.LookupAction) pickerField.getAction(PickerField.LookupAction.NAME);
    if (legacyLookupAction != null) {
        // Opening lookup screen in another mode will close editor
        legacyLookupAction.setLookupScreenOpenType(WindowManager.OpenType.DIALOG);
        // In case of adding special logic for lookup screen opened from DataGrid editor
        legacyLookupAction.setLookupScreenParams(lookupScreenParams);
    }
    LookupAction<?> lookupAction = (LookupAction<?>) pickerField.getAction(LookupAction.ID);
    if (lookupAction != null) {
        // Opening lookup screen in another mode will close editor
        lookupAction.setOpenMode(OpenMode.DIALOG);
        // In case of adding special logic for lookup screen opened from DataGrid editor
        lookupAction.setScreenOptionsSupplier(() -> new MapScreenOptions(lookupScreenParams));
    }
}
Also used : LookupAction(com.haulmont.cuba.gui.actions.picker.LookupAction) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions)

Aggregations

MapScreenOptions (com.haulmont.cuba.gui.screen.MapScreenOptions)6 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)3 Screen (com.haulmont.cuba.gui.screen.Screen)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 Entity (com.haulmont.cuba.core.entity.Entity)1 Screens (com.haulmont.cuba.gui.Screens)1 LookupAction (com.haulmont.cuba.gui.actions.picker.LookupAction)1 RootWindow (com.haulmont.cuba.gui.components.RootWindow)1 EntityDataUnit (com.haulmont.cuba.gui.components.data.meta.EntityDataUnit)1 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)1 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)1 OpenMode (com.haulmont.cuba.gui.screen.OpenMode)1 WebWindow (com.haulmont.cuba.web.gui.WebWindow)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1