Search in sources :

Example 21 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class App method afterLoggedIn.

/**
 * Perform actions after success login
 */
protected void afterLoggedIn() {
    UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
    User user = sessionSource.getUserSession().getUser();
    // Change password on logon
    if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
        mainFrame.deactivate("");
        final DesktopWindowManager wm = mainFrame.getWindowManager();
        for (Window window : wm.getOpenWindows()) {
            window.setEnabled(false);
        }
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
        Window changePasswordWindow = wm.openWindow(changePasswordDialog, OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", false));
        changePasswordWindow.addCloseListener(actionId -> {
            for (Window window : wm.getOpenWindows()) {
                window.setEnabled(true);
            }
        });
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) User(com.haulmont.cuba.security.entity.User) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 22 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class ScreensLinkHandlerProcessor method handle.

@Override
public void handle(ExternalLinkContext linkContext) {
    String screenName = linkContext.getRequestParams().get("screen");
    App app = linkContext.getApp();
    final WindowInfo windowInfo = windowConfig.getWindowInfo(screenName);
    if (windowInfo == null) {
        log.warn("WindowInfo not found for screen: {}", screenName);
        return;
    }
    try {
        openWindow(windowInfo, linkContext);
    } catch (EntityAccessException e) {
        entityAccessExceptionHandler.handle(e, app.getWindowManager());
    } catch (AccessDeniedException e) {
        accessDeniedHandler.handle(e, app.getWindowManager());
    } catch (NoSuchScreenException e) {
        noSuchScreenHandler.handle(e, app.getWindowManager());
    }
}
Also used : App(com.haulmont.cuba.web.App) NoSuchScreenException(com.haulmont.cuba.gui.NoSuchScreenException) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 23 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class WebRelatedEntities method addNavigationAction.

protected void addNavigationAction(MetaClass metaClass, MetaProperty metaProperty) {
    // check if browse screen available
    PropertyOption propertyOption = propertyOptions.get(metaProperty.getName());
    WindowInfo defaultScreen = screensHelper.getDefaultBrowseScreen(metaProperty.getRange().asClass());
    if (defaultScreen != null || (propertyOption != null && StringUtils.isNotEmpty(propertyOption.getScreen()))) {
        RelatedAction relatedAction = RelatedAction.create("related" + actionOrder.size(), listComponent, metaClass, metaProperty);
        relatedAction.setOpenType(openType);
        if (defaultScreen != null) {
            relatedAction.setScreen(defaultScreen.getId());
        }
        if (propertyOption != null) {
            if (StringUtils.isNotEmpty(propertyOption.getCaption())) {
                relatedAction.setCaption(propertyOption.getCaption());
            }
            if (StringUtils.isNotEmpty(propertyOption.getFilterCaption())) {
                relatedAction.setFilterCaption(propertyOption.getFilterCaption());
            }
            if (StringUtils.isNotEmpty(propertyOption.getScreen())) {
                relatedAction.setScreen(propertyOption.getScreen());
            }
        }
        addAction(relatedAction);
    }
}
Also used : RelatedAction(com.haulmont.cuba.gui.components.actions.RelatedAction) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 24 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class FoldersBean method openFolder.

@Override
public void openFolder(AbstractSearchFolder folder) {
    if (StringUtils.isBlank(folder.getFilterComponentId())) {
        log.warn("Unable to open folder: componentId is blank");
        return;
    }
    String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
    String screenId = strings[0];
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
    Map<String, Object> params = new HashMap<>();
    WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
    WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
    if (!StringUtils.isBlank(folder.getTabName())) {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
    } else {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
    }
    WindowParams.FOLDER_ID.set(params, folder.getId());
    com.haulmont.cuba.gui.components.Window window = App.getInstance().getWindowManager().openWindow(windowInfo, OpenType.NEW_TAB, params);
    Filter filterComponent = null;
    if (strings.length > 1) {
        String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
        filterComponent = (Filter) window.getComponentNN(filterComponentId);
        FilterEntity filterEntity = metadata.create(FilterEntity.class);
        filterEntity.setFolder(folder);
        filterEntity.setComponentId(folder.getFilterComponentId());
        filterEntity.setName(folder.getLocName());
        filterEntity.setXml(folder.getFilterXml());
        filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
        if (folder instanceof SearchFolder) {
            filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
        }
        filterComponent.setFilterEntity(filterEntity);
        filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
    }
    if (filterComponent != null && folder instanceof SearchFolder) {
        final SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentation() != null) {
            ((com.haulmont.cuba.gui.components.Component.HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
        }
    }
    ((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) HashMap(java.util.HashMap) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Filter(com.haulmont.cuba.gui.components.Filter)

Example 25 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class WebFrame method openLookup.

@Override
public Window.Lookup openLookup(Class<? extends Entity> entityClass, Window.Lookup.Handler handler, WindowManager.OpenType openType, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo lookupScreen = windowConfig.getLookupScreen(entityClass);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openLookup(lookupScreen, handler, openType, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)33 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)21 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)16 Window (com.haulmont.cuba.gui.components.Window)3 HashMap (java.util.HashMap)3 Element (org.dom4j.Element)3 DetachedFrame (com.haulmont.cuba.desktop.DetachedFrame)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Filter (com.haulmont.cuba.gui.components.Filter)2 RelatedAction (com.haulmont.cuba.gui.components.actions.RelatedAction)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)2 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)2 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)2 User (com.haulmont.cuba.security.entity.User)2 App (com.haulmont.cuba.web.App)2 Tree (com.haulmont.bali.datastruct.Tree)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1