bug 331615 Add a new plug-in that defines a document type for XHTML and provides styles.
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.classpath b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.classpath
new file mode 100644
index 0000000..472ee29
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.project b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.project
new file mode 100644
index 0000000..d8bebca
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wst.xml.vex.xhtml</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/META-INF/MANIFEST.MF b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..1f0471d
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.wst.xml.vex.xhtml;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.wst.xml.vex.ui;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.wst.xml.vex.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jface;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.emf.common;bundle-version="[2.4.1,3.0.0)",
+ org.eclipse.emf.ecore;bundle-version="[2.4.1,4.0.0)",
+ org.eclipse.wst.standard.schemas;bundle-version="[1.0.0,2.0.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ClassPath: .
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/build.properties b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/build.properties
new file mode 100644
index 0000000..11a24b4
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/build.properties
@@ -0,0 +1,7 @@
+bin.includes = META-INF/,\
+ plugin.xml,\
+ .,\
+ plugin.properties,\
+ styles/
+jars.compile.order = .
+source.. = src/
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.properties b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.properties
new file mode 100644
index 0000000..56cf960
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2010 John Krasnay and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# John Krasnay - initial API and implementation
+###############################################################################
+pluginName= Vex XHTML Integration
+providerName= Eclipse.org
+
+doctype.strict1=XHTML 1.0 Strict
+
+style.xhtml-plain=XHTML Plain
+style.xhtml-sans=XHTML Sans
+style.xhtml-modern=XHTML Modern
+contentType.name=XHTML
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.xml b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.xml
new file mode 100644
index 0000000..9388b1a
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/plugin.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension point="org.eclipse.core.contenttype.contentTypes">
+ <content-type id="org.eclipse.wst.xml.vex.ui.xhtml" name="%contentType.name"
+ base-type="org.eclipse.wst.xml.vex.ui.XmlDocument" file-extensions="xml, xhtml">
+ </content-type>
+ </extension>
+
+ <extension point="org.eclipse.wst.xml.vex.ui.doctypes"
+ id="xhtml_1_0_strict"
+ name="XHTML 1.0 Strict">
+ <doctype
+ publicId="-//W3C//DTD XHTML 1.0 Strict//EN"
+ systemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ outlineProvider="org.eclipse.wst.xml.vex.xhtml.XhtmlOutlineProvider" >
+ <rootElement name="html">
+ </rootElement>
+ </doctype>
+ </extension>
+ <extension id="xhtml_1_0_plain" name="XHTML Plain"
+ point="org.eclipse.wst.xml.vex.ui.styles">
+ <style css="styles/xhtml1-plain.css">
+ <doctypeRef publicId="-//W3C//DTD XHTML 1.0 Strict//EN">
+ </doctypeRef>
+ </style>
+ </extension>
+ <extension id="xhtml_1_0_sans" name="XHTML Sans"
+ point="org.eclipse.wst.xml.vex.ui.styles">
+ <style css="styles/xhtml1-sans.css">
+ <doctypeRef publicId="-//W3C//DTD XHTML 1.0 Strict//EN">
+ </doctypeRef>
+ </style>
+ </extension>
+ <extension id="xhtml_1_0_modern" name="XHTML Modern"
+ point="org.eclipse.wst.xml.vex.ui.styles">
+ <style css="styles/xhtml1-modern.css">
+ <doctypeRef publicId="-//W3C//DTD XHTML 1.0 Strict//EN">
+ </doctypeRef>
+ </style>
+ </extension>
+
+</plugin>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/src/org/eclipse/wst/xml/vex/xhtml/XhtmlOutlineProvider.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/src/org/eclipse/wst/xml/vex/xhtml/XhtmlOutlineProvider.java
new file mode 100644
index 0000000..7e6a3d8
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/src/org/eclipse/wst/xml/vex/xhtml/XhtmlOutlineProvider.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 John Krasnay and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * John Krasnay - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.vex.xhtml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXElement;
+import org.eclipse.wst.xml.vex.ui.internal.editor.VexEditor;
+import org.eclipse.wst.xml.vex.ui.internal.outline.IOutlineProvider;
+
+/**
+ * Provides an outline of the sections of an XHTML document.
+ */
+public class XhtmlOutlineProvider implements IOutlineProvider {
+
+ @Override
+ public void init(final VexEditor editor) {
+ }
+
+ @Override
+ public ITreeContentProvider getContentProvider() {
+ return contentProvider;
+ }
+
+ @Override
+ public IBaseLabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+ @Override
+ public VEXElement getOutlineElement(final VEXElement child) {
+ VEXElement element = child;
+ while (element.getParent() != null) {
+
+ // TODO: compare to all structural element names
+
+ final String name = element.getName();
+ if (name.equals("h1") || name.equals("h2") || name.equals("h3") || name.equals("h4") || name.equals("h5") || name.equals("h6"))
+ return element;
+
+ element = element.getParent();
+ }
+ return element;
+ }
+
+ //===================================================== PRIVATE
+
+ private final ITreeContentProvider contentProvider = new ITreeContentProvider() {
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
+ }
+
+ @Override
+ public Object[] getChildren(final Object parentElement) {
+ return getOutlineChildren((VEXElement) parentElement);
+ }
+
+ @Override
+ public Object getParent(final Object element) {
+ final VEXElement parent = ((VEXElement) element).getParent();
+ if (parent == null)
+ return element;
+ else
+ return getOutlineElement(parent);
+ }
+
+ @Override
+ public boolean hasChildren(final Object element) {
+ return getOutlineChildren((VEXElement) element).length > 0;
+ }
+
+ @Override
+ public Object[] getElements(final Object inputElement) {
+ final VEXDocument document = (VEXDocument) inputElement;
+ return new Object[] { document.getRootElement() };
+ }
+
+ };
+
+ /**
+ * Returns an array of the children of the given element that represent
+ * nodes in the outline. These are structural elements such as "section".
+ *
+ * @param element
+ * @return
+ */
+ private VEXElement[] getOutlineChildren(final VEXElement element) {
+ final List children = new ArrayList();
+ if (element.getParent() == null) {
+ final VEXElement body = findChild(element, "body");
+ if (body != null) {
+ final EList<VEXElement> childElements = body.getChildElements();
+
+ // First, find the lowest numbered h tag available
+ String lowH = "h6";
+ for (final VEXElement child : childElements)
+ if (isHTag(child) && child.getName().compareTo(lowH) < 0)
+ lowH = child.getName();
+
+ // Now, get all body children at that level
+ for (final VEXElement child : childElements)
+ if (child.getName().equals(lowH))
+ children.add(child);
+ }
+ } else if (isHTag(element)) {
+ // get siblings with the next lower number
+ // between this element and the next element at the same level
+ final int level = Integer.parseInt(element.getName().substring(1));
+ final String childName = "h" + (level + 1);
+ final List<VEXElement> childElements = element.getParent().getChildElements();
+ boolean foundSelf = false;
+ for (final VEXElement child : childElements)
+ if (child == element)
+ foundSelf = true;
+ else if (!foundSelf)
+ continue;
+ else if (child.getName().equals(childName))
+ children.add(child);
+ else if (child.getName().equals(element.getName()))
+ // terminate at next sibling at same level
+ break;
+ }
+ return (VEXElement[]) children.toArray(new VEXElement[children.size()]);
+ }
+
+ private final ILabelProvider labelProvider = new LabelProvider() {
+ @Override
+ public String getText(final Object o) {
+ String text;
+ final VEXElement element = (VEXElement) o;
+ if (element.getParent() == null) {
+ text = "html";
+ final VEXElement head = findChild(element, "head");
+ if (head != null) {
+ final VEXElement title = findChild(head, "title");
+ if (title != null)
+ text = title.getText();
+ }
+ } else
+ text = element.getText();
+ return text;
+ }
+ };
+
+ private VEXElement findChild(final VEXElement parent, final String childName) {
+ for (final VEXElement child : parent.getChildElements())
+ if (child.getName().equals(childName))
+ return child;
+ return null;
+ }
+
+ private boolean isHTag(final VEXElement element) {
+ final String name = element.getName();
+ return name.equals("h1") || name.equals("h2") || name.equals("h3") || name.equals("h4") || name.equals("h5") || name.equals("h6");
+ }
+
+}
\ No newline at end of file
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-modern.css b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-modern.css
new file mode 100644
index 0000000..ee7da19
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-modern.css
@@ -0,0 +1,14 @@
+
+@import url(xhtml1-plain.css);
+
+* {
+ font: 12px Verdana;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #399;
+}
+
+li {
+ margin: 6px 0;
+}
\ No newline at end of file
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-plain.css b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-plain.css
new file mode 100644
index 0000000..6b228ed
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-plain.css
@@ -0,0 +1,446 @@
+a {
+ border-bottom: 1px solid;
+ color: blue;
+}
+
+abbr {
+ /* TODO */
+}
+
+acronym {
+ /* TODO */
+}
+
+address {
+ /* TODO */
+}
+
+area {
+ /* TODO */
+}
+
+b {
+ font-weight: bold;
+}
+
+base {
+ /* TODO */
+}
+
+base:before {
+ content: "Base: ";
+}
+
+bdo {
+ /* TODO */
+}
+
+big {
+ font-size: 120%;
+}
+
+blockquote {
+ display: block;
+ margin: 20px 40px;
+}
+
+br {
+ display: block;
+}
+
+body {
+ display: block;
+ font: 16px "Times New Roman", serif;
+}
+
+button {
+ background-color: #ccc;
+ border: 1px solid black;
+ padding: 3px;
+}
+
+caption {
+ /* TODO block? */
+ font-style: italic;
+}
+
+cite {
+ /* TODO */
+}
+
+code {
+ font: 12px "Courier New", monospace;
+}
+
+col {
+ /* TODO */
+}
+
+colgroup {
+ /* TODO */
+}
+
+dd {
+ display: block;
+ margin-left: 40px;
+}
+
+del {
+ /* TODO */
+}
+
+dfn {
+ /* TODO */
+}
+
+div {
+ display: block;
+}
+
+dl {
+ display: block;
+ margin-bottom: 20px;
+}
+
+dt {
+ display: block;
+ font-weight: bold;
+ margin-top: 20px;
+}
+
+em {
+ font-style: italic;
+}
+
+fieldset {
+ /* TODO */
+}
+
+form {
+ /* TODO */
+}
+
+h1 {
+ display: block;
+ font-size: 2em;
+ font-weight: bold;
+ margin: .67em 0;
+}
+
+h2 {
+ display: block;
+ font-size: 1.5em;
+ font-weight: bold;
+ margin: .83em 0;
+}
+
+h3 {
+ display: block;
+ font-size: 1.17em;
+ font-weight: bold;
+ margin: 1em 0;
+}
+
+h4 {
+ display: block;
+ font-weight: bold;
+ margin: 1.33em 0;
+}
+
+h5 {
+ display: block;
+ font-size: 0.83em;
+ font-weight: bold;
+ margin: 1.67em 0;
+}
+
+h6 {
+ display: block;
+ font-size: 0.67em;
+ font-weight: bold;
+ margin: 2.33em 0;
+}
+
+head {
+ border: 1px solid;
+ color: #999;
+ display: block;
+ font: 14px "Arial", sans-serif;
+ margin-bottom: 10px;
+ padding: 4px;
+}
+
+hr {
+ border-top: 1px solid black;
+ display: block;
+ margin: 10px 0;
+}
+
+html {
+ background-color: white;
+ color: black;
+ display: block;
+ margin: 20px;
+}
+
+i {
+ font-style: italic;
+}
+
+img {
+}
+
+img:before {
+ background-color: #ccc;
+ content: "(img)";
+ padding: 3px;
+}
+
+input {
+ border: 1px solid black;
+ padding: 3px;
+}
+
+input:before {
+ content: "(input)";
+}
+
+ins {
+ /* TODO */
+}
+
+kbd {
+ /* TODO */
+}
+
+label {
+ /* TODO */
+}
+
+legend {
+ /* TODO */
+}
+
+li {
+ display: list-item;
+}
+
+link {
+ display: block;
+}
+
+link:before {
+ content: '(link)';
+}
+
+map {
+ /* TODO */
+}
+
+meta {
+ display: block;
+}
+
+meta:before {
+ content: '(meta)';
+}
+
+noscript {
+ /* TODO */
+}
+
+object {
+ /* TODO */
+}
+
+ol {
+ display: block;
+ list-style-type: decimal;
+ margin: 10px 40px;
+}
+
+ol ol {
+ list-style-type: lower-alpha;
+}
+
+ol ol ol {
+ list-style-type: lower-roman;
+}
+
+optgroup {
+ /* TODO */
+}
+
+option {
+ display: block;
+}
+
+p {
+ display: block;
+ margin-bottom: 10px;
+ margin-top: 10px;
+}
+
+param {
+ /* TODO */
+}
+
+pre {
+ display: block;
+ border: 1px solid #888;
+ font: 12px "Courier New", monospace;
+ margin-bottom: 10px;
+ margin-top: 10px;
+ padding: 3px;
+ white-space: pre;
+}
+
+q {
+ /* TODO */
+}
+
+samp {
+ /* TODO */
+}
+
+script {
+ background-color: #ffff66;
+ font: 12px "Courier New", monospace;
+ display: block;
+ padding: 3px;
+ white-space: pre;
+}
+
+select {
+ border: 1px solid black;
+ display: block;
+ padding: 3px;
+}
+
+select:before {
+ background-color: #ccc;
+ display: block;
+ padding: 2px;
+}
+
+small {
+ font-size: 80%;
+}
+
+span {
+ display: inline;
+}
+
+strong {
+ font-weight: bold;
+}
+
+style {
+ background-color: #ccccff;
+ color: #888;
+ display: block;
+ font: 12px "Courier New", monospace;
+ padding: 3px;
+ white-space: pre;
+}
+
+sub {
+ /* TODO */
+}
+
+sup {
+ /* TODO */
+}
+
+/* TODO review tables once they're supported by VexWidget */
+
+table {
+ background-color: #ccc;
+ display: block;
+}
+
+table:before {
+ content: "table";
+ display: block;
+ font: 10px sans-serif;
+ padding: 2px;
+}
+
+tbody {
+ display: block;
+}
+
+td {
+ display: block;
+}
+
+td, th {
+ background-color: white;
+ border-bottom: 1px dotted #ccc;
+ padding: 2px;
+}
+
+td:before {
+ background-color: #ccc;
+ content: "td";
+ font: 10px sans-serif;
+ padding: 2px;
+}
+
+textarea {
+ display: block;
+ white-space: pre;
+}
+
+tfoot {
+ display: block;
+}
+
+th {
+ display: block;
+}
+
+th:before {
+ background-color: #ccc;
+ content: "th";
+ font: 10px sans-serif;
+ margin-right: 2px;
+ padding: 2px;
+}
+
+title {
+ display: block;
+}
+
+tr {
+ display: block;
+ margin: 6px;
+}
+
+tr:before {
+ background-color: #888;
+ color: white;
+ content: "tr";
+ display: block;
+ font: 10px bold sans-serif;
+ padding: 2px;
+}
+
+title:before {
+ content: 'Title: ';
+}
+
+tt {
+ font: 12px "Courier New", sans-serif;
+}
+
+ul {
+ display: block;
+ list-item-style: disc;
+ margin: 10px 40px;
+}
+
+var {
+ /* TODO */
+}
+
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-sans.css b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-sans.css
new file mode 100644
index 0000000..40cdce7
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.xhtml/styles/xhtml1-sans.css
@@ -0,0 +1,6 @@
+
+@import url(xhtml1-plain.css);
+
+* {
+ font-family: Arial, sans-serif;
+}