use of com.haulmont.cuba.gui.xml.layout.LayoutLoader in project cuba by cuba-platform.
the class WindowManager method openFrame.
public Frame openFrame(Frame parentFrame, Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
if (params == null) {
params = Collections.emptyMap();
}
// Parameters can be useful later
params = createParametersMap(windowInfo, params);
String src = windowInfo.getTemplate();
ComponentLoaderContext context = new ComponentLoaderContext(params);
context.setDsContext(parentFrame.getDsContext());
context.setFullFrameId(windowInfo.getId());
context.setCurrentFrameId(windowInfo.getId());
LayoutLoader loader = new LayoutLoader(context, AppConfig.getFactory(), LayoutLoaderConfig.getFrameLoaders());
loader.setLocale(getLocale());
loader.setMessagesPack(parentFrame.getMessagesPack());
StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
Frame component;
String frameId = id != null ? id : windowInfo.getId();
Pair<ComponentLoader, Element> loaderElementPair = loader.createFrameComponent(src, frameId, context.getParams());
component = (Frame) loaderElementPair.getFirst().getResultComponent();
if (parent != null) {
showFrame(parent, component);
} else {
component.setFrame(parentFrame);
}
loaderElementPair.getFirst().loadComponent();
if (component.getMessagesPack() == null) {
component.setMessagesPack(parentFrame.getMessagesPack());
}
context.executeInjectTasks();
context.setFrame(component);
context.executePostWrapTasks();
// init of frame
context.executeInitTasks();
context.executePostInitTasks();
loadDescriptorWatch.stop();
initDebugIds(component);
userActionsLog.trace("Frame {} was opened", windowInfo.getId());
return component;
}
use of com.haulmont.cuba.gui.xml.layout.LayoutLoader in project cuba by cuba-platform.
the class FrameComponentLoader method createComponent.
@Override
public void createComponent() {
String src = element.attributeValue("src");
String screenId = element.attributeValue("screen");
if (src == null && screenId == null) {
throw new GuiDevelopmentException("Either 'src' or 'screen' must be specified for 'frame'", context.getFullFrameId());
}
if (src == null) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
src = windowInfo.getTemplate();
if (src == null) {
throw new GuiDevelopmentException("Screen " + screenId + " doesn't have template path configured", context.getFullFrameId());
}
}
if (element.attributeValue("id") != null) {
frameId = element.attributeValue("id");
}
LayoutLoader layoutLoader = new LayoutLoader(context, factory, LayoutLoaderConfig.getFrameLoaders());
layoutLoader.setLocale(getLocale());
layoutLoader.setMessagesPack(getMessagesPack());
String currentFrameId = context.getCurrentFrameId();
context.setCurrentFrameId(frameId);
try {
Pair<ComponentLoader, Element> loaderElementPair = layoutLoader.createFrameComponent(src, frameId, context.getParams());
frameLoader = loaderElementPair.getFirst();
resultComponent = (Frame) frameLoader.getResultComponent();
} finally {
context.setCurrentFrameId(currentFrameId);
}
}
use of com.haulmont.cuba.gui.xml.layout.LayoutLoader in project cuba by cuba-platform.
the class PopupButtonLoader method createContent.
protected void createContent() {
if (element != null && element.element("popup") != null) {
LayoutLoader loader = new LayoutLoader(context, factory, layoutLoaderConfig);
loader.setLocale(getLocale());
loader.setMessagesPack(getMessagesPack());
List<Element> elements = Dom4j.elements(element.element("popup"));
if (elements.size() != 0) {
Element innerElement = elements.get(0);
if (innerElement != null) {
popupComponentLoader = loader.createComponent(innerElement);
resultComponent.setPopupContent(popupComponentLoader.getResultComponent());
resultComponent.setAutoClose(false);
}
}
}
}
use of com.haulmont.cuba.gui.xml.layout.LayoutLoader in project cuba by cuba-platform.
the class RuntimePropertiesFrameLoader method createComponent.
@Override
public void createComponent() {
String src = element.attributeValue("src");
if (src == null) {
src = DEFAULT_DESCRIPTOR;
}
String screenPath = src;
if (element.attributeValue("id") != null) {
screenPath = element.attributeValue("id");
}
frameId = screenPath;
LayoutLoader layoutLoader = new LayoutLoader(context, factory, LayoutLoaderConfig.getFrameLoaders());
layoutLoader.setLocale(getLocale());
layoutLoader.setMessagesPack(getMessagesPack());
String currentFrameId = context.getCurrentFrameId();
context.setCurrentFrameId(frameId);
try {
Pair<ComponentLoader, Element> loaderElementPair = layoutLoader.createFrameComponent(src, frameId, context.getParams());
frameLoader = loaderElementPair.getFirst();
resultComponent = (Frame) frameLoader.getResultComponent();
} finally {
context.setCurrentFrameId(currentFrameId);
}
}
Aggregations