use of com.haulmont.cuba.gui.config.WindowAttributesProvider 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);
}
Aggregations