org.symbian.tools.wrttools/cssvalidator-removed-src/css/StyleSheetGenerator.java
author John Kern <johnk@symbian.org>
Fri, 29 Jan 2010 16:32:12 -0800
changeset 62 040d2c998a7b
parent 3 d3477de62514
permissions -rw-r--r--
source level most be provided on command line; work is variable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     1
package org.w3c.css.css;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     2
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     3
import java.io.FileNotFoundException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     4
import java.io.IOException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     5
import java.io.PrintWriter;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     6
import java.net.URL;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     7
import java.text.SimpleDateFormat;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     8
import java.util.ArrayList;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     9
import java.util.Date;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    10
import java.util.Enumeration;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    11
import java.util.HashMap;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    12
import java.util.Hashtable;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    13
import java.util.Iterator;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    14
import java.util.TimeZone;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    15
import java.util.Vector;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    16
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    17
import org.apache.velocity.VelocityContext;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    18
import org.apache.velocity.Template;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    19
import org.apache.velocity.app.Velocity;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    20
import org.apache.velocity.exception.ResourceNotFoundException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    21
import org.apache.velocity.exception.ParseErrorException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    22
import org.w3c.css.error.ErrorReportHTML;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    23
import org.w3c.css.parser.CssError;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    24
import org.w3c.css.parser.CssErrorToken;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    25
import org.w3c.css.parser.CssParseException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    26
import org.w3c.css.parser.Errors;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    27
import org.w3c.css.properties.PropertiesLoader;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    28
import org.w3c.css.util.ApplContext;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    29
import org.w3c.css.util.InvalidParamException;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    30
import org.w3c.css.util.Messages;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    31
import org.w3c.css.util.Utf8Properties;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    32
import org.w3c.css.util.Warnings;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    33
import org.w3c.css.util.Warning;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    34
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    35
/**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    36
 * @author Julien Grand-Mourcel
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    37
 * @author Maria Kaceriakova
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    38
 * @date 2007-06-29
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    39
 * This class uses Velocity to output the validator results
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    40
 * 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    41
 */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    42
public class StyleSheetGenerator extends StyleReport {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    43
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    44
    private PrintWriter out;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    45
    private Template template;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    46
    private String template_file;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    47
    private String default_lang = "en"; 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    48
    private ApplContext ac;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    49
    private StyleSheet style;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    50
    private String title;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    51
    private VelocityContext context;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    52
    private Warnings warnings;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    53
    private Errors errors;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    54
    private Vector items;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    55
    private static Utf8Properties availableFormat;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    56
    private static Utf8Properties availablePropertiesURL;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    57
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    58
    static {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    59
        availableFormat = new Utf8Properties();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    60
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    61
            java.io.InputStream f;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    62
	    f = StyleSheetGenerator.class.getResourceAsStream(
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    63
							   "format.properties");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    64
            availableFormat.load(f);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    65
            f.close();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    66
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    67
            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: "+
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    68
			       "couldn't load format properties ");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    69
            System.err.println("  " + e.toString());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    70
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    71
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    72
        availablePropertiesURL = new Utf8Properties();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    73
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    74
            java.io.InputStream f;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    75
	    f = StyleSheetGenerator.class.getResourceAsStream(
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    76
							     "urls.properties");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    77
            availablePropertiesURL.load(f);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    78
            f.close();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    79
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    80
            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: "+
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    81
			       "couldn't load URLs properties ");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    82
            System.err.println("  " + e.toString());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    83
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    84
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    85
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    86
            Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    87
            Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    88
            Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".class",
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    89
	       "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    90
            URL path = StyleSheetGenerator.class.getResource("/");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    91
            if(path != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    92
                Velocity.addProperty("file." + Velocity.RESOURCE_LOADER +
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    93
				     ".path", path.getFile());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    94
                Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER+".path",
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    95
				      "jar:" + path + "css-validator.jar");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    96
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    97
            Velocity.init();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    98
        } catch(Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    99
            System.err.println("Failed to initialize Velocity. "+
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   100
			       "Validator might not work as expected.");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   101
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   102
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   103
	
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   104
    public StyleSheetGenerator(String title, StyleSheet style, String document,
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   105
			       int warningLevel)
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   106
    {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   107
        this(null, title, style, document, warningLevel);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   108
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   109
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   110
    public StyleSheetGenerator(ApplContext ac, String title, StyleSheet style,
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   111
			       String document, int warningLevel) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   112
        this.ac = ac;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   113
        this.style = style;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   114
        this.title = title;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   115
        this.template_file = availableFormat.getProperty(document);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   116
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   117
        context = new VelocityContext();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   118
	// adjust the source name if needed
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   119
	if (ac.isInputFake()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   120
	    title = title.substring(title.lastIndexOf('/')+1);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   121
	}
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   122
	context.put("file_title", queryReplace(title));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   123
	        
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   124
        // W3C_validator_result
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   125
        warnings = style.getWarnings();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   126
        errors = style.getErrors();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   127
        items = style.newGetRules();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   128
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   129
        // Setting all the variables of the velocity context
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   130
        ApplContext ac_default = new ApplContext(default_lang);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   131
        String k;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   132
        if (ac.getLang() == null || ac.getLang().equals(default_lang)) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   133
            Iterator it = ac_default.getMsg().properties.keySet().iterator();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   134
            while (it.hasNext()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   135
                k = String.valueOf(it.next());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   136
                context.put(k, ac.getMsg().getString(k));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   137
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   138
        } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   139
            Iterator it = ac_default.getMsg().properties.keySet().iterator();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   140
            while (it.hasNext()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   141
                k = String.valueOf(it.next());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   142
                if (ac.getMsg().getString(k) == null)
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   143
                    context.put(k, ac_default.getMsg().getString(k));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   144
                else
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   145
                    context.put(k, ac.getMsg().getString(k));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   146
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   147
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   148
		
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   149
        if (ac.getLink() != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   150
	    int arraysize = Messages.languages_name.size();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   151
	    ArrayList<HashMap<String,String>> languages;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   152
	    languages = new ArrayList<HashMap<String,String>>(arraysize);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   153
            String name;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   154
            for (int i = 0; i < arraysize; ++i) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   155
                name = String.valueOf(Messages.languages_name.get(i));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   156
                HashMap<String,String> l = new HashMap<String,String>();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   157
                l.put("name", name);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   158
                l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   159
		languages.add(i, l);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   160
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   161
            context.put("languages", languages.toArray());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   162
            String link = ac.getLink().replaceAll("&lang=.*&", "&");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   163
            link = link.replaceAll("&lang=.*$", "");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   164
            context.put("link", "?" + link.replaceAll("&", "&amp;"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   165
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   166
		
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   167
        // generated values
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   168
        SimpleDateFormat formatter;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   169
	formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   170
        formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   171
        context.put("currentdate", formatter.format(new Date()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   172
        context.put("lang", ac.getContentLanguage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   173
        context.put("errors_count", new Integer(errors.getErrorCount()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   174
        context.put("warnings_count", new Integer(warnings.getWarningCount()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   175
        context.put("ignored-warnings_count", 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   176
		               new Integer(warnings.getIgnoredWarningCount()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   177
        context.put("warning_level", new Integer(warningLevel));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   178
        context.put("rules_count", new Integer(items.size()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   179
        context.put("no_errors_report", new Boolean(false));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   180
        context.put("charset", ac.getContentEncoding());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   181
        context.put("cssversion", ac.getCssVersion());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   182
        context.put("css_profile", ac.getProfile());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   183
        context.put("css", ac.getMsg().getString(ac.getCssVersion()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   184
        context.put("css_link",getURLProperty("@url-base_"+ac.getCssVersion()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   185
        context.put("is_valid", (errors.getErrorCount() == 0)?"true":"false");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   186
	context.put("fake_input", new Boolean(ac.isInputFake()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   187
        context.put("author", "www-validator-css");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   188
        context.put("author-email", "Email.html");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   189
        if (style.charset != null)
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   190
            context.put("style_charset", style.charset);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   191
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   192
        produceError();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   193
        produceWarning();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   194
        produceStyleSheet();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   195
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   196
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   197
            template = Velocity.getTemplate("org/w3c/css/css/" + template_file);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   198
	    template.setEncoding("utf-8");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   199
        } catch (ResourceNotFoundException rnfe) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   200
            System.err.println(rnfe.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   201
            rnfe.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   202
        } catch (ParseErrorException pee) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   203
            System.err.println(pee.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   204
            pee.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   205
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   206
            System.err.println(e.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   207
            e.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   208
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   209
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   210
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   211
    private final static String getURLProperty(String name) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   212
        return availablePropertiesURL.getProperty(name);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   213
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   214
	
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   215
    public final static void printAvailableFormat(PrintWriter out) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   216
        Enumeration e = availableFormat.propertyNames();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   217
        out.println(" -- listing available output format --");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   218
        while (e.hasMoreElements()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   219
            String key = ((String) e.nextElement()).toLowerCase();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   220
            out.println("Format : " + key);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   221
            out.println("   File : " + getDocumentName(key));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   222
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   223
        out.flush();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   224
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   225
	
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   226
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   227
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   228
     * Test if <tt>document</tt> is an available output
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   229
     * @param document, the desired output
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   230
     * @return <tt>true</tt> if the desired output is available
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   231
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   232
    public static boolean isAvailableFormat(String document) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   233
        return availableFormat.containsKey(document);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   234
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   235
	
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   236
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   237
    private final static String getDocumentName(String documentName) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   238
        String document = availableFormat.getProperty(documentName
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   239
                                                      .toLowerCase());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   240
        if (document == null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   241
            System.err.println("Unable to find " + documentName.toLowerCase()
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   242
                               + " output format");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   243
            return documentName;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   244
        } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   245
            return document;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   246
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   247
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   248
	
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   249
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   250
     * Add the style information to the context
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   251
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   252
    private void produceStyleSheet() {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   253
        context.put("at_rules_list", style.newGetRules());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   254
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   255
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   256
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   257
     * Add the errors information to the context
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   258
     * For each error,
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   259
     * <ul>
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   260
     * <li> the error type and message, and
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   261
     * <li> the context type and value
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   262
     * </ul>
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   263
     * are set.
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   264
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   265
    private void produceError() {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   266
        Hashtable[] errors_content = new Hashtable[errors.getErrorCount()];
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   267
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   268
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   269
            if (errors.getErrorCount() != 0) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   270
                CssError[] error = errors.getErrors();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   271
                int nbError = error.length;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   272
                for (int i=0; i < nbError; i++) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   273
                    CssError csserror = error[i];
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   274
                    Throwable ex = csserror.getException();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   275
                    Hashtable<String,Object> h = new Hashtable<String,Object>();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   276
                    errors_content[i] = h;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   277
                    h.put("Error", csserror);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   278
                    h.put("CtxName", "nocontext");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   279
                    h.put("CtxMsg", "");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   280
                    h.put("ErrorMsg", ((ex.getMessage() == null) ? "" :
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   281
				                             ex.getMessage()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   282
                    h.put("ClassName", "unkownerror");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   283
                    if (ex instanceof FileNotFoundException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   284
                        h.put("ClassName", "notfound");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   285
                        h.put("ErrorMsg", 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   286
			      ac.getMsg().getGeneratorString("not-found") + 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   287
			      ": " + ex.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   288
                    } else if (ex instanceof CssParseException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   289
                        produceParseException((CssParseException) ex, h);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   290
                    } else if (ex instanceof InvalidParamException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   291
                        h.put("ClassName", "invalidparam");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   292
                    } else if (ex instanceof IOException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   293
                        String stringError = ex.toString();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   294
                        // int index = stringError.indexOf(':');
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   295
                        // The Exception name 'StringError' was previously
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   296
                        // displayed
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   297
                        // between </td> and <td class='nocontext' ...
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   298
                        // It's now displayed inside the <td class='nocontext'>
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   299
                        // tag
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   300
                        // because we would need a new variable to put it there
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   301
                        // for
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   302
                        // just one rare case
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   303
                        // TODO: why not using ex.toString()?
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   304
                        h.put("CtxMsg", stringError);// .substring(0,
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   305
                        // index));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   306
                        h.put("ClassName", "io");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   307
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   308
                    } else if (csserror instanceof CssErrorToken) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   309
                        CssErrorToken terror = (CssErrorToken) csserror;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   310
                        h.put("ClassName", "errortoken");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   311
                        h.put("ErrorMsg", terror.getErrorDescription() + " : "
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   312
                              + terror.getSkippedString());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   313
                    } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   314
                        h.put("ClassName", "unkownerror");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   315
                        h.put("ErrorMsg", ac.getMsg().getErrorString("unknown")
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   316
			                  + " " + ex);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   317
                        if (ex instanceof NullPointerException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   318
                            // ohoh, a bug
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   319
                            ex.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   320
                        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   321
                    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   322
                }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   323
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   324
            context.put("errors_content", errors_content);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   325
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   326
            context.put("errors_content", errors_content);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   327
            context.put("request", ac.getMsg().getGeneratorString("request"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   328
            System.err.println(e.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   329
            e.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   330
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   331
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   332
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   333
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   334
     * Add an array of warnings to the context so it c an be displayed
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   335
     * 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   336
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   337
    private void produceWarning() {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   338
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   339
            if (warnings.getWarningCount() != 0) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   340
                warnings.sort();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   341
                context.put("warnings_list", warnings.getWarnings());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   342
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   343
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   344
            out.println(ac.getMsg().getGeneratorString("request"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   345
            e.printStackTrace();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   346
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   347
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   348
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   349
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   350
     * Some error need more details
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   351
     * We can add a link or information of this kind
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   352
     * @param error, the error to check
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   353
     * @param ht_error, the Hastable with information about this error
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   354
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   355
    private void produceParseException(CssParseException error, 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   356
				       Hashtable<String,Object> ht_error) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   357
        if (error.getContexts() != null && error.getContexts().size() != 0) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   358
            ht_error.put("CtxName", "codeContext");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   359
            StringBuilder buf = new StringBuilder();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   360
            // Loop on the list of contexts for errors
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   361
	    Enumeration e;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   362
            for (e = error.getContexts().elements(); e.hasMoreElements();) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   363
                Object t = e.nextElement();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   364
                // if the list is not null, add a comma
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   365
                if (t != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   366
                    buf.append(t);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   367
                    if (e.hasMoreElements()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   368
                        buf.append(", ");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   369
                    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   370
                }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   371
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   372
            if (buf.length() != 0) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   373
                ht_error.put("CtxMsg", String.valueOf(buf));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   374
	    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   375
        } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   376
            ht_error.put("CtxName", "nocontext");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   377
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   378
        ht_error.put("ClassName", "parse-error");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   379
        String name = error.getProperty();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   380
        String ret;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   381
        if ((name != null) && (getURLProperty(name) != null) && 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   382
	    PropertiesLoader.getProfile(ac.getCssVersion()).containsKey(name)) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   383
            //we add a link information
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   384
            // we check if the property doesn't exist in this css version
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   385
            ht_error.put("link_before_parse_error",
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   386
			 ac.getMsg().getGeneratorString("property"));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   387
            // Since CSS3 is only a working draft, the links don't exist yet
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   388
	    // in CSS3...
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   389
            // And this is the same with CSS1 because the links are not working
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   390
	    // the same way...
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   391
            // This can be removed as soon as the CSS3 specifications are made
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   392
	    // and CSS1 use the links
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   393
            // and the link is changed in urls.properties
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   394
            String lnk;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   395
            if (ac.getCssVersion().equals("css3")) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   396
                lnk = getURLProperty("@url-base_css2.1");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   397
            } else if (ac.getCssVersion().equals("css1")) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   398
                lnk = getURLProperty("@url-base_css2"); 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   399
            } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   400
                lnk = context.get("css_link").toString();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   401
	    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   402
            // this would be replaced by :
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   403
            // ht_error.put("link_value_parse_error",
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   404
	    //              context.get("css_link") + getURLProperty(name));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   405
            ht_error.put("link_value_parse_error", lnk + getURLProperty(name));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   406
            ht_error.put("link_name_parse_error", name);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   407
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   408
        if ((error.getException() != null) && (error.getMessage() != null)) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   409
            if (error.isParseException()) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   410
                ret = queryReplace(error.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   411
            } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   412
                Exception ex = error.getException();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   413
                if (ex instanceof NumberFormatException) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   414
                    ret = ac.getMsg().getGeneratorString("invalid-number");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   415
                } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   416
                    ret = queryReplace(ex.getMessage());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   417
                }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   418
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   419
            if (error.getSkippedString() != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   420
                ht_error.put("span_class_parse_error", "skippedString");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   421
                ht_error.put("span_value_parse_error", 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   422
			     queryReplace(error.getSkippedString()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   423
            } else if (error.getExp() != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   424
                ret += " : " + queryReplace(error.getExp().toStringFromStart());
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   425
                ht_error.put("span_class_parse_error", "exp");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   426
                ht_error.put("span_value_parse_error", 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   427
			     queryReplace(error.getExp().toString()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   428
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   429
        } else {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   430
            ret = ac.getMsg().getGeneratorString("unrecognize");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   431
            ht_error.put("span_class_parse_error", "unrecognized");
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   432
            ht_error.put("span_value_parse_error", 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   433
			 queryReplace(error.getSkippedString()));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   434
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   435
        ht_error.put("ErrorMsg", ret);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   436
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   437
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   438
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   439
     * 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   440
     * @param s, the string to convert
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   441
     * @return the string s with html character escaped
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   442
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   443
    private String queryReplace(String s) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   444
        if (s != null) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   445
            int len = s.length();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   446
            StringBuilder ret = new StringBuilder(len+16);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   447
            char c;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   448
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   449
            for (int i = 0; i < len; i++) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   450
                switch (c = s.charAt(i)) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   451
                case '&'  : ret.append("&amp;"); break;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   452
                case '\'' : ret.append("&#39;"); break;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   453
                case '"'  : ret.append("&quot;"); break;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   454
                case '<'  : ret.append("&lt;"); break;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   455
                case '>'  : ret.append("&gt;"); break;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   456
                default   : ret.append(c);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   457
                }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   458
            }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   459
            return ret.toString();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   460
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   461
        return "[empty string]";
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   462
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   463
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   464
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   465
     * Display the output 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   466
     * @require VelocityContext to be set and init()
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   467
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   468
    public void print(PrintWriter out) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   469
        this.out = out;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   470
        try {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   471
            // Velocity context must have been setup in IndexGenerator
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   472
            template.merge(context, out);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   473
        } catch (Exception e) {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   474
            new ErrorReportHTML(ac, title, "", e).print(out);
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   475
        }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   476
        out.flush();
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   477
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   478
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   479
    /**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   480
     * The user doesn't want to see the error report when this function 
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   481
     * is called
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   482
     */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   483
    public void desactivateError() {
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   484
        context.put("no_errors_report", new Boolean(true));
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   485
	// activate the no errors report
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   486
    }
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   487
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   488
}