ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/etc junit-noframes.xsl
Date Tue, 28 Aug 2001 21:08:33 GMT
sbailliez    01/08/28 14:08:33

  Modified:    src/etc  Tag: ANT_14_BRANCH junit-noframes.xsl
  Log:
  Added changes done by Erik Hatcher <erik@hatcher.net> about properties.
  It nows pops up a window to display system properties related to a testcase.
  I changed the original patch to have a named window w/o a toolbar and
  a status bar.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +72 -41    jakarta-ant/src/etc/junit-noframes.xsl
  
  Index: junit-noframes.xsl
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/junit-noframes.xsl,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- junit-noframes.xsl	2001/08/22 21:13:26	1.1.2.2
  +++ junit-noframes.xsl	2001/08/28 21:08:32	1.1.2.3
  @@ -22,25 +22,6 @@
         	background:#eeeee0;
         }
         
  -      table.properties {
  -      	border-collapse:collapse;
  -      	border-left:solid 1 #cccccc; border-top:solid 1 #cccccc;
  -      	padding:5px;
  -      }
  -      
  -      table.properties th {
  -        text-align:left;
  -      	border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc;
  -      	background-color:#eeeeee;
  -      }
  -      
  -      table.properties td {
  -      	font:normal;
  -      	text-align:left;
  -      	border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc;
  -      	background-color:#fffffff;
  -      }
  -      
         p {
         	line-height:1.5em;
         	margin-top:0.5em; margin-bottom:1.0em;
  @@ -69,12 +50,45 @@
         .Failure {
         	font-weight:bold; color:purple;
         }
  +      .Properties {
  +      	text-align:right;
  +      }
         </style>
  -      <script language="JavaScript"><![CDATA[   
  -        function toggle (field)
  -        {
  -          field.style.display = (field.style.display == "block") ? "none" : "block";
  -        }  ]]> 
  +      <script language="JavaScript">
  +        var TestCases = new Array();
  +        var cur;
  +        <xsl:for-each select="./testsuite">      
  +            <xsl:apply-templates select="properties"/>
  +        </xsl:for-each>
  +
  +       </script>
  +       <script language="JavaScript"><![CDATA[
  +        function displayProperties (name) {
  +          var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
  +          var doc = win.document.open();
  +          doc.write("<html><head><title>Properties of " + name + "</title>");
  +          doc.write("<style>")
  +          doc.write("body {font:normal 68% verdana,arial,helvetica;	color:#000000; }");
  +          doc.write("table tr td, table tr th { font-size: 68%; }");
  +          doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc;
border-top:solid 1 #cccccc; padding:5px; }");
  +          doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc;
border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
  +          doc.write("table.properties td { font:normal; text-align:left; border-right:solid
1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
  +          doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
}");
  +          doc.write("</style>");
  +          doc.write("</head><body>");
  +          doc.write("<h3>Properties of " + name + "</h3>");
  +          doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
  +          doc.write("<table class='properties'>");
  +          doc.write("<tr><th>Name</th><th>Value</th></tr>");
  +          for (prop in TestCases[name]) {
  +            doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop]
+ "</td></tr>");
  +          }
  +          doc.write("</table>");
  +          doc.write("</body></html>");
  +          doc.close();
  +          win.focus();
  +        }
  +      ]]>  
         </script>
   		</HEAD>
   		<body>
  @@ -188,8 +202,13 @@
   				</xsl:if>
   				<xsl:apply-templates select="./testcase" mode="print.test"/>
   			</table>
  +            <div class="Properties">
  +                <a>
  +			        <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of
select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
  +			        Properties &gt;&gt;
  +			    </a>
  +            </div>
   			<p/>
  -			<xsl:apply-templates select="properties"/>
   			
   			<a href="#top">Back to top</a>
   		</xsl:for-each>
  @@ -243,25 +262,15 @@
   	</xsl:template>
   	
     <!--
  -   Simple way to display properties, it is not very nice but it does
  -   the job. Properties are sorted so that they can be found easily.
  +   Write properties into a JavaScript data structure.
      This is based on the original idea by Erik Hatcher (erik@hatcher.net)
      -->
     <xsl:template match="properties">
  -    <xsl:variable name="id" select="concat(translate(../@package,'.','_'),'_', ../@name)"/>
  -    <i><a href="javascript:toggle({$id});">Show/Hide System Properties &gt;&gt;</a></i>
  -    <div id="{$id}" style="display:none">
  -  	  <table class="properties" border="0" cellpadding="5" cellspacing="2" width="95%">
  -  	    <xsl:for-each select="property">
  -        <xsl:sort select="@name"/>
  -  		  <tr valign="top">
  -  			  <th><xsl:value-of select="@name"/></th>
  -  			  <td><xsl:value-of select="@value"/></td>
  -  		  </tr>			  
  -  	    </xsl:for-each>
  -  	  </table>
  -    </div>
  -    <p/>
  +    cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>']
= new Array();
  +  	<xsl:for-each select="property">
  +    <xsl:sort select="@name"/>
  +        cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param
name="string" select="@value"/></xsl:call-template>';
  +  	</xsl:for-each>
     </xsl:template>
   	
   <!-- Page HEADER -->
  @@ -389,6 +398,28 @@
   	<!-- the later is better but might be problematic for non-21" monitors... -->
   	<!--pre><xsl:value-of select="."/></pre-->
   </xsl:template>
  +
  +<xsl:template name="JS-escape">
  +	<xsl:param name="string"/>
  +	<xsl:choose><!-- something isn't right here, basically all single quotes need
to be replaced with backslash-single-quote
  +		<xsl:when test="contains($string,'&apos;')">
  +			<xsl:value-of select="substring-before($string,'&apos;')"/>
  +			\&apos;
  +			<xsl:call-template name="JS-escape">
  +				<xsl:with-param name="string" select="substring-after($string,'&apos;')"/>
  +			</xsl:call-template>
  +		</xsl:when> -->
  +		<xsl:when test="contains($string,'\')">
  +			<xsl:value-of select="substring-before($string,'\')"/>\\<xsl:call-template
name="JS-escape">
  +				<xsl:with-param name="string" select="substring-after($string,'\')"/>
  +			</xsl:call-template>
  +		</xsl:when>
  +		<xsl:otherwise>
  +			<xsl:value-of select="$string"/>
  +		</xsl:otherwise>
  +	</xsl:choose>
  +</xsl:template>
  +
   
   <!--
   	template that will convert a carriage return into a br tag
  
  
  

Mime
View raw message