aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
diff options
context:
space:
mode:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>2007-07-17 08:28:41 +0000
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>2007-07-17 08:28:41 +0000
commit511a2b97c27f986d0f6ee5231e76c913cf467f39 (patch)
treec412a5626c8ab676e4ede4829c43790ec539ed7f /src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
parent2b666eb05f7a3faf454c3654168fa3e6f7cf62f3 (diff)
downloadvaadin-framework-511a2b97c27f986d0f6ee5231e76c913cf467f39.tar.gz
vaadin-framework-511a2b97c27f986d0f6ee5231e76c913cf467f39.zip
Started a major refactoring: removed terminal.web, added terminal.gwt.server. Refactoring is not even nearly complete, but can already replace old web terminal implementation
svn changeset:1864/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java')
-rw-r--r--src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java210
1 files changed, 0 insertions, 210 deletions
diff --git a/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java b/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
deleted file mode 100644
index 047b787bf5..0000000000
--- a/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
-package com.itmill.toolkit.terminal.web;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Theme source for consisting of collection of other theme sources. This class
- * is used to implement the retrieval of themes from multiple sources. Also this
- * class implements the inheritance of themes by first retrieving the relevant
- * parent theme information.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public class CollectionThemeSource implements ThemeSource {
-
- private List sources = new LinkedList();
-
- /**
- * Gets the name of the ThemeSource.
- *
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getName()
- */
- public String getName() {
- return "THEMES";
- }
-
- /**
- * Gets the XSL stream for the specified theme and web-browser type.
- *
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme,
- * WebBrowser)
- */
- public Collection getXSLStreams(Theme theme, WebBrowser type)
- throws ThemeException {
- Collection xslFiles = new LinkedList();
-
- // Adds parent theme XSL
- xslFiles.addAll(this.getParentXSLStreams(theme, type));
-
- // Adds theme XSL, Handle subdirectories: return the first match
- for (Iterator i = this.sources.iterator(); i.hasNext();) {
- ThemeSource source = (ThemeSource) i.next();
- if (source.getThemes().contains(theme))
- xslFiles.addAll(source.getXSLStreams(theme, type));
- }
-
- return xslFiles;
- }
-
- /**
- *
- * @param theme
- * @param type
- * @return
- * @throws ThemeException
- * If the resource is not found or there was some problem
- * finding the resource.
- */
- private Collection getParentXSLStreams(Theme theme, WebBrowser type)
- throws ThemeException {
- Collection xslFiles = new LinkedList();
- String parentName = theme.getParent();
- if (parentName != null) {
- Theme parent = this.getThemeByName(parentName);
- if (parent != null) {
- xslFiles.addAll(this.getXSLStreams(parent, type));
- } else {
- throw new ThemeSource.ThemeException(
- "Parent theme not found for name: " + parentName);
- }
- }
- return xslFiles;
- }
-
- /**
- * Gets the last modification time, used to reload theme on changes.
- *
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getModificationTime()
- */
- public long getModificationTime() {
- long modTime = 0;
- for (Iterator i = this.sources.iterator(); i.hasNext();) {
- long t = ((ThemeSource) i.next()).getModificationTime();
- if (t > modTime)
- modTime = t;
- }
- return modTime;
- }
-
- /**
- * Gets the input stream for the resource with the specified resource id.
- *
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getResource(String)
- */
- public InputStream getResource(String resourceId) throws ThemeException {
-
- // Resolves theme name and resource name
- int delim = resourceId.indexOf("/");
- String subResourceId = "";
- String themeName = "";
- if (delim >= 0 && delim < resourceId.length() - 1) {
- subResourceId = resourceId.substring(delim + 1);
- themeName = resourceId.substring(0, delim);
- }
-
- // Gets the list of themes to look for the resource
- List themes = new LinkedList();
- while (themeName != null && themeName.length() > 0) {
- Theme t = this.getThemeByName(themeName);
- if (t != null)
- themes.add(themeName);
- themeName = t.getParent();
- }
-
- // Iterate all themes in list
- for (Iterator ti = themes.iterator(); ti.hasNext();) {
- String name = (String) ti.next();
- String resource = name + "/" + subResourceId;
- // Search all sources
- for (Iterator i = this.sources.iterator(); i.hasNext();) {
- try {
- InputStream in = ((ThemeSource) i.next())
- .getResource(resource);
- if (in != null)
- return in;
- } catch (ThemeException e) {
- // Ignore and continue to next source
- }
- }
- }
-
- throw new ThemeException("Theme resource not found:" + subResourceId
- + " in themes " + themes);
- }
-
- /**
- * Gets the list of themes in the theme source.
- *
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getThemes()
- */
- public Collection getThemes() {
- Collection themes = new LinkedList();
- for (Iterator i = this.sources.iterator(); i.hasNext();) {
- Collection c = ((ThemeSource) i.next()).getThemes();
- themes.addAll(c);
- }
- return themes;
- }
-
- /**
- * Gets the theme instance by name.
- *
- * @param name
- * the theme name.
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getThemeByName(String)
- */
- public Theme getThemeByName(String name) {
- for (Iterator i = this.sources.iterator(); i.hasNext();) {
- Theme t = ((ThemeSource) i.next()).getThemeByName(name);
- if (t != null)
- return t;
- }
- return null;
- }
-
- /**
- * Adds new theme source to this collection.
- *
- * @param source
- * the Theme source to be added.
- */
- public void add(ThemeSource source) {
- this.sources.add(source);
- }
-
-}