1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package graphical; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.io.File; 27cdf0e10cSrcweir import java.io.FileWriter; 28cdf0e10cSrcweir // import util.utils; 29cdf0e10cSrcweir // import helper.OSHelper; 30cdf0e10cSrcweir 31cdf0e10cSrcweir public class HTMLResult 32cdf0e10cSrcweir { 33cdf0e10cSrcweir private FileWriter m_aOut; 34cdf0e10cSrcweir // private String m_sFilename; 35cdf0e10cSrcweir // private String m_sNamePrefix; // the HTML files used a suffix to build it's right name 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** 38cdf0e10cSrcweir * ls is the current line separator (carridge return) 39cdf0e10cSrcweir */ 40cdf0e10cSrcweir private String ls; 41cdf0e10cSrcweir HTMLResult( String _sOutputPath, String _sHTMLFilename )42cdf0e10cSrcweir public HTMLResult( String _sOutputPath, String _sHTMLFilename ) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir FileHelper.makeDirectories("", _sOutputPath); 45cdf0e10cSrcweir // HTMLResult a = new HTMLResult(); 46cdf0e10cSrcweir String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename); 47cdf0e10cSrcweir 48cdf0e10cSrcweir try 49cdf0e10cSrcweir { 50cdf0e10cSrcweir File outputFile = new File(sFilename); 51cdf0e10cSrcweir m_aOut = new FileWriter(outputFile.toString()); 52cdf0e10cSrcweir ls = System.getProperty("line.separator"); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir catch (java.io.IOException e) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir e.printStackTrace(); 57cdf0e10cSrcweir GlobalLogWriter.println("ERROR: Can't create HTML Outputter"); 58cdf0e10cSrcweir // return null; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir // m_sFilename = sFilename; 61cdf0e10cSrcweir // a.m_sNamePrefix = _sNamePrefix; 62cdf0e10cSrcweir // return a; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir // public String getFilename() {return m_sFilename;} 66cdf0e10cSrcweir writeln(String _sStr)67cdf0e10cSrcweir private void writeln(String _sStr) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir try 70cdf0e10cSrcweir { 71cdf0e10cSrcweir m_aOut.write( _sStr ); 72cdf0e10cSrcweir m_aOut.write ( ls ); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir catch (java.io.IOException e) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir } 77cdf0e10cSrcweir } flush()78cdf0e10cSrcweir private void flush() 79cdf0e10cSrcweir { 80cdf0e10cSrcweir try 81cdf0e10cSrcweir { 82cdf0e10cSrcweir m_aOut.flush(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir catch (java.io.IOException e) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir } 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir * create the HTML header 92cdf0e10cSrcweir * @param _sTitle 93cdf0e10cSrcweir */ header(String _sTitle)94cdf0e10cSrcweir public void header(String _sTitle) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir writeln( "<HTML>"); 97cdf0e10cSrcweir writeln( "<HEAD>" ); 98cdf0e10cSrcweir writeln( "<TITLE>" + _sTitle + "</TITLE>"); 99cdf0e10cSrcweir writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />"); 100cdf0e10cSrcweir writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />"); 101cdf0e10cSrcweir writeln( "</HEAD>"); 102cdf0e10cSrcweir writeln( "<BODY bgcolor=white>"); 103cdf0e10cSrcweir flush(); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir final static String TEST_TABLETITLE = "Document"; 107cdf0e10cSrcweir final static String VISUAL_STATUS_TABLETITLE = "Visual status"; 108cdf0e10cSrcweir final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message"; 109cdf0e10cSrcweir final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg"; 110cdf0e10cSrcweir indexSection(String _sOfficeInfo)111cdf0e10cSrcweir public void indexSection(String _sOfficeInfo) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir writeln( "<H2>Results for " + _sOfficeInfo + "</H2>"); 114cdf0e10cSrcweir writeln( "<P>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog()); 115cdf0e10cSrcweir writeln( "<P>Legend:<BR>"); 116cdf0e10cSrcweir writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<BR>"); 117cdf0e10cSrcweir 118cdf0e10cSrcweir writeln( "<TABLE class=\"infotable\">"); 119cdf0e10cSrcweir writeln( "<TR>"); 120cdf0e10cSrcweir writeln( tableHeaderCell(TEST_TABLETITLE)); 121cdf0e10cSrcweir writeln( tableHeaderCell("")); 122cdf0e10cSrcweir writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE)); 123cdf0e10cSrcweir writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE)); 124cdf0e10cSrcweir writeln( "</TR>"); 125cdf0e10cSrcweir flush(); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir /** 128cdf0e10cSrcweir * Returns the given _sHREF & _sPathInfo as a HTML String 129cdf0e10cSrcweir * <A HREF="_sHREF">_sPathInfo</A> 130cdf0e10cSrcweir * @param _sHREF 131cdf0e10cSrcweir * @param _sPathInfo 132cdf0e10cSrcweir * @return 133cdf0e10cSrcweir */ getHREF(String _sHREF, String _sPathInfo)134cdf0e10cSrcweir private String getHREF(String _sHREF, String _sPathInfo) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir StringBuffer a = new StringBuffer(); 137cdf0e10cSrcweir a.append("<A HREF=\""); 138cdf0e10cSrcweir a.append(_sHREF); 139cdf0e10cSrcweir a.append("\">"); 140cdf0e10cSrcweir a.append(_sPathInfo); 141cdf0e10cSrcweir a.append("</A>"); 142cdf0e10cSrcweir return a.toString(); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir /** 146cdf0e10cSrcweir * Returns the given _sValue as a HTML Table cell with _sValue as content 147cdf0e10cSrcweir * @param _sValue 148cdf0e10cSrcweir * @return 149cdf0e10cSrcweir */ tableDataCell(String _sValue)150cdf0e10cSrcweir private String tableDataCell(String _sValue) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir StringBuffer a = new StringBuffer(); 153cdf0e10cSrcweir a.append("<TD>"); 154cdf0e10cSrcweir a.append(_sValue); 155cdf0e10cSrcweir a.append("</TD>"); 156cdf0e10cSrcweir return a.toString(); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir /** 160cdf0e10cSrcweir * Returns the given _sValue as a HTML Table header cell with _sValue as content 161cdf0e10cSrcweir * @param _sValue 162cdf0e10cSrcweir * @return 163cdf0e10cSrcweir */ tableHeaderCell(String _sValue)164cdf0e10cSrcweir private String tableHeaderCell(String _sValue) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir StringBuffer a = new StringBuffer(); 167cdf0e10cSrcweir a.append("<TH>"); 168cdf0e10cSrcweir a.append(_sValue); 169cdf0e10cSrcweir a.append("</TH>"); 170cdf0e10cSrcweir return a.toString(); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)173cdf0e10cSrcweir public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir writeln( "<TR>"); 176cdf0e10cSrcweir writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) ); 177cdf0e10cSrcweir writeln(tableDataCell( "" ) ); 178cdf0e10cSrcweir writeln( tableDataCell(_sStatusRunThrough) ); 179cdf0e10cSrcweir writeln( tableDataCell(_sStatusMessage) ); 180cdf0e10cSrcweir writeln( "</TR>"); 181cdf0e10cSrcweir flush(); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir close()184cdf0e10cSrcweir public void close() 185cdf0e10cSrcweir { 186cdf0e10cSrcweir writeln( "</TABLE>"); 187cdf0e10cSrcweir writeln( "</BODY></HTML>"); 188cdf0e10cSrcweir try 189cdf0e10cSrcweir { 190cdf0e10cSrcweir m_aOut.close(); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir catch (java.io.IOException e) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir } 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir // ----------------------------------------------------------------------------- stronghtml(String _sValue)198cdf0e10cSrcweir private String stronghtml(String _sValue) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir StringBuffer a = new StringBuffer(); 201cdf0e10cSrcweir a.append("<STRONG>"); 202cdf0e10cSrcweir a.append(_sValue); 203cdf0e10cSrcweir a.append("</STRONG>"); 204cdf0e10cSrcweir return a.toString(); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir } 208