Search in sources :

Example 56 with WindowInfo

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

the class App method navigateTo.

/**
 * Initialize new TopLevelWindow and replace current.
 *
 * @param topLevelWindowId target top level window id
 * @deprecated Use {@link Screens#create(Class, Screens.LaunchMode)} with {@link OpenMode#ROOT}
 */
@Deprecated
public void navigateTo(String topLevelWindowId) {
    AppUI ui = AppUI.getCurrent();
    WindowInfo windowInfo = windowConfig.getWindowInfo(topLevelWindowId);
    Screens screens = ui.getScreens();
    Screen screen = screens.create(windowInfo.asScreen(), OpenMode.ROOT);
    screens.show(screen);
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) Screens(com.haulmont.cuba.gui.Screens) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 57 with WindowInfo

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

the class RuntimePropertiesFrameLoader method createComponent.

@Override
public void createComponent() {
    String src = element.attributeValue("src");
    String screenId = element.attributeValue("id");
    if (src == null) {
        src = DEFAULT_DESCRIPTOR;
    }
    String fragmentId = screenId != null ? screenId : src;
    FragmentHelper fragmentHelper = getFragmentHelper();
    WindowInfo windowInfo = fragmentHelper.createFakeWindowInfo(src, fragmentId);
    Fragment fragment = factory.create(Fragment.NAME);
    ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
    // setup screen and controller
    ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
    FrameOwner hostController = parentContext.getFrame().getFrameOwner();
    // setup screen and controller
    setHostController(controller, hostController);
    setWindowId(controller, windowInfo.getId());
    setFrame(controller, fragment);
    setScreenContext(controller, new ScreenContextImpl(windowInfo, parentContext.getOptions(), getScreenContext(hostController)));
    setScreenData(controller, new ScreenDataImpl());
    FragmentImplementation fragmentImpl = (FragmentImplementation) fragment;
    fragmentImpl.setFrameOwner(controller);
    fragmentImpl.setId(fragmentId);
    FragmentContextImpl frameContext = new FragmentContextImpl(fragment, innerContext);
    ((FrameImplementation) fragment).setContext(frameContext);
    if (windowInfo.getTemplate() != null) {
        String frameId = fragmentId;
        if (parentContext.getFullFrameId() != null) {
            frameId = parentContext.getFullFrameId() + "." + frameId;
        }
        innerContext = new ComponentLoaderContext(getContext().getOptions());
        innerContext.setMessagesPack(fragmentHelper.getMessagePack(windowInfo.getTemplate()));
        innerContext.setCurrentFrameId(fragmentId);
        innerContext.setFullFrameId(frameId);
        innerContext.setFrame(fragment);
        innerContext.setParent(parentContext);
        LayoutLoader layoutLoader = getLayoutLoader(innerContext);
        ScreenXmlLoader screenXmlLoader = beanLocator.get(ScreenXmlLoader.NAME);
        Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
        String messagesPack = rootElement.attributeValue("messagesPack");
        if (messagesPack != null) {
            innerContext.setMessagesPack(messagesPack);
        }
        this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
    }
    this.resultComponent = fragment;
}
Also used : LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) FragmentImplementation(com.haulmont.cuba.gui.components.sys.FragmentImplementation) Element(org.dom4j.Element) FragmentContextImpl(com.haulmont.cuba.gui.sys.FragmentContextImpl) FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) Fragment(com.haulmont.cuba.gui.components.Fragment) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) ScreenDataImpl(com.haulmont.cuba.gui.model.impl.ScreenDataImpl) FragmentHelper(com.haulmont.cuba.gui.sys.FragmentHelper) ScreenContextImpl(com.haulmont.cuba.gui.sys.ScreenContextImpl) ScreenXmlLoader(com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader)

Example 58 with WindowInfo

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

the class ConstraintEditor method openWizard.

public void openWizard() {
    String entityNameValue = entityName.getValue();
    if (StringUtils.isBlank(entityNameValue)) {
        showNotification(getMessage("notification.entityIsEmpty"), NotificationType.HUMANIZED);
        entityName.focus();
        return;
    }
    FakeFilterSupport fakeFilterSupport = new FakeFilterSupport(this, metadata.getSession().getClass(entityNameValue));
    WindowInfo windowInfo = windowConfig.getWindowInfo("filterEditor");
    Map<String, Object> params = new HashMap<>();
    Constraint constraint = getItem();
    final Filter fakeFilter = fakeFilterSupport.createFakeFilter();
    final FilterEntity filterEntity = fakeFilterSupport.createFakeFilterEntity(constraint.getFilterXml());
    final ConditionsTree conditionsTree = fakeFilterSupport.createFakeConditionsTree(fakeFilter, filterEntity);
    params.put("filter", fakeFilter);
    params.put("filterEntity", filterEntity);
    params.put("conditionsTree", conditionsTree);
    params.put("useShortConditionForm", true);
    params.put("hideDynamicAttributes", constraint.getCheckType() != ConstraintCheckType.DATABASE);
    params.put("hideCustomConditions", constraint.getCheckType() != ConstraintCheckType.DATABASE);
    FilterEditor filterEditor = (FilterEditor) getWindowManager().openWindow(windowInfo, OpenType.DIALOG, params);
    filterEditor.addCloseListener(actionId -> {
        if (!COMMIT_ACTION_ID.equals(actionId))
            return;
        FilterParser filterParser1 = AppBeans.get(FilterParser.class);
        // todo eude rename com.haulmont.cuba.gui.components.filter.FilterParser
        filterEntity.setXml(filterParser1.getXml(filterEditor.getConditions(), Param.ValueProperty.DEFAULT_VALUE));
        if (filterEntity.getXml() != null) {
            Element element = dom4JTools.readDocument(filterEntity.getXml()).getRootElement();
            com.haulmont.cuba.core.global.filter.FilterParser filterParser = new com.haulmont.cuba.core.global.filter.FilterParser(element);
            Constraint item = getItem();
            if (item.getCheckType().database()) {
                String jpql = new SecurityJpqlGenerator().generateJpql(filterParser.getRoot());
                constraint.setWhereClause(jpql);
                Set<String> joins = filterParser.getRoot().getJoins();
                if (!joins.isEmpty()) {
                    String joinsStr = new TextStringBuilder().appendWithSeparators(joins, " ").toString();
                    constraint.setJoinClause(joinsStr);
                }
            }
            if (item.getCheckType().memory()) {
                String groovy = new GroovyGenerator().generateGroovy(filterParser.getRoot());
                constraint.setGroovyScript(groovy);
            }
            constraint.setFilterXml(filterEntity.getXml());
        }
    });
}
Also used : Constraint(com.haulmont.cuba.security.entity.Constraint) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Element(org.dom4j.Element) GroovyGenerator(com.haulmont.cuba.core.global.filter.GroovyGenerator) FilterEditor(com.haulmont.cuba.gui.components.filter.edit.FilterEditor) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) TextStringBuilder(org.apache.commons.text.TextStringBuilder) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) FakeFilterSupport(com.haulmont.cuba.gui.components.filter.FakeFilterSupport) FilterParser(com.haulmont.cuba.gui.components.filter.FilterParser) SecurityJpqlGenerator(com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator) ConditionsTree(com.haulmont.cuba.gui.components.filter.ConditionsTree)

Example 59 with WindowInfo

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

the class HistoryNavigator method handleRootBackNavigation.

protected void handleRootBackNavigation(NavigationState previousState) {
    WindowInfo rootWindowInfo = urlChangeHandler.windowConfig.findWindowInfoByRoute(previousState.getRoot());
    if (rootWindowInfo == null) {
        log.debug("Unable to find registered root screen with route: '{}'", previousState.getRoot());
        urlChangeHandler.revertNavigationState();
        return;
    }
    Class<? extends FrameOwner> requestedScreenClass = rootWindowInfo.getControllerClass();
    RootWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
    Class<? extends FrameOwner> currentScreenClass = topLevelWindow != null ? topLevelWindow.getFrameOwner().getClass() : null;
    if (currentScreenClass != null && requestedScreenClass.isAssignableFrom(currentScreenClass)) {
        if (Window.HasWorkArea.class.isAssignableFrom(requestedScreenClass)) {
            if (closeWorkAreaScreens()) {
                history.backward();
            }
        } else {
            history.backward();
        }
    } else {
        urlChangeHandler.getScreenNavigator().handleScreenNavigation(previousState);
        /*
             * Since back navigation from one root screen to another root screen
             * can be performed only via screen opening we have to trigger history
             * back twice.
             */
        history.backward();
        history.backward();
    }
}
Also used : RootWindow(com.haulmont.cuba.gui.components.RootWindow) Window(com.haulmont.cuba.gui.components.Window) RootWindow(com.haulmont.cuba.gui.components.RootWindow) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 60 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)

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