You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 18:05:51 UTC

[myfaces-trinidad-maven] 14/17: TRINIDAD-1529 applied patch

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1.2.10.1-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad-maven.git

commit 7f1f415efe59b9227932432e918acbb8be8f1964
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Sat Jul 11 20:53:36 2009 +0000

    TRINIDAD-1529
    applied patch
---
 .../plugin/faces/parse/AbstractTagBean.java        |  60 +++++++++++-
 .../plugin/faces/parse/FacesConfigParser.java      |  10 ++
 .../plugin/faces/parse/ScreenshotBean.java         | 104 +++++++++++++++++++++
 .../plugin/faces/resources/transform12.xsl         |   1 +
 .../trinidadbuild/plugin/tagdoc/TagdocReport.java  |  90 +++++++++++++++---
 5 files changed, 250 insertions(+), 15 deletions(-)

diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
index d9cecdc..6ab3454 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
@@ -33,7 +33,9 @@ public class AbstractTagBean extends ObjectBean {
   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 @@ public class AbstractTagBean extends ObjectBean {
       _properties = new LinkedHashMap();
     }
     _examples   = new LinkedHashMap();      
+    _screenshots = new LinkedHashMap();   
   }
 
   /**
@@ -225,6 +228,51 @@ public class AbstractTagBean extends ObjectBean {
     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 @@ public class AbstractTagBean extends ObjectBean {
     _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;
+  }  
 }
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
index dae2548..55f0a2d 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
@@ -188,6 +188,16 @@ public class FacesConfigParser
     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",
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ScreenshotBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ScreenshotBean.java
new file mode 100644
index 0000000..8b0a0d7
--- /dev/null
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ScreenshotBean.java
@@ -0,0 +1,104 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.faces.parse;
+
+/**
+ * ScreenshotBean is a Java representation of the faces-config mfp:screenshot
+ * XML element.
+ * An example of how the ScreenshotBean would be represented as an XML element is:
+ * <mfp:screenshot>
+ *   <mfp:image>
+ *     <![CDATA[
+ *     <img src="../images/inputDate.png" alt="inputDate screenshot"></img>
+ *     ]]> 
+ *   </mfp:image>
+ *   <mfp:description>
+ *     inputDate component as shown when rendered in a simple form
+ *   </mfp:description>
+ * </mfp:screenshot>
+ */
+public class ScreenshotBean extends ObjectBean
+{
+  /**
+   * Get Description Text. The description text is used as a caption for the screen
+   * shot image in the generated tag doc.
+   * 
+   * @return Screenshot Description Text
+   */
+  public String getDescription()
+  {
+    return _description;
+  }
+
+  /**
+   * Set screenshot Description Text.  The description text is used as a caption for the screen
+   * shot image in the generated tag doc.
+   *
+   * @param description   screenshot Description Text.
+   */
+  public void setDescription( String description )
+  {
+    _description = description;
+  }
+
+  /**
+   * Returns image Screenshot.
+   *
+   * @return image Screenshot
+   */
+  public String getImage()
+  {
+    return _image;
+  }
+
+  /**
+   * Set image for screenshot. 
+   *
+   * @param image  image screenshot to be added to the list.
+   */
+  public void setImage( String image )
+  {
+    _image = image;
+  }
+
+  /**
+   * Returns Screenshot hashmap key.
+   *
+   * @return Screenshot hashmap key
+   */
+  public String getKey()
+  {
+    return _key;
+  }
+
+  /**
+   * Set hashmap key for this screenshot.
+   *
+   * @param key Set key for this screenshot put in 
+   *        ComponentBean _screenshots hashmap.
+   */
+  protected void setKey( String key )
+  {
+    _key = key;
+  }
+
+  private String _description  = null;
+  private String _image        = null;
+  private String _key          = null;
+}
diff --git a/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl b/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
index 3a87320..0773dce 100644
--- a/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
+++ b/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
@@ -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" />
diff --git a/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java b/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
index 6ed5033..6ced162 100644
--- a/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
+++ b/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
@@ -62,6 +62,7 @@ import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigBean;
 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 @@ public class TagdocReport extends AbstractMavenMultiPageReport
       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 @@ public class TagdocReport extends AbstractMavenMultiPageReport
       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 @@ public class TagdocReport extends AbstractMavenMultiPageReport
       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 @@ public class TagdocReport extends AbstractMavenMultiPageReport
     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 @@ public class TagdocReport extends AbstractMavenMultiPageReport
       }
     }
     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()

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.