You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2010/11/18 20:58:34 UTC

svn commit: r1036594 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/config/ tobago-core/src/main/java/org/apache/myfaces/tobago/context/ tobago-core/src/test/java/org/apache/myfaces/tobago/context/ tobago-core/src/test/...

Author: bommel
Date: Thu Nov 18 19:58:33 2010
New Revision: 1036594

URL: http://svn.apache.org/viewvc?rev=1036594&view=rev
Log:
(TOBAGO-943) Consolidation of the Tobago JavaScript files and css  files

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResource.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResources.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoScript.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoStyle.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/context/ThemeParserTest.java
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml
Removed:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/style.css
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Theme.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
    myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java Thu Nov 18 19:58:33 2010
@@ -47,7 +47,7 @@ public class
   private Theme defaultTheme;
   private String defaultThemeName;
   private List<String> resourceDirs;
-  private Map<String, Theme> availableTheme;
+  private Map<String, Theme> availableThemes;
   private RenderersConfig renderersConfig;
   private ProjectStage projectStage;
 
@@ -63,7 +63,7 @@ public class
   // TODO one init method
   public void resolveThemes() {
     if (defaultThemeName != null) {
-      defaultTheme = availableTheme.get(defaultThemeName);
+      defaultTheme = availableThemes.get(defaultThemeName);
       checkThemeIsAvailable(defaultThemeName, defaultTheme);
       if (LOG.isDebugEnabled()) {
         LOG.debug("name = '{}'", defaultThemeName);
@@ -71,7 +71,7 @@ public class
       }
     } else {
       int deep = 0;
-      for (Map.Entry<String, Theme> entry : availableTheme.entrySet()) {
+      for (Map.Entry<String, Theme> entry : availableThemes.entrySet()) {
         Theme theme = entry.getValue();
         if (theme.getFallbackList().size() > deep) {
           defaultTheme = theme;
@@ -92,7 +92,7 @@ public class
     }
     if (!supportedThemeNames.isEmpty()) {
       for (String name : supportedThemeNames) {
-        Theme theme = availableTheme.get(name);
+        Theme theme = availableThemes.get(name);
         checkThemeIsAvailable(name, theme);
         supportedThemes.add(theme);
         if (LOG.isDebugEnabled()) {
@@ -107,7 +107,7 @@ public class
     if (theme == null) {
       String error = "Theme not found! name: '" + name + "'. "
           + "Please ensure you have a tobago-theme.xml file in your "
-          + "theme jar. Found the following themes: " + availableTheme.keySet();
+          + "theme jar. Found the following themes: " + availableThemes.keySet();
       LOG.error(error);
       throw new RuntimeException(error);
     }
@@ -173,8 +173,11 @@ public class
     return defaultTheme;
   }
 
-  public void setAvailableThemes(Map<String, Theme> availableTheme) {
-    this.availableTheme = availableTheme;
+  public void setAvailableThemes(Map<String, Theme> availableThemes) {
+    this.availableThemes = availableThemes;
+    for (Theme theme : this.availableThemes.values()) {
+      addResourceDir(theme.getResourcePath());
+    }
   }
 
   public RenderersConfig getRenderersConfig() {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java Thu Nov 18 19:58:33 2010
@@ -22,7 +22,6 @@ import org.apache.myfaces.tobago.config.
 import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
-import java.util.Map;
 
 public class ResourceManagerFactory {
 
@@ -49,18 +48,12 @@ public class ResourceManagerFactory {
       ServletContext servletContext, TobagoConfig tobagoConfig)
       throws ServletException {
     assert !initialized;
-    ResourceManagerImpl resourceManager
-        = new ResourceManagerImpl(tobagoConfig);
+    ResourceManagerImpl resourceManager= new ResourceManagerImpl(tobagoConfig);
 
-    ThemeBuilder themeBuilder = new ThemeBuilder();
-    ResourceLocator resourceLocator = new ResourceLocator(
-        servletContext, resourceManager, themeBuilder);
+    ThemeBuilder themeBuilder = new ThemeBuilder(tobagoConfig);
+    ResourceLocator resourceLocator = new ResourceLocator(servletContext, resourceManager, themeBuilder);
     resourceLocator.locate();
-    Map<String, Theme> availableThemes = themeBuilder.resolveThemes(tobagoConfig.getRenderersConfig());
-    tobagoConfig.setAvailableThemes(availableThemes);
-    for (Theme theme : availableThemes.values()) {
-      tobagoConfig.addResourceDir(theme.getResourcePath());
-    }
+    themeBuilder.resolveThemes();
 
     servletContext.setAttribute(RESOURCE_MANAGER, resourceManager);
 

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Theme.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Theme.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Theme.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Theme.java Thu Nov 18 19:58:33 2010
@@ -32,4 +32,9 @@ public interface Theme {
   String getResourcePath();
 
   RenderersConfig getRenderersConfig();
+
+  String[] getScriptResources(boolean production);
+
+  String[] getStyleResources(boolean production);
+
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java Thu Nov 18 19:58:33 2010
@@ -17,6 +17,7 @@ package org.apache.myfaces.tobago.contex
  * limitations under the License.
  */
 
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,8 +35,13 @@ class ThemeBuilder {
   private static final Logger LOG = LoggerFactory.getLogger(ThemeBuilder.class);
 
   private List<ThemeImpl> availableThemes = new ArrayList<ThemeImpl>();
+  private TobagoConfig tobagoConfig;
 
-  public Map<String, Theme> resolveThemes(RenderersConfig renderersConfig) {
+  ThemeBuilder(TobagoConfig tobagoConfig) {
+    this.tobagoConfig = tobagoConfig;
+  }
+
+  public void resolveThemes() {
     Map<String, ThemeImpl> map = new HashMap<String, ThemeImpl>();
     for (ThemeImpl theme : availableThemes) {
       LOG.debug("theme from tobago-theme.xml files: {} ", theme.getName());
@@ -50,7 +56,7 @@ class ThemeBuilder {
       theme.resolveFallbacks();
     }
     for (ThemeImpl theme : availableThemes) {
-      theme.resolveRendererConfig(renderersConfig);
+      theme.resolveRendererConfig(tobagoConfig.getRenderersConfig());
     }
     Map<String, Theme> result = new HashMap<String, Theme>();
     for (ThemeImpl theme : availableThemes) {
@@ -61,8 +67,13 @@ class ThemeBuilder {
         result.put(theme.getDeprecatedName(), theme);
       }
     }
-
-    return Collections.unmodifiableMap(result);
+    for (ThemeImpl theme : availableThemes) {
+      theme.resolveResources();
+    }
+    for (ThemeImpl theme : availableThemes) {
+      theme.init();
+    }
+    tobagoConfig.setAvailableThemes(Collections.unmodifiableMap(result));
   }
 
   public void addTheme(ThemeImpl theme) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java Thu Nov 18 19:58:33 2010
@@ -47,6 +47,19 @@ class ThemeImpl implements Theme, Serial
 
   private RenderersConfigImpl renderersConfig;
 
+  private TobagoResources productionResources;
+
+  private TobagoResources resources;
+
+  private String[] productionScripts;
+
+  private String[] productionStyles;
+
+  private String[] scripts;
+
+  private String[] styles;
+
+
   public String getName() {
     return name;
   }
@@ -140,6 +153,15 @@ class ThemeImpl implements Theme, Serial
     }
   }
 
+  public void resolveResources() {
+    ThemeImpl fallback = getFallback();
+    if (fallback != null) {
+      fallback.resolveResources();
+      addResources(fallback.getProductionResources());
+      addResources(fallback.getResources());
+    }
+  }
+
   public String toString() {
 //    LOG.warn("Should not be called!", new Exception());
     return name;
@@ -156,4 +178,79 @@ class ThemeImpl implements Theme, Serial
   RenderersConfigImpl getRenderersConfigImpl() {
     return renderersConfig;
   }
+
+  public TobagoResources getResources() {
+    return resources;
+  }
+
+  public TobagoResources getProductionResources() {
+    return productionResources;
+  }
+
+  public void addResources(TobagoResources resources) {
+    if (resources.isProduction()) {
+      if (productionResources != null) {
+        merge(productionResources, resources);
+      } else {
+        productionResources = resources.copy();
+      }
+    } else {
+      if (this.resources != null) {
+        merge(this.resources, resources);
+      } else {
+        this.resources = resources.copy();
+      }
+    }
+  }
+
+  public void init() {
+    productionScripts = new String[productionResources.getScriptList().size()];
+    for (int i = 0; i< productionResources.getScriptList().size(); i++) {
+      productionScripts[i] = productionResources.getScriptList().get(i).getName();
+    }
+    productionStyles = new String[productionResources.getStyleList().size()];
+    for (int i = 0; i< productionResources.getStyleList().size(); i++) {
+      productionStyles[i] = productionResources.getStyleList().get(i).getName();
+    }
+
+    scripts = new String[resources.getScriptList().size()];
+    for (int i = 0; i< resources.getScriptList().size(); i++) {
+      scripts[i] = resources.getScriptList().get(i).getName();
+    }
+    styles = new String[resources.getStyleList().size()];
+    for (int i = 0; i< resources.getStyleList().size(); i++) {
+      styles[i] = resources.getStyleList().get(i).getName();
+    }
+
+  }
+
+  private void merge(TobagoResources resources, TobagoResources toAddResources) {
+    if (resources == toAddResources) {
+      return;
+    }
+    for (int i = toAddResources.getScriptList().size()-1; i >= 0; i--) {
+      TobagoScript script = toAddResources.getScriptList().get(i);
+      resources.getScriptList().remove(script);
+      resources.getScriptList().add(0, script);
+    }
+    for (int i = toAddResources.getStyleList().size()-1; i >= 0; i--) {
+      TobagoStyle style = toAddResources.getStyleList().get(i);
+      resources.getStyleList().remove(style);
+      resources.getStyleList().add(0, style);
+    }
+  }
+
+  public String[] getScriptResources(boolean production) {
+    if (production) {
+      return productionScripts;
+    }
+    return scripts;
+  }
+
+  public String[] getStyleResources(boolean production) {
+    if (production) {
+      return productionStyles;
+    }
+    return styles;
+  }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java Thu Nov 18 19:58:33 2010
@@ -61,6 +61,17 @@ class ThemeParser {
     digester.addObjectCreate("tobago-theme/renderers/renderer/supported-markup", MarkupConfig.class);
     digester.addSetNext("tobago-theme/renderers/renderer/supported-markup", "setMarkupConfig");
     digester.addCallMethod("tobago-theme/renderers/renderer/supported-markup/markup", "addMarkup", 0);
+    digester.addObjectCreate("tobago-theme/resources", TobagoResources.class);
+    digester.addSetProperties("tobago-theme/resources");
+    digester.addSetNext("tobago-theme/resources", "addResources");
+    digester.addObjectCreate("tobago-theme/resources/script", TobagoScript.class);
+    digester.addSetProperties("tobago-theme/resources/script");
+    digester.addSetNext("tobago-theme/resources/script", "addScript");
+    digester.addObjectCreate("tobago-theme/resources/style", TobagoStyle.class);
+    digester.addSetProperties("tobago-theme/resources/style");
+    digester.addSetNext("tobago-theme/resources/style", "addStyle");
+
+
   }
 
   public ThemeImpl parse(final URL url)

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java Thu Nov 18 19:58:33 2010
@@ -31,8 +31,6 @@ import java.util.Set;
 
 public class TobagoFacesContext extends FacesContextWrapper {
 
-  public static final String DEFAULT_STYLE = "style/style.css";
-
   private SetUniqueList scriptFiles;
 
   private Set<String> scriptBlocks;
@@ -64,7 +62,6 @@ public class TobagoFacesContext extends 
     scriptFiles = SetUniqueList.decorate(new ArrayList());
     scriptBlocks = new ListOrderedSet();
     styleFiles = new ListOrderedSet();
-    styleFiles.add(DEFAULT_STYLE);
     styleBlocks = new ListOrderedSet();
     onloadScripts = SetUniqueList.decorate(new ArrayList());
     onunloadScripts = new ListOrderedSet();

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResource.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResource.java?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResource.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResource.java Thu Nov 18 19:58:33 2010
@@ -0,0 +1,54 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * @since 1.5.0
+ */
+public class TobagoResource {
+  private String name;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (!(o instanceof TobagoResource)) {
+      return false;
+    }
+
+    TobagoResource that = (TobagoResource) o;
+
+    return !(name != null ? !name.equals(that.name) : that.name != null);
+
+  }
+
+  @Override
+  public int hashCode() {
+    return name != null ? name.hashCode() : 0;
+  }
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResources.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResources.java?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResources.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoResources.java Thu Nov 18 19:58:33 2010
@@ -0,0 +1,64 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @since 1.5.0
+ */
+public final class TobagoResources {
+
+  private boolean production;
+  private List<TobagoScript> scriptList = new ArrayList<TobagoScript>();
+  private List<TobagoStyle> styleList = new ArrayList<TobagoStyle>();
+
+  public TobagoResources copy() {
+    TobagoResources resources = new TobagoResources();
+    resources.setProduction(isProduction());
+    resources.scriptList.addAll(scriptList);
+    resources.styleList.addAll(styleList);
+    return resources;
+  }
+
+  public boolean isProduction() {
+    return production;
+  }
+
+  public void setProduction(boolean production) {
+    this.production = production;
+  }
+
+  public boolean addScript(TobagoScript script) {
+    return scriptList.add(script);
+  }
+
+  public boolean addStyle(TobagoStyle style) {
+    return styleList.add(style);
+  }
+
+  public List<TobagoScript> getScriptList() {
+    return scriptList;
+  }
+
+  public List<TobagoStyle> getStyleList() {
+    return styleList;
+  }
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoScript.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoScript.java?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoScript.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoScript.java Thu Nov 18 19:58:33 2010
@@ -0,0 +1,28 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * @since 1.5.0
+ */
+public final class TobagoScript extends TobagoResource {
+
+
+
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoStyle.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoStyle.java?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoStyle.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/TobagoStyle.java Thu Nov 18 19:58:33 2010
@@ -0,0 +1,26 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * @since 1.5.0
+ */
+public final class TobagoStyle extends TobagoResource {
+
+}

Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/context/ThemeParserTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/context/ThemeParserTest.java?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/context/ThemeParserTest.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/context/ThemeParserTest.java Thu Nov 18 19:58:33 2010
@@ -0,0 +1,124 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
+public class ThemeParserTest {
+
+  @Test
+  public void test() throws IOException, SAXException {
+    TobagoConfig config = new TobagoConfig();
+    ThemeBuilder themeBuilder = new ThemeBuilder(config);
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");
+
+    ThemeParser parser = new ThemeParser();
+    ThemeImpl theme = null;
+    if  (urls.hasMoreElements()) {
+      URL themeUrl = urls.nextElement();
+      theme = parser.parse(themeUrl);
+      Assert.assertEquals("test", theme.getName());
+      Assert.assertNotNull(theme.getResources());
+      Assert.assertNotNull(theme.getProductionResources());
+      TobagoResources resources = theme.getResources();
+      TobagoResources productionResources = theme.getProductionResources();
+
+      Assert.assertEquals(2, resources.getScriptList().size());
+      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
+      Assert.assertEquals("script/logging.js", resources.getScriptList().get(1).getName());
+
+      Assert.assertEquals(1, productionResources.getScriptList().size());
+      themeBuilder.addTheme(theme);
+    } else {
+      Assert.fail();
+    }
+
+    urls = classLoader.getResources("theme-config2.xml");
+
+    ThemeImpl theme2 = null;
+    if (urls.hasMoreElements()) {
+      URL themeUrl = urls.nextElement();
+      theme2 = parser.parse(themeUrl);
+      Assert.assertEquals("test2", theme2.getName());
+      Assert.assertNotNull(theme2.getResources());
+      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
+      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
+      themeBuilder.addTheme(theme2);
+    } else {
+      Assert.fail();
+    }
+
+    urls = classLoader.getResources("theme-config3.xml");
+
+    ThemeImpl theme3 = null;
+    if (urls.hasMoreElements()) {
+      URL themeUrl = urls.nextElement();
+      theme3 = parser.parse(themeUrl);
+      Assert.assertEquals("test3", theme3.getName());
+      Assert.assertNull(theme3.getResources());
+      themeBuilder.addTheme(theme3);
+    } else {
+      Assert.fail();
+    }
+
+    urls = classLoader.getResources("theme-config4.xml");
+
+    ThemeImpl theme4 = null;
+    if (urls.hasMoreElements()) {
+      URL themeUrl = urls.nextElement();
+      theme4 = parser.parse(themeUrl);
+      Assert.assertEquals("test4", theme4.getName());
+      Assert.assertNull(theme4.getResources());
+      themeBuilder.addTheme(theme4);
+    } else {
+      Assert.fail();
+    }
+
+    themeBuilder.resolveThemes();
+    Assert.assertEquals(2, theme.getResources().getScriptList().size());
+    Assert.assertEquals("script/tobago.js", theme.getResources().getScriptList().get(0).getName());
+    Assert.assertEquals("script/logging.js", theme.getResources().getScriptList().get(1).getName());
+
+    Assert.assertNotNull(theme2.getResources());
+    Assert.assertEquals(3, theme2.getResources().getScriptList().size());
+    Assert.assertEquals(1, theme2.getResources().getStyleList().size());
+    Assert.assertEquals("script/tobago.js", theme2.getResources().getScriptList().get(0).getName());
+    Assert.assertEquals("script/logging.js", theme2.getResources().getScriptList().get(1).getName());
+    Assert.assertEquals("script/test.js", theme2.getResources().getScriptList().get(2).getName());
+
+    Assert.assertEquals(3, theme3.getResources().getScriptList().size());
+    Assert.assertEquals("script/tobago.js", theme3.getResources().getScriptList().get(0).getName());
+    Assert.assertEquals("script/logging.js", theme3.getResources().getScriptList().get(1).getName());
+    Assert.assertEquals("script/test.js", theme3.getResources().getScriptList().get(2).getName());
+
+    Assert.assertEquals(3, theme4.getResources().getScriptList().size());
+    Assert.assertEquals("script/tobago.js", theme4.getResources().getScriptList().get(0).getName());
+    Assert.assertEquals("script/logging.js", theme4.getResources().getScriptList().get(1).getName());
+    Assert.assertEquals("script/test.js", theme4.getResources().getScriptList().get(2).getName());
+
+
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java Thu Nov 18 19:58:33 2010
@@ -57,4 +57,12 @@ public class MockTheme implements Theme 
   public RenderersConfig getRenderersConfig() {
     return config;
   }
+
+  public String[] getScriptResources(boolean production) {
+    return new String[0];
+  }
+
+  public String[] getStyleResources(boolean production) {
+    return new String[0];
+  }
 }

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml Thu Nov 18 19:58:33 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<tobago-theme>
+  <name>test</name>
+  <display-name>Test</display-name>
+  <deprecated-name>Test</deprecated-name>
+  <resource-path>Test</resource-path>
+  <resources production="true">
+    <script name="script/tobago.min.js"/>
+    <style name="style.css"/>
+  </resources>
+  <resources production="false">
+    <script name="script/tobago.js"/>
+    <script name="script/logging.js"/>
+    <style name="style.css"/>
+  </resources>
+</tobago-theme>
\ No newline at end of file

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml Thu Nov 18 19:58:33 2010
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<tobago-theme>
+  <name>test2</name>
+  <display-name>Test2</display-name>
+  <deprecated-name>Test2</deprecated-name>
+  <resource-path>Test2</resource-path>
+  <fallback>test</fallback>
+  <resources production="false">
+    <script name="script/test.js"/>
+    <style name="style.css"/>
+  </resources>
+</tobago-theme>
\ No newline at end of file

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml Thu Nov 18 19:58:33 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<tobago-theme>
+  <name>test3</name>
+  <display-name>Test3</display-name>
+  <deprecated-name>Test3</deprecated-name>
+  <resource-path>Test3</resource-path>
+  <fallback>test2</fallback>
+</tobago-theme>
\ No newline at end of file

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml?rev=1036594&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml Thu Nov 18 19:58:33 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<tobago-theme>
+  <name>test4</name>
+  <display-name>Test4</display-name>
+  <deprecated-name>Test4</deprecated-name>
+  <resource-path>Test4</resource-path>
+  <fallback>test3</fallback>
+</tobago-theme>
\ No newline at end of file

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/pom.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/pom.xml Thu Nov 18 19:58:33 2010
@@ -24,7 +24,28 @@
   </parent>
   <artifactId>tobago-theme-charlotteville</artifactId>
   <name>Tobago Theme Charlotteville</name>
-
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compress</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <suffix>.min</suffix>
+          <excludes>
+            <exclude>**/*.js</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
   <dependencies>
     <dependency>
       <groupId>org.apache.myfaces.tobago</groupId>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/pom.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/pom.xml Thu Nov 18 19:58:33 2010
@@ -25,6 +25,28 @@
   <artifactId>tobago-theme-richmond</artifactId>
   <packaging>jar</packaging>
   <name>Tobago Theme Richmond</name>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compress</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <suffix>.min</suffix>
+          <excludes>
+            <exclude>**/*.js</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
   <dependencies>
     <dependency>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml Thu Nov 18 19:58:33 2010
@@ -73,6 +73,24 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compress</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <suffix>.min</suffix>
+          <excludes>
+            <exclude>**/*.js</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Thu Nov 18 19:58:33 2010
@@ -30,6 +30,7 @@ import org.apache.myfaces.tobago.config.
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.context.Theme;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
@@ -135,8 +136,6 @@ public class PageRenderer extends PageRe
       facesContext = new TobagoFacesContext(facesContextOrg);
     }
 
-    boolean developmentMode = TobagoConfig.getInstance(facesContext).getProjectStage() == ProjectStage.Development;
-
     LayoutContext layoutContext = new LayoutContext(page);
     layoutContext.layout();
 
@@ -165,7 +164,10 @@ public class PageRenderer extends PageRe
     ResponseUtils.ensureContentTypeHeader(facesContext, contentType);
     String clientId = page.getClientId(facesContext);
     final ClientProperties client = VariableResolverUtils.resolveClientProperties(facesContext);
+    final ProjectStage projectStage = TobagoConfig.getInstance(facesContext).getProjectStage();
+    final boolean developmentMode =  projectStage == ProjectStage.Development;
     final boolean debugMode = client.isDebugMode() || developmentMode;
+    final boolean productionMode = !debugMode && projectStage == ProjectStage.Production;
     boolean calculateScrollbarWeight = false;
     int clientLogSeverity = 2;
     if (debugMode) {
@@ -204,20 +206,15 @@ public class PageRenderer extends PageRe
       writer.startElement(HtmlElements.TITLE, null);
       writer.writeText(title != null ? title : "");
       writer.endElement(HtmlElements.TITLE);
+      final Theme theme = client.getTheme();
 
       // style files
+      for (String styleFile : theme.getStyleResources(productionMode)) {
+        writeStyle(facesContext, writer, styleFile);
+      }
+
       for (String styleFile : facesContext.getStyleFiles()) {
-        List<String> styles = ResourceManagerUtils.getStyles(facesContext, styleFile);
-        for (String styleString : styles) {
-          if (styleString.length() > 0) {
-            writer.startElement(HtmlElements.LINK, null);
-            writer.writeAttribute(HtmlAttributes.REL, "stylesheet", false);
-            writer.writeAttribute(HtmlAttributes.HREF, styleString, false);
-  //          writer.writeAttribute(HtmlAttributes.MEDIA, "screen", false);
-            writer.writeAttribute(HtmlAttributes.TYPE, "text/css", false);
-            writer.endElement(HtmlElements.LINK);
-          }
-        }
+        writeStyle(facesContext, writer, styleFile);
       }
 
       String icon = page.getApplicationIcon();
@@ -253,24 +250,6 @@ public class PageRenderer extends PageRe
         writer.endElement(HtmlElements.STYLE);
       }
 
-      // script files
-      List<String> scriptFiles = facesContext.getScriptFiles();
-      // jquery.js and tobago.js needs to be first!
-
-      int pos = 0;
-      scriptFiles.add(pos++, debugMode ? "script/jquery/1_4_2/jquery.js" : "script/jquery/1_4_2/jquery.min.js");
-      scriptFiles.add(pos++, debugMode ? "script/tobago.js": "script/tobago.min.js");
-      if (debugMode) {
-        scriptFiles.add(pos++, "script/tobago-menu.js");
-        scriptFiles.add(pos++, "script/theme-config.js");
-        scriptFiles.add(pos++, "script/tobago-tabgroup.js");
-        scriptFiles.add(pos++, "script/tobago-tree.js");
-        scriptFiles.add(pos++, "script/tobago-sheet.js");
-        scriptFiles.add(pos++, "script/calendar.js");
-        scriptFiles.add(pos++, "script/dateConverter.js");
-      }
-
-
       if (debugMode) {
         boolean hideClientLogging = true;
         String severity = (String) facesContext.getExternalContext().getRequestMap().get(CLIENT_DEBUG_SEVERITY);
@@ -286,15 +265,16 @@ public class PageRenderer extends PageRe
           hideClientLogging = !severity.contains("show");
         }
         // the jquery ui is used in moment only for the logging area...
-        scriptFiles.add("script/jquery-ui/1_7_2/ui.core.min.js");
-        scriptFiles.add("script/jquery-ui/1_7_2/ui.draggable.min.js");
-        scriptFiles.add("script/logging.js");
         facesContext.getOnloadScripts().add(0, "new LOG.LogArea({hide: " + hideClientLogging + "});");
       }
 
       // render remaining script tags
-      for (String scriptFile : scriptFiles) {
-        encodeScripts(writer, facesContext, scriptFile);
+      for (String scriptFile: theme.getScriptResources(productionMode)) {
+        encodeScript(facesContext, writer, scriptFile);
+      }
+
+      for (String scriptFile : facesContext.getScriptFiles()) {
+        encodeScript(facesContext, writer, scriptFile);
       }
 
       // focus id
@@ -513,6 +493,21 @@ public class PageRenderer extends PageRe
     writer.writeStyleAttribute(style);
   }
 
+  private void writeStyle(TobagoFacesContext facesContext, TobagoResponseWriter writer, String styleFile)
+      throws IOException {
+    List<String> styles = ResourceManagerUtils.getStyles(facesContext, styleFile);
+    for (String styleString : styles) {
+      if (styleString.length() > 0) {
+        writer.startElement(HtmlElements.LINK, null);
+        writer.writeAttribute(HtmlAttributes.REL, "stylesheet", false);
+        writer.writeAttribute(HtmlAttributes.HREF, styleString, false);
+//          writer.writeAttribute(HtmlAttributes.MEDIA, "screen", false);
+        writer.writeAttribute(HtmlAttributes.TYPE, "text/css", false);
+        writer.endElement(HtmlElements.LINK);
+      }
+    }
+  }
+
 //  @Override
 //  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
 //    UIPage page = (UIPage) component;
@@ -683,7 +678,7 @@ public class PageRenderer extends PageRe
     }
   }
 
-  private void encodeScripts(TobagoResponseWriter writer, FacesContext facesContext, String script) throws IOException {
+  private void encodeScript(FacesContext facesContext, TobagoResponseWriter writer, String script) throws IOException {
     List<String> list;
     if (StringUtils.startsWith(script, "/") 
         || StringUtils.startsWithIgnoreCase(script, "HTTP:")

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java Thu Nov 18 19:58:33 2010
@@ -19,7 +19,6 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.component.UITreeNode;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.component.AbstractUITree;
 import org.apache.myfaces.tobago.internal.context.ResponseWriterDivider;
 import org.apache.myfaces.tobago.layout.Measure;
@@ -41,17 +40,11 @@ import java.util.List;
 
 public class TreeListboxRenderer extends LayoutComponentRendererBase {
 
-  private static final String SCRIPT = "script/tobago-tree.js";
-  
+
   public static final String DIVIDER = TreeListboxRenderer.class.getName() + "DIVIDER";
 
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
     super.prepareRender(facesContext, component);
-    if (facesContext instanceof TobagoFacesContext) {
-      // todo: this may be removed, it is twice on the page 1. in the header 2. in the ScriptLoader
-      ((TobagoFacesContext) facesContext).getScriptFiles().add(SCRIPT);
-    }
-
     setRendererTypeForCommandsAndNodes(component);
   }
 
@@ -117,8 +110,6 @@ public class TreeListboxRenderer extends
       writer.endElement(HtmlElements.INPUT);
     }
 
-    HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPT);
-
     RenderUtils.encode(facesContext, root);
 
     writer.startElement(HtmlElements.DIV, tree);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Thu Nov 18 19:58:33 2010
@@ -20,6 +20,25 @@
  * agent: standard
  */
 
+/* Global settings ------------------------------------------------------------------ */
+
+form {
+  margin: 0;
+}
+
+/*
+  This is to make the menu bar to be always at the top of the page.
+  The "position: fixed;" doesn't work with ie6 and makes
+  on other browsers problems, when clicking the menu (the scroll panel scrolls then).
+*/
+html, body {
+  height: 100%;
+  width: 100%;
+  padding: 0;
+  margin: 0;
+  overflow: hidden;
+}
+
 /* box ---------------------------------------------------------------- */
 
 fieldset.tobago-box {
@@ -307,6 +326,11 @@ div.tobago-gridLayout-first-column {
   -moz-box-sizing: border-box;
 }
 
+.tobago-in-suggestPopup a {
+  text-decoration: none;
+  color: black;
+}
+
 .tobago-in-suggestPopup li {
   white-space: nowrap;
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/pom.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/pom.xml Thu Nov 18 19:58:33 2010
@@ -176,6 +176,24 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compress</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <suffix>.min</suffix>
+          <excludes>
+            <exclude>**/*.js</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml Thu Nov 18 19:58:33 2010
@@ -77,6 +77,32 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>yuicompressor-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compress</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <suffix>.min</suffix>
+          <excludes>
+            <exclude>**/*.js</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <!--<plugin>
+        <groupId>ro.isdc.wro4j</groupId>
+        <artifactId>wro4j-maven-plugin</artifactId>
+        <version>1.3.1</version>
+        <configuration>
+
+        </configuration>
+      </plugin>-->
     </plugins>
   </build>
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml?rev=1036594&r1=1036593&r2=1036594&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml Thu Nov 18 19:58:33 2010
@@ -271,7 +271,7 @@
     <renderer>
       <name>TreeNode</name>
       <supported-markup>
-        <markup>strong</markup> <!--XXX has to be in lable and command ? -->
+        <markup>strong</markup> <!--XXX has to be in label and command ? -->
         <markup>marked</markup>
         <markup>folder</markup>
       </supported-markup>
@@ -279,10 +279,30 @@
     <renderer>
       <name>TreeMenuNode</name>
       <supported-markup>
-        <markup>strong</markup> <!--XXX has to be in lable and command ? -->
+        <markup>strong</markup> <!--XXX has to be in label and command ? -->
         <markup>marked</markup>
         <markup>folder</markup>
       </supported-markup>
     </renderer>
   </renderers>
+  <resources production="true">
+    <script name="script/jquery/1_4_2/jquery.min.js"/>
+    <script name="script/tobago.min.js"/>
+    <style name="style/style.min.css"/>
+  </resources>
+  <resources production="false">
+    <script name="script/jquery/1_4_2/jquery.js"/>
+    <script name="script/tobago.js"/>
+    <script name="script/calendar.js"/>
+    <script name="script/dateConverter.js"/>
+    <script name="script/theme-config.js"/>
+    <script name="script/tobago-menu.js"/>
+    <script name="script/tobago-sheet.js"/>
+    <script name="script/tobago-tabgroup.js"/>
+    <script name="script/tobago-tree.js"/>
+    <script name="script/jquery-ui/1_7_2/ui.core.min.js"/>
+    <script name="script/jquery-ui/1_7_2/ui.draggable.min.js"/>
+    <script name="script/logging.js"/>
+    <style name="style/style.css"/>
+  </resources>
 </tobago-theme>