bug 514337 - [CSS] Support table header styling in our CSS engine

* adds new css Properties for table header styling:
** "swt-table-header-color"
** "swt-table-header-background-color"

Change-Id: I5bd1f3623ffb0c9ca32a025858c5f729e2a8dceb
Signed-off-by: Fabian Pfaff <fabian.pfaff@vogella.com>
diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
index 01efbb7..d565f61 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
+++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
@@ -538,6 +538,16 @@
          </property-name>
       </handler>
       <handler
+            adapter="org.eclipse.e4.ui.css.swt.dom.TableElement"
+            handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyTableHeaderHandler">
+         <property-name
+               name="swt-table-header-color">
+         </property-name>
+         <property-name
+               name="swt-table-header-background-color">
+         </property-name>
+      </handler>
+      <handler
             adapter="org.eclipse.e4.ui.css.swt.dom.StyledTextElement"
             handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyStyledTextScrollbarSWTHandler">
          <property-name
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/dom/TableElement.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/dom/TableElement.java
index b4741d8..2bafab1 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/dom/TableElement.java
+++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/dom/TableElement.java
@@ -108,4 +108,16 @@
 		this.fControlSelectedColorCustomization.setSelectionForegroundColor(color);
 	}
 
+	public void setTableHeaderColor(Color color) {
+		getTable().setHeaderForeground(color);
+	}
+
+	public void setTableHeaderBackgroundColor(Color color) {
+		getTable().setHeaderBackground(color);
+	}
+
+	public Table getTable() {
+		return (Table) getNativeWidget();
+	}
+
 }
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTableHeaderHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTableHeaderHandler.java
new file mode 100644
index 0000000..9ebf9b7
--- /dev/null
+++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTableHeaderHandler.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Fabian Pfaff 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:
+ *     Fabian Pfaff <fabian.pfaff@vogella.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.ui.css.swt.properties.custom;
+
+import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.swt.dom.TableElement;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Table;
+import org.w3c.dom.css.CSSValue;
+
+/**
+ * A handler which allows the styling of table headers.
+ */
+public class CSSPropertyTableHeaderHandler implements ICSSPropertyHandler {
+
+	private static final String SWT_TABLE_HEADER_COLOR = "swt-table-header-color"; //$NON-NLS-1$
+	private static final String SWT_TABLE_HEADER_BACKGROUND_COLOR = "swt-table-header-background-color"; //$NON-NLS-1$
+
+	@Override
+	public boolean applyCSSProperty(Object element, String property, CSSValue value, String pseudo, CSSEngine engine)
+			throws Exception {
+		if (!(element instanceof TableElement)) {
+			return false;
+		}
+		TableElement tableElement = (TableElement) element;
+		Table table = (Table) tableElement.getNativeWidget();
+		if (SWT_TABLE_HEADER_COLOR.equals(property)
+				&& value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+			Color newColor = (Color) engine.convert(value, Color.class, table.getDisplay());
+			tableElement.setTableHeaderColor(newColor);
+		} else if (SWT_TABLE_HEADER_BACKGROUND_COLOR.equals(property)
+				&& value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+			Color newColor = (Color) engine.convert(value, Color.class, table.getDisplay());
+			tableElement.setTableHeaderBackgroundColor(newColor);
+		} else {
+			return false;
+		}
+		return true;
+	}
+
+	@Override
+	public String retrieveCSSProperty(Object element, String property, String pseudo, CSSEngine engine)
+			throws Exception {
+		return null;
+	}
+
+}