Search in sources :

Example 1 with ScreenComponentDescriptor

use of com.haulmont.cuba.gui.components.ScreenComponentDescriptor in project cuba by cuba-platform.

the class ScreensHelper method getScreenComponents.

public List<ScreenComponentDescriptor> getScreenComponents(String screenId) {
    String key = getScreenComponentsCacheKey(screenId, userSessionSource.getLocale());
    List<ScreenComponentDescriptor> screenComponents = screenComponentsCache.get(key);
    if (screenComponents != null) {
        return screenComponents;
    }
    List<ScreenComponentDescriptor> components = new ArrayList<>();
    WindowInfo windowInfo = windowConfig.findWindowInfo(screenId);
    if (windowInfo != null) {
        String template = windowInfo.getTemplate();
        try {
            Element layoutElement = getRootLayoutElement(template);
            if (layoutElement != null) {
                findScreenComponents(components, null, layoutElement);
            }
        } catch (FileNotFoundException e) {
            log.error("Can't obtain screen's root layout: ", e);
        }
    }
    components = ImmutableList.copyOf(components);
    cacheScreenComponents(key, components);
    return components;
}
Also used : Element(org.dom4j.Element) FileNotFoundException(java.io.FileNotFoundException) ScreenComponentDescriptor(com.haulmont.cuba.gui.components.ScreenComponentDescriptor) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 2 with ScreenComponentDescriptor

use of com.haulmont.cuba.gui.components.ScreenComponentDescriptor in project cuba by cuba-platform.

the class ScreensHelper method findScreenComponents.

public void findScreenComponents(List<ScreenComponentDescriptor> components, @Nullable ScreenComponentDescriptor parent, Element root) {
    List<Element> elements = isFrame(root) ? getFrameElements(root) : root.elements();
    for (Element element : elements) {
        if (isComponentElement(element)) {
            // noinspection IncorrectCreateEntity
            ScreenComponentDescriptor descriptor = new ScreenComponentDescriptor(element, parent);
            components.add(descriptor);
            findScreenComponents(components, descriptor, element);
        }
    }
}
Also used : Element(org.dom4j.Element) ScreenComponentDescriptor(com.haulmont.cuba.gui.components.ScreenComponentDescriptor)

Aggregations

ScreenComponentDescriptor (com.haulmont.cuba.gui.components.ScreenComponentDescriptor)2 Element (org.dom4j.Element)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 FileNotFoundException (java.io.FileNotFoundException)1