Search in sources :

Example 16 with WindowInfo

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

the class DesktopFrame method openFrame.

@Override
public Frame openFrame(Component parent, String windowAlias) {
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
    return getWindowManager().openFrame(wrappedFrame, parent, windowInfo);
}
Also used : DetachedFrame(com.haulmont.cuba.desktop.DetachedFrame) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 17 with WindowInfo

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

the class ScreensHelper method getAvailableScreensMap.

protected Map<String, Object> getAvailableScreensMap(Class entityClass, ScreenType filterScreenType) {
    String key = getScreensCacheKey(entityClass.getName(), getUserLocale(), filterScreenType);
    Map<String, Object> screensMap = availableScreensCache.get(key);
    if (screensMap != null) {
        return screensMap;
    }
    Collection<WindowInfo> windowInfoCollection = windowConfig.getWindows();
    screensMap = new TreeMap<>();
    Set<String> visitedWindowIds = new HashSet<>();
    for (WindowInfo windowInfo : windowInfoCollection) {
        String windowId = windowInfo.getId();
        // just skip for now, we assume all versions of screen can operate with the same entity
        if (visitedWindowIds.contains(windowId)) {
            continue;
        }
        String src = windowInfo.getTemplate();
        if (StringUtils.isNotEmpty(src)) {
            try {
                Element windowElement = getWindowElement(src);
                if (windowElement != null) {
                    if (isEntityAvailable(windowElement, entityClass, filterScreenType)) {
                        String caption = getScreenCaption(windowElement, src);
                        caption = getDetailedScreenCaption(caption, windowId);
                        screensMap.put(caption, windowId);
                    }
                } else {
                    screensMap.put(windowId, windowId);
                }
            } catch (FileNotFoundException e) {
                log.error(e.getMessage());
            }
        }
        visitedWindowIds.add(windowId);
    }
    screensMap = Collections.unmodifiableMap(screensMap);
    cacheScreens(key, screensMap);
    return screensMap;
}
Also used : Element(org.dom4j.Element) FileNotFoundException(java.io.FileNotFoundException) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 18 with WindowInfo

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

the class ScreensHelper method getDefaultBrowseScreen.

@Nullable
public WindowInfo getDefaultBrowseScreen(MetaClass metaClass) {
    WindowInfo browseWindow = windowConfig.findWindowInfo(windowConfig.getBrowseScreenId(metaClass));
    if (browseWindow != null && userSessionSource.getUserSession().isScreenPermitted(browseWindow.getId())) {
        return browseWindow;
    }
    WindowInfo lookupWindow = windowConfig.findWindowInfo(windowConfig.getLookupScreenId(metaClass));
    if (lookupWindow != null && userSessionSource.getUserSession().isScreenPermitted(lookupWindow.getId())) {
        return lookupWindow;
    }
    return null;
}
Also used : WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Nullable(javax.annotation.Nullable)

Example 19 with WindowInfo

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

the class UiPermissionsFrame method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    Collection<WindowInfo> windows = sortWindowInfos(windowConfig.getWindows());
    Map<String, Object> screens = new LinkedHashMap<>();
    for (WindowInfo windowInfo : windows) {
        String id = windowInfo.getId();
        String menuId = "menu-config." + id;
        String localeMsg = messages.getMessage(AppConfig.getMessagesPack(), menuId);
        String title = menuId.equals(localeMsg) ? id : localeMsg + " (" + id + ")";
        screens.put(title, id);
    }
    screenFilter.setOptionsMap(screens);
    companion.initPermissionsColoredColumns(uiPermissionsTable);
    uiPermissionTargetsDs.addItemChangeListener(e -> {
        if (!selectedComponentPanel.isVisible() && (e.getItem() != null)) {
            selectedComponentPanel.setVisible(true);
        }
        if (selectedComponentPanel.isVisible() && (e.getItem() == null)) {
            selectedComponentPanel.setVisible(false);
        }
        updateCheckBoxes(e.getItem());
    });
    uiPermissionTargetsDs.addItemPropertyChangeListener(e -> {
        if ("permissionVariant".equals(e.getProperty())) {
            updateCheckBoxes(uiPermissionsTable.getSingleSelected());
        }
    });
    attachCheckBoxListener(readOnlyCheckBox, UiPermissionVariant.READ_ONLY);
    attachCheckBoxListener(hideCheckBox, UiPermissionVariant.HIDE);
    attachCheckBoxListener(showCheckBox, UiPermissionVariant.SHOW);
    uiPermissionTargetsDs.setPermissionDs(uiPermissionsDs);
    uiPermissionsDs.refresh();
    uiPermissionTargetsDs.refresh();
    boolean isCreatePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.CREATE);
    boolean isDeletePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.DELETE);
    boolean isRoleEditPermitted = security.isEntityOpPermitted(metadata.getClass(Role.class), EntityOp.UPDATE);
    final boolean hasPermissionsToModifyPermission = isCreatePermitted && isDeletePermitted && isRoleEditPermitted;
    RemoveAction removeAction = new RemoveAction(uiPermissionsTable, false);
    removeAction.setAfterRemoveHandler(removedItems -> {
        if (!removedItems.isEmpty()) {
            UiPermissionTarget removedPermission = (UiPermissionTarget) removedItems.iterator().next();
            markItemPermission(UiPermissionVariant.NOTSET, removedPermission);
        }
    });
    removeAction.setEnabled(hasPermissionsToModifyPermission);
    removeAction.setIcon(null);
    removeAction.setCaption(getMessage("actions.RemoveSelected"));
    removePermissionBtn.setAction(removeAction);
    uiPermissionsTable.addAction(removeAction);
    editPane.setEnabled(security.isEntityOpPermitted(Role.class, EntityOp.UPDATE));
    applyPermissions(hasPermissionsToModifyPermission);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Role(com.haulmont.cuba.security.entity.Role) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) UiPermissionTarget(com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)

Example 20 with WindowInfo

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

the class WindowDelegate method openFrame.

public Frame openFrame(Component parent, String windowAlias, Map<String, Object> params) {
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
    return window.getWindowManager().openFrame(wrappedFrame, parent, windowInfo, params);
}
Also used : 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