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);
}
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;
}
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());
}
});
}
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();
}
}
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());
}
}
Aggregations