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 2006/09/25 18:57:15 UTC

svn commit: r449737 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/context/ core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ theme/standard/src/main/resources/META-INF/

Author: bommel
Date: Mon Sep 25 09:57:14 2006
New Revision: 449737

URL: http://svn.apache.org/viewvc?view=rev&rev=449737
Log:
[TOBAGO-119] support customizing of markup

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererConfig.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfig.java
      - copied, changed from r449516, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfigImpl.java
      - copied, changed from r449520, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfigImpl.java
Removed:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfigImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererMarkup.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/Theme.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/META-INF/tobago-theme.xml

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java?view=auto&rev=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java Mon Sep 25 09:57:14 2006
@@ -0,0 +1,45 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Copyright 2002-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.Set;
+import java.util.HashSet;
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Sep 24, 2006
+ * Time: 10:09:35 PM
+ */
+public class MarkupConfig {
+
+  private Set<String> markups = new HashSet<String>();
+
+  public boolean contains(String markup) {
+    return markups.contains(markup);
+  }
+
+  public void addMarkup(String markup) {
+    this.markups.add(markup);
+  }
+
+  public String toString() {
+    return "MarkupConfig: " + markups;
+  }
+
+}

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererConfig.java?view=auto&rev=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererConfig.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RendererConfig.java Mon Sep 25 09:57:14 2006
@@ -0,0 +1,71 @@
+package org.apache.myfaces.tobago.context;
+
+/*
+ * Copyright 2002-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Sep 25, 2006
+ * Time: 10:54:19 AM
+ */
+public class RendererConfig {
+  private String name;
+  private MarkupConfig markupConfig;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name.substring(0, 1).toLowerCase() + name.substring(1);
+  }
+
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    final RendererConfig that = (RendererConfig) o;
+
+    return name.equals(that.name);
+
+  }
+
+  public boolean contains(String markup) {
+    return markupConfig.contains(markup);
+  }
+
+  public int hashCode() {
+    return name.hashCode();
+  }
+
+  public MarkupConfig getMarkupConfig() {
+    return markupConfig;
+  }
+
+  public void setMarkupConfig(MarkupConfig markupConfig) {
+    this.markupConfig = markupConfig;
+  }
+
+  public String toString() {
+    return "RendererConfig: " + getName() + " " + markupConfig;
+  }
+
+}

Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfig.java (from r449516, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfig.java?view=diff&rev=449737&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java&r1=449516&p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfig.java&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfig.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfig.java Mon Sep 25 09:57:14 2006
@@ -24,7 +24,7 @@
  * Date: Sep 24, 2006
  * Time: 12:32:35 PM
  */
-public interface MarkupConfig {
+public interface RenderersConfig {
 
   boolean isMarkupSupported(String rendererName, String markup);
 

Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfigImpl.java (from r449520, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfigImpl.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfigImpl.java?view=diff&rev=449737&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfigImpl.java&r1=449520&p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfigImpl.java&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/MarkupConfigImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/RenderersConfigImpl.java Mon Sep 25 09:57:14 2006
@@ -28,11 +28,11 @@
  * Date: Sep 24, 2006
  * Time: 3:46:11 PM
  */
-public class MarkupConfigImpl implements MarkupConfig {
+public class RenderersConfigImpl implements RenderersConfig {
 
-  private static final Log LOG = LogFactory.getLog(MarkupConfigImpl.class);
+  private static final Log LOG = LogFactory.getLog(RenderersConfigImpl.class);
 
-  private Map<String,RendererMarkup> renderer = new HashMap<String,RendererMarkup>();
+  private Map<String,RendererConfig> renderer = new HashMap<String,RendererConfig>();
 
   private boolean merged = false;
 
@@ -44,13 +44,13 @@
     this.merged = merged;
   }
 
-  Collection<RendererMarkup>  getRendererMarkups() {
+  Collection<RendererConfig>  getRendererConfigs() {
     return renderer.values();
   }
 
-  public void addRenderer(RendererMarkup rendererMarkup) {
-    if (!renderer.containsKey(rendererMarkup.getName())) {
-      renderer.put(rendererMarkup.getName(), rendererMarkup);
+  public void addRenderer(RendererConfig rendererConfig) {
+    if (!renderer.containsKey(rendererConfig.getName())) {
+      renderer.put(rendererConfig.getName(), rendererConfig);
     }
   }
 
@@ -58,19 +58,19 @@
     if (LOG.isDebugEnabled()) {
       LOG.debug("calling isMarkupSupported" + rendererName + " " +markup);
     }
-    RendererMarkup rendererMarkup = renderer.get(rendererName);
-    if (rendererMarkup != null) {
-      return rendererMarkup.contains(markup);
+    RendererConfig rendererConfig = renderer.get(rendererName);
+    if (rendererConfig != null) {
+      return rendererConfig.contains(markup);
     } else {
       LOG.error("Calling isMarkupSupported" + rendererName + " " +markup + "but no configuration found.");
       return false;
     }
   }
 
-  void merge(MarkupConfigImpl markupConfig) {
-    Collection<RendererMarkup> markups = markupConfig.getRendererMarkups();
-    for (RendererMarkup markup: markups) {
-      addRenderer(markup);
+  void merge(RenderersConfigImpl renderersConfig) {
+    Collection<RendererConfig> renderers = renderersConfig.getRendererConfigs();
+    for (RendererConfig rendererConfig : renderers) {
+      addRenderer(rendererConfig);
     }
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/Theme.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/Theme.java?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/Theme.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/Theme.java Mon Sep 25 09:57:14 2006
@@ -31,5 +31,5 @@
 
   String getResourcePath();
 
-  MarkupConfig getMarkupConfig();
+  RenderersConfig getRenderersConfig();
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeBuilder.java Mon Sep 25 09:57:14 2006
@@ -50,7 +50,7 @@
       theme.resolveFallbacks();
     }
     for (ThemeImpl theme : availableThemes) {
-      theme.resolveMarkupConfig();
+      theme.resolveRendererConfig();
     }
     Map<String, Theme> result = new HashMap<String, Theme>();
     for (ThemeImpl theme : availableThemes) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java Mon Sep 25 09:57:14 2006
@@ -42,7 +42,7 @@
 
   private List<Theme> fallbackList;
 
-  private MarkupConfigImpl markupConfig;
+  private RenderersConfigImpl renderersConfig;
 
   public String getName() {
     return name;
@@ -107,25 +107,25 @@
     }
   }
 
-  public void resolveMarkupConfig() {
-    if (markupConfig == null) {
-      markupConfig = new MarkupConfigImpl();
+  public void resolveRendererConfig() {
+    if (renderersConfig == null) {
+      renderersConfig = new RenderersConfigImpl();
     }
-    if (!markupConfig.isMerged()) {
+    if (!renderersConfig.isMerged()) {
       ThemeImpl fallback  = getFallback();
       if (fallback != null) {
-        fallback.resolveMarkupConfig();
-        MarkupConfigImpl fallbackMarkupConfig = fallback.getMarkupConfigImpl();
-        if (fallbackMarkupConfig != null) {
-          markupConfig.merge(fallbackMarkupConfig);
+        fallback.resolveRendererConfig();
+        RenderersConfigImpl fallbackRenderersConfig = fallback.getRenderersConfigImpl();
+        if (fallbackRenderersConfig != null) {
+          renderersConfig.merge(fallbackRenderersConfig);
           if (LOG.isDebugEnabled()) {
             LOG.debug("merge markupconfig from " + fallback.getName() + " for " + getName());
           }
         }
       }
-      markupConfig.setMerged(true);
+      renderersConfig.setMerged(true);
       if (LOG.isDebugEnabled()) {
-        LOG.debug(getName() + " " +markupConfig);
+        LOG.debug(getName() + " " +renderersConfig);
       }
     }
   }
@@ -135,15 +135,15 @@
     return name;
   }
 
-  public void setMarkupConfig(MarkupConfigImpl markupConfig) {
-    this.markupConfig = markupConfig;
+  public void setRenderersConfig(RenderersConfigImpl renderersConfig) {
+    this.renderersConfig = renderersConfig;
   }
 
-  public MarkupConfig getMarkupConfig() {
-    return markupConfig;
+  public RenderersConfig getRenderersConfig() {
+    return renderersConfig;
   }
 
-  MarkupConfigImpl getMarkupConfigImpl() {
-    return markupConfig;
+  RenderersConfigImpl getRenderersConfigImpl() {
+    return renderersConfig;
   }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ThemeParser.java Mon Sep 25 09:57:14 2006
@@ -53,12 +53,14 @@
     digester.addCallMethod("tobago-theme/deprecated-name", "setDeprecatedName", 0);
     digester.addCallMethod("tobago-theme/resource-path", "setResourcePath", 0);
     digester.addCallMethod("tobago-theme/fallback", "setFallbackName", 0);
-    digester.addObjectCreate("tobago-theme/supported-markup", MarkupConfigImpl.class);
-    digester.addSetNext("tobago-theme/supported-markup", "setMarkupConfig");
-    digester.addObjectCreate("tobago-theme/supported-markup/renderer",  RendererMarkup.class);
-    digester.addSetNext("tobago-theme/supported-markup/renderer", "addRenderer");
-    digester.addCallMethod("tobago-theme/supported-markup/renderer/name", "setName", 0);
-    digester.addCallMethod("tobago-theme/supported-markup/renderer/markup", "addMarkup" , 0);
+    digester.addObjectCreate("tobago-theme/renderers", RenderersConfigImpl.class);
+    digester.addSetNext("tobago-theme/renderers", "setRenderersConfig");
+    digester.addObjectCreate("tobago-theme/renderers/renderer",  RendererConfig.class);
+    digester.addSetNext("tobago-theme/renderers/renderer", "addRenderer");
+    digester.addCallMethod("tobago-theme/renderers/renderer/name", "setName", 0);
+    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);
 
     return digester;
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Mon Sep 25 09:57:14 2006
@@ -435,7 +435,7 @@
       String markup = ComponentUtil.getStringAttribute(component, ATTR_MARKUP);
       if (StringUtils.isNotEmpty(markup)) {
         Theme theme = ClientProperties.getInstance(FacesContext.getCurrentInstance().getViewRoot()).getTheme();
-        if (theme.getMarkupConfig().isMarkupSupported(rendererName, markup)) {
+        if (theme.getRenderersConfig().isMarkupSupported(rendererName, markup)) {
           tobagoClass.append(prefix).append("-markup-").append(markup).append(" ");
         } else {
           LOG.warn("Unknown markup='" + markup + "'");

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/META-INF/tobago-theme.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/META-INF/tobago-theme.xml?view=diff&rev=449737&r1=449736&r2=449737
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/META-INF/tobago-theme.xml (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/META-INF/tobago-theme.xml Mon Sep 25 09:57:14 2006
@@ -16,19 +16,17 @@
  *    limitations under the License.
 -->
 
-<!--
-  todo: Test still under development
-  http://issues.apache.org/jira/browse/TOBAGO-20
--->
 <tobago-theme>
   <name>standard</name>
   <deprecated-name>org.apache.myfaces.tobago.context.StandardTheme</deprecated-name>
   <resource-path>org/apache/myfaces/tobago/renderkit</resource-path>
-  <supported-markup>
+  <renderers>
     <renderer>
-      <name>out</name>
-      <markup>strong</markup>
-      <markup>deleted</markup>
+      <name>Out</name>
+      <supported-markup>
+        <markup>strong</markup>
+        <markup>deleted</markup>
+      </supported-markup>
     </renderer>
-  </supported-markup>
+  </renderers>
 </tobago-theme>