Search in sources :

Example 26 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class MetadataBuildSupport method init.

public List<XmlFile> init() {
    List<XmlFile> metadataXmlList = new ArrayList<>();
    StringTokenizer metadataFilesTokenizer = new StringTokenizer(getMetadataConfig());
    for (String fileName : metadataFilesTokenizer.getTokenArray()) {
        metadataXmlList.add(new XmlFile(fileName, readXml(fileName)));
    }
    return metadataXmlList;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 27 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class WindowConfig method loadScreensXml.

protected void loadScreensXml() {
    String configName = AppContext.getProperty(WINDOW_CONFIG_XML_PROP);
    StringTokenizer tokenizer = new StringTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            try (InputStream stream = resource.getInputStream()) {
                loadConfig(dom4JTools.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException("Unable to read window config from " + location, e);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Example 28 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class MenuConfig method init.

protected void init() {
    rootItems.clear();
    String configName = AppContext.getProperty(MENU_CONFIG_XML_PROP);
    StringTokenizer tokenizer = new StringTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            try (InputStream stream = resource.getInputStream()) {
                Element rootElement = dom4JTools.readDocument(stream).getRootElement();
                loadMenuItems(rootElement, null);
            } catch (IOException e) {
                throw new RuntimeException("Unable to read menu config", e);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStream(java.io.InputStream) Element(org.dom4j.Element) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Example 29 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class ThemeConstantsRepository method init.

protected void init() {
    String configName = AppContext.getProperty("cuba.themeConfig");
    if (!StringUtils.isBlank(configName)) {
        Map<String, Map<String, String>> themeProperties = new HashMap<>();
        StringTokenizer tokenizer = new StringTokenizer(configName);
        for (String fileName : tokenizer.getTokenArray()) {
            String themeName = parseThemeName(fileName);
            if (StringUtils.isNotBlank(themeName)) {
                Map<String, String> themeMap = themeProperties.computeIfAbsent(themeName, k -> new HashMap<>());
                loadThemeProperties(fileName, themeMap);
            }
        }
        Map<String, ThemeConstants> themes = new LinkedHashMap<>();
        for (Map.Entry<String, Map<String, String>> entry : themeProperties.entrySet()) {
            themes.put(entry.getKey(), new ThemeConstants(entry.getValue()));
        }
        this.themeConstantsMap = Collections.unmodifiableMap(themes);
    } else {
        this.themeConstantsMap = Collections.emptyMap();
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 30 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class WebExternalUIComponentsSource method _registerAppComponents.

protected void _registerAppComponents() {
    String configNames = AppContext.getProperty(WEB_COMPONENTS_CONFIG_XML_PROP);
    if (Strings.isNullOrEmpty(configNames)) {
        return;
    }
    log.debug("Loading UI components from {}", configNames);
    StringTokenizer tokenizer = new StringTokenizer(configNames);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                _registerComponent(stream);
            } catch (ClassNotFoundException | IOException e) {
                throw new RuntimeException("Unable to load components config " + location, e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Aggregations

StringTokenizer (org.apache.commons.text.StringTokenizer)43 IOException (java.io.IOException)9 Resource (org.springframework.core.io.Resource)9 ArrayList (java.util.ArrayList)8 InputStream (java.io.InputStream)7 Element (org.dom4j.Element)5 AppContextInitializedEvent (com.haulmont.cuba.core.sys.events.AppContextInitializedEvent)3 File (java.io.File)3 TextStringBuilder (org.apache.commons.text.TextStringBuilder)3 Events (com.haulmont.cuba.core.global.Events)2 Properties (java.util.Properties)2 Nullable (javax.annotation.Nullable)2 Preconditions (com.google.common.base.Preconditions)1 Resources (com.haulmont.cuba.core.global.Resources)1 CubaClassPathXmlApplicationContext (com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext)1 DesktopResources (com.haulmont.cuba.desktop.DesktopResources)1 ComponentDecorator (com.haulmont.cuba.desktop.theme.ComponentDecorator)1 Specification (io.github.linuxforhealth.api.Specification)1 Stores (io.jmix.core.Stores)1 Sequence (io.jmix.data.Sequence)1