You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2009/07/11 22:53:36 UTC

svn commit: r793216 - in /myfaces/trinidad-maven/branches/1.2.10.1-branch: ./ maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/reso...

Author: arobinson74
Date: Sat Jul 11 20:53:36 2009
New Revision: 793216

URL: http://svn.apache.org/viewvc?rev=793216&view=rev
Log:
TRINIDAD-1529
applied patch

Added:
    myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ScreenshotBean.java
      - copied unchanged from r793068, myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ScreenshotBean.java
Modified:
    myfaces/trinidad-maven/branches/1.2.10.1-branch/   (props changed)
    myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
    myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
    myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
    myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java

Propchange: myfaces/trinidad-maven/branches/1.2.10.1-branch/
------------------------------------------------------------------------------
    svn:mergeinfo = /myfaces/trinidad-maven/trunk:793066,793068

Modified: myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java?rev=793216&r1=793215&r2=793216&view=diff
==============================================================================
--- myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java (original)
+++ myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java Sat Jul 11 20:53:36 2009
@@ -33,7 +33,9 @@
   private int     _tagClassModifiers;
   private Map     _examples;
   private int     _exampleIdx = 0;
-
+  private Map     _screenshots;
+  private int     _screenshotIdx = 0;
+  
   public AbstractTagBean() 
   {
     this(false);
@@ -50,6 +52,7 @@
       _properties = new LinkedHashMap();
     }
     _examples   = new LinkedHashMap();      
+    _screenshots = new LinkedHashMap();   
   }
 
   /**
@@ -225,6 +228,51 @@
     return _examples.values().iterator();
   }
 
+  /**
+   * Adds a Screenshot to this component.
+   *
+   * @param screenshot  the screenshot to add
+   */
+  public void addScreenshot(
+    ScreenshotBean screenshot)
+  {
+    String key = _generateScreenshotKey();
+    screenshot.setKey(key);
+    _screenshots.put(key, screenshot);
+  }
+
+  /**
+   * Returns true if this component has any screenshots.
+   *
+   * @return  true   if this component has any screenshots,
+   *          false  otherwise
+   */
+  public boolean hasScreenshots()
+  {
+    return !_screenshots.isEmpty();
+  }
+
+  /**
+   * Returns the screenshot for this screenshot key.
+   *
+   * @param key  the hashmap screenshot key
+   */
+  public ScreenshotBean findScreenshot(
+    String key)
+  {
+    return (ScreenshotBean)_screenshots.get(key);
+  }
+
+  /**
+  * Returns an iterator for all screenshots on this component only.
+  *
+  * @return  the screenshot iterator
+  */
+  public Iterator screenshots()
+  {
+    return _screenshots.values().iterator();
+  }
+
   public void parseTagClassModifier(
     String modifier)
   {
@@ -297,4 +345,14 @@
     _exampleIdx++;
     return key;
   }
+  
+  /* Get a generated key to use in storing
+   * this screen shot bean in its hashmap.
+   */
+  private String _generateScreenshotKey()
+  {
+    String key = "Screenshot" + Integer.toString(_screenshotIdx);
+    _screenshotIdx++;
+    return key;
+  }  
 }

Modified: myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java?rev=793216&r1=793215&r2=793216&view=diff
==============================================================================
--- myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java (original)
+++ myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java Sat Jul 11 20:53:36 2009
@@ -188,6 +188,16 @@
     digester.addSetNext("faces-config/component/component-extension/example",
                         "addExample", ExampleBean.class.getName());
 
+    // faces-config/component/component-extension/screenshot
+    digester.addObjectCreate("faces-config/component/component-extension/screenshot",
+                             ScreenshotBean.class);
+    digester.addBeanPropertySetter("faces-config/component/component-extension/screenshot/description",
+                                   "description");
+    digester.addBeanPropertySetter("faces-config/component/component-extension/screenshot/image",
+                                   "image");
+    digester.addSetNext("faces-config/component/component-extension/screenshot",
+                        "addScreenshot", ScreenshotBean.class.getName());
+
     // faces-config/component/component-extension/event
     digester.addObjectCreate("faces-config/component/component-extension/event", EventRefBean.class);
     digester.addBeanPropertySetter("faces-config/component/component-extension/event/event-type",

Modified: myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl?rev=793216&r1=793215&r2=793216&view=diff
==============================================================================
--- myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl (original)
+++ myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl Sat Jul 11 20:53:36 2009
@@ -1055,6 +1055,7 @@
   <xsl:template match="//mfp:jsp-property-name" />
   <xsl:template match="//mfp:long-description" />
   <xsl:template match="//mfp:method-binding-signature" />
+  <xsl:template match="//mfp:screenshot" />
   <xsl:template match="//mfp:short-description" />
   <xsl:template match="//mfp:state-holder" />
   <xsl:template match="//mfp:tag-attribute-excluded" />

Modified: myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java?rev=793216&r1=793215&r2=793216&view=diff
==============================================================================
--- myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java (original)
+++ myfaces/trinidad-maven/branches/1.2.10.1-branch/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java Sat Jul 11 20:53:36 2009
@@ -62,6 +62,7 @@
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigParser;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacetBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ScreenshotBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.ComponentFilter;
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.ConverterFilter;
@@ -401,11 +402,12 @@
       out.write(" <p>\n");
       _writeComponentSummary(out, component);
       out.write(" </p>\n");
-      out.write(" <p>\n");
-      _writeExamples(out, component);
-      out.write(" </p>\n");
       out.write(" </section>\n");
-      
+
+      _writeScreenshots(out, component);
+
+      _writeExamples(out, component);
+
       if (component.hasEvents(true))
       {
         out.write(" <section name=\"Events\">\n");
@@ -469,11 +471,12 @@
       out.write(" <p>\n");
       _writeConverterSummary(out, converter);
       out.write(" </p>\n");
-      out.write(" <p>\n");
-      _writeExamples(out, converter);
-      out.write(" </p>\n");
       out.write(" </section>\n");
-            
+
+      _writeScreenshots(out, converter);
+
+      _writeExamples(out, converter);
+
       out.write(" <section name=\"Attributes\">\n");
       _writeConverterAttributes(out, converter);
       out.write(" </section>\n");
@@ -519,11 +522,12 @@
       out.write(" <p>\n");
       _writeValidatorSummary(out, validator);
       out.write(" </p>\n");
-      out.write(" <p>\n");
-      _writeExamples(out, validator);
-      out.write(" </p>\n");
       out.write(" </section>\n");
-            
+
+      _writeScreenshots(out, validator);
+
+      _writeExamples(out, validator);
+
       out.write(" <section name=\"Attributes\">\n");
       _writeValidatorAttributes(out, validator);
       out.write(" </section>\n");
@@ -1062,8 +1066,8 @@
     ExampleBean exBean = null;
 
     // Write header
-    out.write("   <b>Example(s):</b> ");
-    out.write("   <br/>\n");
+    out.write(" <section name=\"Code Example(s)\">\n");
+    out.write(" <p>\n");    
     out.write("   <html>\n");
     
     // Go through each example, write its description
@@ -1097,6 +1101,64 @@
       }
     }
     out.write("   </html>\n");
+    out.write(" </p>\n");
+    out.write(" </section>\n");    
+  }
+
+  private void _writeScreenshots(Writer out, AbstractTagBean bean) throws IOException
+  {
+    if (!bean.hasScreenshots())
+      return;
+    
+    ScreenshotBean ssBean = null;
+
+    // Write header
+    out.write(" <section name=\"Screenshot(s)\">\n");
+    out.write(" <p>\n");
+    out.write("   <html>\n");
+
+    // Go through each screenshot, write its image
+    // followed by the image's caption.
+    Iterator iter = bean.screenshots();
+    while (iter.hasNext())
+    {
+      ssBean = (ScreenshotBean) iter.next();
+      String desc   = ssBean.getDescription();
+      String img = ssBean.getImage();
+
+      out.write("    <div class=\'screenshot\'>\n");
+
+      if (img != null)
+      {
+        if (!"".equals(img))
+        {
+          out.write(img);
+        }
+      }
+
+      if (desc != null)
+      {
+        desc = desc.replaceAll("<", "&lt;");
+        desc = desc.replaceAll(">", "&gt;");
+
+        if (!"".equals(desc))
+        {
+          out.write("<br/>");
+          out.write(desc + "\n");
+        }
+      }      
+      out.write("    </div>\n");    
+
+      // create extra space between each screenshot to ensure it is clear which description 
+      // text belongs to which image
+      if (iter.hasNext())
+      {
+        out.write("<br/>");
+      }
+    }
+    out.write("   </html>\n");
+    out.write(" </p>\n");
+    out.write(" </section>\n");
   }
 
   protected MavenProject getProject()