private Theme loadTheme(String name, Theme.Type type) throws IOException { Theme theme = findTheme(name, type); if (theme != null && (theme.getParentName() != null || theme.getImportName() != null)) { List<Theme> themes = new LinkedList<>(); themes.add(theme); if (theme.getImportName() != null) { String[] s = theme.getImportName().split("/"); themes.add(findTheme(s[1], Theme.Type.valueOf(s[0].toUpperCase()))); } if (theme.getParentName() != null) { for (String parentName = theme.getParentName(); parentName != null; parentName = theme.getParentName()) { theme = findTheme(parentName, type); themes.add(theme); if (theme.getImportName() != null) { String[] s = theme.getImportName().split("/"); themes.add(findTheme(s[1], Theme.Type.valueOf(s[0].toUpperCase()))); } } } return new ExtendingTheme(themes); } else { return theme; } }
public static Theme getTheme(long uid) { for (Theme selectedTheme : themeList) { if (selectedTheme.getUid() == uid) { return selectedTheme; } } return null; }
public static boolean removeTheme(Long uid) { for (Theme accessTheme : themeList) { if (accessTheme.getUid().equals(uid)) { themeList.remove(accessTheme); return true; } } return false; }
@Override public InputStream getResourceAsStream(String path) throws IOException { for (Theme t : themes) { InputStream resource = t.getResourceAsStream(path); if (resource != null) { return resource; } } return null; }
@Override public URL getResource(String path) throws IOException { for (Theme t : themes) { URL resource = t.getResource(path); if (resource != null) { return resource; } } return null; }
@Override public InputStream getTemplateAsStream(String name) throws IOException { for (Theme t : themes) { InputStream template = t.getTemplateAsStream(name); if (template != null) { return template; } } return null; }
@Override public URL getTemplate(String name) throws IOException { for (Theme t : themes) { URL template = t.getTemplate(name); if (template != null) { return template; } } return null; }