CSS validator plugin was made completely self-contained
authorEugene Ostroukhov <eugeneo@symbian.org>
Thu, 14 Oct 2010 14:46:23 -0700
changeset 493 e4a4cac2cdeb
parent 492 aa160993160c
child 494 6786e27ef30a
CSS validator plugin was made completely self-contained
plugins/org.symbian.tools.wrttools/.classpath
plugins/org.symbian.tools.wrttools/META-INF/MANIFEST.MF
plugins/org.symbian.tools.wrttools/build.properties
plugins/org.symbian.tools.wrttools/lib/jtidy-8.0-20060801.131059-3.jar
plugins/org.symbian.tools.wrttools/plugin.xml
plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.java
plugins/org.w3c.css/.classpath
plugins/org.w3c.css/.settings/org.eclipse.pde.core.prefs
plugins/org.w3c.css/META-INF/MANIFEST.MF
plugins/org.w3c.css/build.properties
plugins/org.w3c.css/cssvalidator-eclipse-src/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.java
plugins/org.w3c.css/plugin.xml
--- a/plugins/org.symbian.tools.wrttools/.classpath	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/.classpath	Thu Oct 14 14:46:23 2010 -0700
@@ -1,8 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry exported="true" kind="lib" path="lib/jtidy-8.0-20060801.131059-3.jar"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- a/plugins/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Thu Oct 14 14:46:23 2010 -0700
@@ -19,7 +19,6 @@
  org.eclipse.wst.validation;bundle-version="1.2.102",
  org.eclipse.wst.sse.core;bundle-version="1.1.400",
  org.eclipse.wst.xml.core;bundle-version="1.1.400",
- org.w3c.css;bundle-version="1.0.0",
  org.eclipse.core.expressions;bundle-version="3.4.101",
  org.eclipse.wst.xml.ui;bundle-version="1.1.2",
  org.eclipse.ltk.core.refactoring,
@@ -55,5 +54,4 @@
 Export-Package: org.symbian.tools.wrttools,
  org.symbian.tools.wrttools.core,
  org.symbian.tools.wrttools.wizards
-Bundle-ClassPath: .,
- lib/jtidy-8.0-20060801.131059-3.jar
+Bundle-ClassPath: .
--- a/plugins/org.symbian.tools.wrttools/build.properties	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/build.properties	Thu Oct 14 14:46:23 2010 -0700
@@ -8,8 +8,7 @@
                icons/,\
                epl-v10.html,\
                license.html,\
-               libraries/,\
-               lib/
+               libraries/
 # javac 
 javacSource=1.5
 javacTarget=1.5
Binary file plugins/org.symbian.tools.wrttools/lib/jtidy-8.0-20060801.131059-3.jar has changed
--- a/plugins/org.symbian.tools.wrttools/plugin.xml	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/plugin.xml	Thu Oct 14 14:46:23 2010 -0700
@@ -81,24 +81,6 @@
     </objectContribution>
    </extension>  
 
-<!-- CSS Validator -->
-	<extension id="org.symbian.tools.wrttools.core.cssvalidator"
-		name="CSS Validator" point="org.eclipse.wst.validation.validatorV2">
-		<validator build="true"
-			class="org.symbian.tools.wrttools.core.internal.validation.CssBuildValidator"
-			manual="true" markerId="org.symbian.tools.wrttools.core.cssValidationMarker"
-			version="0.0.1">
-			<include>
-				<rules>
-					<contentType exactMatch="false"
-						id="org.eclipse.wst.css.core.csssource">
-					</contentType>
-				</rules>
-			</include>
-		</validator>
-	</extension>
-	 
-	
 <!-- WRT Project Templates -->
 	
 <!-- Import Wizard -->
--- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.java	Mon Oct 11 17:25:46 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- *******************************************************************************/
-package org.symbian.tools.wrttools.core.internal.validation;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.ValidatorMessage;
-import org.symbian.tools.wrttools.Activator;
-import org.w3c.css.css.DocumentParser;
-import org.w3c.css.css.StyleSheet;
-import org.w3c.css.parser.CssError;
-import org.w3c.css.properties.PropertiesLoader;
-import org.w3c.css.util.ApplContext;
-import org.w3c.css.util.Warning;
-
-public class CssBuildValidator extends AbstractValidator {
-    @Override
-    public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
-        return main(resource.getLocationURI().toString(), resource);
-    }
-
-    public ValidationResult main(String uri, IResource resource) {
-        String language = "en";
-        String profile = "css3"; // css2, css21 (default), css3, svg, svgbasic,
-        // svgtiny, atsc-tv, mobile, tv
-        String medium = ""; // (default), aural, braille, embossed,
-        // handheld, print, projection, screen,
-        // tty, tv, presentation
-        int warningLevel = 2; // -1 (no warning), 0, 1, 2 (default, all the
-        // warnings)
-
-        // first, we get the parameters and create an application context
-        ApplContext ac = new ApplContext(language);
-
-        if (profile != null && !"none".equals(profile)) {
-            if ("css1".equals(profile) || "css2".equals(profile) || "css21".equals(profile) || "css3".equals(profile)
-                    || "svg".equals(profile) || "svgbasic".equals(profile) || "svgtiny".equals(profile)) {
-                ac.setCssVersion(profile);
-            } else {
-                ac.setProfile(profile);
-                ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile"));
-            }
-        } else {
-            ac.setProfile(profile);
-            ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile"));
-        }
-
-        // medium to use
-        ac.setMedium(medium);
-
-        // HTML document
-        try {
-            DocumentParser urlParser = new DocumentParser(ac, uri);
-
-            return handleRequest(ac, uri, urlParser.getStyleSheet(), warningLevel, true, resource);
-        } catch (Exception e) {
-            Activator.log(e);
-        }
-        return null;
-    }
-
-    private ValidationResult handleRequest(ApplContext ac, String title, StyleSheet styleSheet, int warningLevel,
-            boolean errorReport, IResource resource) throws Exception {
-
-        if (styleSheet == null) {
-            throw new IOException(ac.getMsg().getServletString("process") + " " + title);
-        }
-
-        styleSheet.findConflicts(ac);
-        ValidationResult result = new ValidationResult();
-        CssError[] errors = styleSheet.getErrors().getErrors();
-        for (CssError cssError : errors) {
-            String msg = cssError.getException().getLocalizedMessage();
-            if (msg != null && msg.trim().length() > 0) {
-                ValidatorMessage message = createMessage(resource, cssError.getLine(), msg, IMarker.SEVERITY_WARNING);
-                result.add(message);
-            }
-        }
-        Warning[] warnings = styleSheet.getWarnings().getWarnings();
-        for (Warning warning : warnings) {
-            ValidatorMessage message = createMessage(resource, warning.getLine(), warning.getWarningMessage(),
-                    IMarker.SEVERITY_WARNING);
-            result.add(message);
-        }
-        return result;
-    }
-
-    private ValidatorMessage createMessage(IResource resource, int line, String msg, int severity) {
-        ValidatorMessage message = ValidatorMessage.create(msg, resource);
-        message.setAttribute(IMarker.LINE_NUMBER, line);
-        message.setAttribute(IMarker.SEVERITY, severity);
-        return message;
-    }
-}
--- a/plugins/org.w3c.css/.classpath	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.w3c.css/.classpath	Thu Oct 14 14:46:23 2010 -0700
@@ -1,9 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/>
-	<classpathentry kind="src" path="cssvalidation-src"/>
-	<classpathentry kind="src" path="cssvalidator-mods-src"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="cssvalidation-src"/>
+	<classpathentry kind="src" path="cssvalidator-mods-src"/>
+	<classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/>
+	<classpathentry kind="src" path="cssvalidator-eclipse-src/"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- a/plugins/org.w3c.css/.settings/org.eclipse.pde.core.prefs	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.w3c.css/.settings/org.eclipse.pde.core.prefs	Thu Oct 14 14:46:23 2010 -0700
@@ -1,5 +1,5 @@
-#Wed Feb 24 10:41:50 PST 2010
-eclipse.preferences.version=1
-pluginProject.equinox=false
-pluginProject.extensions=false
-resolve.requirebundle=false
+#Thu Oct 14 14:34:01 PDT 2010
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=true
+resolve.requirebundle=false
--- a/plugins/org.w3c.css/META-INF/MANIFEST.MF	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.w3c.css/META-INF/MANIFEST.MF	Thu Oct 14 14:46:23 2010 -0700
@@ -1,7 +1,7 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: W3C CSS Validator
-Bundle-SymbolicName: org.w3c.css
+Bundle-SymbolicName: org.w3c.css;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-Vendor: World Wide Web Consortium (W3C)
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
@@ -35,3 +35,7 @@
  org.w3c.www.mime
 Import-Package: org.apache.velocity.io;version="1.5.0",
  org.apache.xerces.parsers;version="2.9.0"
+Require-Bundle: org.eclipse.wst.validation;bundle-version="1.2.200",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0"
+Bundle-ActivationPolicy: lazy
--- a/plugins/org.w3c.css/build.properties	Mon Oct 11 17:25:46 2010 -0700
+++ b/plugins/org.w3c.css/build.properties	Thu Oct 14 14:46:23 2010 -0700
@@ -1,13 +1,9 @@
 source.. = cssvalidation-src/,\
-           cssvalidator-mods-src/
+           cssvalidator-mods-src/,\
+           cssvalidator-eclipse-src/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
-               lib/
-src.includes = cssvalidation-src/,\
-               cssvalidator-mods-src/,\
-               cssvalidator-removed-src/,\
-               .classpath,\
-               .project,\
-               .settings/,\
-               build.properties
+               lib/,\
+               plugin.xml
+src.includes = cssvalidator-removed-src/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/org.w3c.css/cssvalidator-eclipse-src/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.java	Thu Oct 14 14:46:23 2010 -0700
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ *******************************************************************************/
+package org.symbian.tools.wrttools.core.internal.validation;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.validation.AbstractValidator;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.w3c.css.css.DocumentParser;
+import org.w3c.css.css.StyleSheet;
+import org.w3c.css.parser.CssError;
+import org.w3c.css.properties.PropertiesLoader;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.Warning;
+
+public class CssBuildValidator extends AbstractValidator {
+    @Override
+    public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
+        return main(resource.getLocationURI().toString(), resource);
+    }
+
+    public ValidationResult main(String uri, IResource resource) {
+        String language = "en";
+        String profile = "css3"; // css2, css21 (default), css3, svg, svgbasic,
+        // svgtiny, atsc-tv, mobile, tv
+        String medium = ""; // (default), aural, braille, embossed,
+        // handheld, print, projection, screen,
+        // tty, tv, presentation
+        int warningLevel = 2; // -1 (no warning), 0, 1, 2 (default, all the
+        // warnings)
+
+        // first, we get the parameters and create an application context
+        ApplContext ac = new ApplContext(language);
+
+        if (profile != null && !"none".equals(profile)) {
+            if ("css1".equals(profile) || "css2".equals(profile) || "css21".equals(profile) || "css3".equals(profile)
+                    || "svg".equals(profile) || "svgbasic".equals(profile) || "svgtiny".equals(profile)) {
+                ac.setCssVersion(profile);
+            } else {
+                ac.setProfile(profile);
+                ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile"));
+            }
+        } else {
+            ac.setProfile(profile);
+            ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile"));
+        }
+
+        // medium to use
+        ac.setMedium(medium);
+
+        // HTML document
+        try {
+            DocumentParser urlParser = new DocumentParser(ac, uri);
+
+            return handleRequest(ac, uri, urlParser.getStyleSheet(), warningLevel, true, resource);
+        } catch (Exception e) {
+            Platform.getLog(Platform.getBundle("org.w3c.css")).log(new Status(IStatus.ERROR, "org.w3c.css", null, e));
+        }
+        return null;
+    }
+
+    private ValidationResult handleRequest(ApplContext ac, String title, StyleSheet styleSheet, int warningLevel,
+            boolean errorReport, IResource resource) throws Exception {
+
+        if (styleSheet == null) {
+            throw new IOException(ac.getMsg().getServletString("process") + " " + title);
+        }
+
+        styleSheet.findConflicts(ac);
+        ValidationResult result = new ValidationResult();
+        CssError[] errors = styleSheet.getErrors().getErrors();
+        for (CssError cssError : errors) {
+            String msg = cssError.getException().getLocalizedMessage();
+            if (msg != null && msg.trim().length() > 0) {
+                ValidatorMessage message = createMessage(resource, cssError.getLine(), msg, IMarker.SEVERITY_WARNING);
+                result.add(message);
+            }
+        }
+        Warning[] warnings = styleSheet.getWarnings().getWarnings();
+        for (Warning warning : warnings) {
+            ValidatorMessage message = createMessage(resource, warning.getLine(), warning.getWarningMessage(),
+                    IMarker.SEVERITY_WARNING);
+            result.add(message);
+        }
+        return result;
+    }
+
+    private ValidatorMessage createMessage(IResource resource, int line, String msg, int severity) {
+        ValidatorMessage message = ValidatorMessage.create(msg, resource);
+        message.setAttribute(IMarker.LINE_NUMBER, line);
+        message.setAttribute(IMarker.SEVERITY, severity);
+        return message;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/org.w3c.css/plugin.xml	Thu Oct 14 14:46:23 2010 -0700
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<!-- CSS Validator -->
+	<extension id="org.symbian.tools.wrttools.core.cssvalidator"
+		name="CSS Validator" point="org.eclipse.wst.validation.validatorV2">
+		<validator build="true"
+			class="org.symbian.tools.wrttools.core.internal.validation.CssBuildValidator"
+			manual="true" markerId="org.symbian.tools.wrttools.core.cssValidationMarker"
+			version="0.0.1">
+			<include>
+				<rules>
+					<contentType exactMatch="false"
+						id="org.eclipse.wst.css.core.csssource">
+					</contentType>
+				</rules>
+			</include>
+		</validator>
+	</extension>
+</plugin>