Search in sources :

Example 51 with WindowInfo

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

the class ShowInfoAction method showInfo.

public void showInfo(Entity entity, MetaClass metaClass, Component.BelongToFrame component) {
    WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(component).getScreens();
    WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("sysInfoWindow");
    wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("metaClass", metaClass, "item", entity));
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 52 with WindowInfo

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

the class FragmentHelper method createFakeWindowInfo.

@SuppressWarnings("unchecked")
public WindowInfo createFakeWindowInfo(String src, String fragmentId) {
    Element screenElement = DocumentHelper.createElement("screen");
    screenElement.addAttribute("template", src);
    screenElement.addAttribute("id", fragmentId);
    Element windowElement = screenXmlLoader.load(src, fragmentId, Collections.emptyMap());
    Class<? extends ScreenFragment> fragmentClass;
    String className = windowElement.attributeValue("class");
    if (StringUtils.isNotEmpty(className)) {
        fragmentClass = (Class<? extends ScreenFragment>) scripting.loadClassNN(className);
    } else {
        fragmentClass = AbstractFrame.class;
    }
    return new WindowInfo(fragmentId, new WindowAttributesProvider() {

        @Override
        public WindowInfo.Type getType(WindowInfo wi) {
            return WindowInfo.Type.FRAGMENT;
        }

        @Override
        public String getTemplate(WindowInfo wi) {
            return src;
        }

        @Nonnull
        @Override
        public Class<? extends FrameOwner> getControllerClass(WindowInfo wi) {
            return fragmentClass;
        }

        @Override
        public WindowInfo resolve(WindowInfo windowInfo) {
            return windowInfo;
        }
    }, screenElement);
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) WindowAttributesProvider(com.haulmont.cuba.gui.config.WindowAttributesProvider) Nonnull(javax.annotation.Nonnull) Element(org.dom4j.Element) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 53 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 54 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];
    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());
    WindowManager wm = App.getInstance().getWindowManager();
    Window window = wm.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) {
        SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentation() != null) {
            ((HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
        }
    }
    if (window.getFrameOwner() instanceof LegacyFrame) {
        DsContext dsContext = ((LegacyFrame) window.getFrameOwner()).getDsContext();
        if (dsContext != null) {
            ((DsContextImplementation) dsContext).resumeSuspended();
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) HasPresentations(com.haulmont.cuba.gui.components.HasPresentations) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) DsContext(com.haulmont.cuba.gui.data.DsContext) 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) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager) Filter(com.haulmont.cuba.gui.components.Filter)

Example 55 with WindowInfo

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

the class MainScreen method openSettingsScreen.

protected void openSettingsScreen() {
    WindowInfo settingsInfo = getBeanLocator().get(WindowConfig.class).getWindowInfo("settings");
    MapScreenOptions screenOptions = new MapScreenOptions(loadSettingsScreenParams(settingsInfo));
    UiControllerUtils.getScreenContext(this).getScreens().create(settingsInfo.getId(), OpenMode.NEW_TAB, screenOptions).show();
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)74 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)43 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 WindowManager (com.haulmont.cuba.gui.WindowManager)9 Element (org.dom4j.Element)8 Window (com.haulmont.cuba.gui.components.Window)7 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)5 HashMap (java.util.HashMap)5 Screens (com.haulmont.cuba.gui.Screens)3 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 DetachedFrame (com.haulmont.cuba.desktop.DetachedFrame)2 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)2 Notifications (com.haulmont.cuba.gui.Notifications)2 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Fragment (com.haulmont.cuba.gui.components.Fragment)2 RelatedAction (com.haulmont.cuba.gui.components.actions.RelatedAction)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2