use of com.haulmont.cuba.gui.sys.FrameHelper in project jmix by jmix-framework.
the class CubaFragmentComponentLoader method createWindowInfo.
@Override
protected WindowInfo createWindowInfo(Element element) {
String src = element.attributeValue("src");
if (src == null) {
return super.createWindowInfo(element);
}
String frameId;
if (element.attributeValue("id") != null) {
frameId = element.attributeValue("id");
} else if (element.attributeValue("screen") != null) {
frameId = element.attributeValue("screen");
} else {
frameId = src;
}
FrameHelper frameHelper = getFrameHelper();
return frameHelper.createFakeWindowInfo(src, frameId);
}
use of com.haulmont.cuba.gui.sys.FrameHelper in project jmix by jmix-framework.
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();
FrameHelper frameHelper = getFrameHelper();
WindowInfo windowInfo = frameHelper.createFakeWindowInfo(src, fragmentId);
UiComponents uiComponents = applicationContext.getBean(UiComponents.class);
Fragment fragment = uiComponents.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, applicationContext.getBean(ScreenData.class));
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.setMessageGroup(fragmentHelper.getMessageGroup(windowInfo.getTemplate()));
innerContext.setCurrentFrameId(fragmentId);
innerContext.setFullFrameId(frameId);
innerContext.setFrame(fragment);
innerContext.setParent(parentContext);
LayoutLoader layoutLoader = getLayoutLoader(innerContext);
ScreenXmlLoader screenXmlLoader = applicationContext.getBean(ScreenXmlLoader.class);
Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
String messagesPack = rootElement.attributeValue("messagesPack");
if (messagesPack != null) {
innerContext.setMessageGroup(messagesPack);
}
this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
}
this.resultComponent = fragment;
}
Aggregations