Working on preference page for setting the terminal's background and
foreground colors.
diff --git a/com.google.eclipse.terminal.local/META-INF/MANIFEST.MF b/com.google.eclipse.terminal.local/META-INF/MANIFEST.MF
index 54a9e3c..7e7e3ef 100644
--- a/com.google.eclipse.terminal.local/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.terminal.local/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@
  org.eclipse.core.runtime,
  com.google.eclipse.tm.terminal,
  com.google.eclipse.cdt.core,
- org.eclipse.debug.core;bundle-version="3.7.1"
+ org.eclipse.debug.core;bundle-version="3.7.1",
+ org.eclipse.jface.text
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
diff --git a/com.google.eclipse.terminal.local/plugin.xml b/com.google.eclipse.terminal.local/plugin.xml
index cbbeccd..cd9aea9 100644
--- a/com.google.eclipse.terminal.local/plugin.xml
+++ b/com.google.eclipse.terminal.local/plugin.xml
@@ -41,5 +41,13 @@
          </action>
       </objectContribution>
    </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            class="com.google.eclipse.terminal.local.ui.preferences.ColorsPreferencePage"
+            id="com.google.eclipse.terminal.local.colors"
+            name="Colors">
+      </page>
+   </extension>
 
 </plugin>
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorSettingPreviewText.txt b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorSettingPreviewText.txt
new file mode 100644
index 0000000..b434966
--- /dev/null
+++ b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorSettingPreviewText.txt
@@ -0,0 +1,8 @@
+$ mkdir ~/Hello-World
+$ cd ~/Hello-World
+$ git init
+$ touch README
+$ git add README
+$ git commit -m 'first commit'
+$ git remote add origin https://code.google.com/p/elt/
+$ git push -u origin master
\ No newline at end of file
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorsPreferencePage.java b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorsPreferencePage.java
new file mode 100644
index 0000000..1f79486
--- /dev/null
+++ b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/preferences/ColorsPreferencePage.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * 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
+ */
+package com.google.eclipse.terminal.local.ui.preferences;
+
+import static com.google.eclipse.terminal.local.Activator.log;
+import static org.eclipse.jface.preference.ColorSelector.PROP_COLORCHANGE;
+import static org.eclipse.swt.SWT.*;
+
+import java.util.Scanner;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.util.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.*;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ColorsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+  private ProjectionViewer previewer;
+  private ColorSelector foregroundColorSelector;
+  private ColorSelector backgroundColorSelector;
+
+  public ColorsPreferencePage() {
+  }
+
+  @Override public void init(IWorkbench workbench) {
+  }
+
+  @Override protected Control createContents(Composite parent) {
+    Composite contents = new Composite(parent, NONE);
+    contents.setLayout(new GridLayout(1, false));
+    Label lblDescription = new Label(contents, SWT.NONE);
+    lblDescription.setText("Local terminal color preferences.");
+    new Label(contents, SWT.NONE);
+    Composite controls = new Composite(contents, SWT.NONE);
+    controls.setLayout(new GridLayout(2, false));
+    Label lblBackground = new Label(controls, SWT.NONE);
+    lblBackground.setText("Background:");
+    backgroundColorSelector = new ColorSelector(controls);
+    Label lblForeground = new Label(controls, SWT.NONE);
+    lblForeground.setText("Foreground:");
+    foregroundColorSelector = new ColorSelector(controls);
+    new Label(contents, SWT.NONE);
+    Label lblPreview = new Label(contents, SWT.NONE);
+    lblPreview.setText("Preview:");
+    previewer = new ProjectionViewer(contents, null, null, false, V_SCROLL | H_SCROLL);
+    previewer.setEditable(false);
+    previewer.setDocument(new Document(loadContentsFrom("ColorSettingPreviewText.txt")));
+    StyledText previewerText = previewer.getTextWidget();
+    previewerText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+    Cursor arrowCursor = previewerText.getDisplay().getSystemCursor(CURSOR_ARROW);
+    previewerText.setCursor(arrowCursor);
+    Display display = getShell().getDisplay();
+    backgroundColorSelector.addListener(new ColorChangeListener(display) {
+      @Override void updateColor(Color color) {
+        previewer.getTextWidget().setBackground(color);
+      }
+    });
+    foregroundColorSelector.addListener(new ColorChangeListener(display) {
+      @Override void updateColor(Color color) {
+        previewer.setTextColor(color);
+      }
+    });
+    return contents;
+  }
+
+  private String loadContentsFrom(String fileName) {
+    String lineSeparator = System.getProperty("line.separator");
+    StringBuilder buffer = new StringBuilder();
+    Scanner scanner = null;
+    try {
+      scanner = new Scanner(getClass().getResourceAsStream(fileName));
+      while (scanner.hasNextLine()) {
+        String line = scanner.nextLine();
+        buffer.append(line).append(lineSeparator);
+      }
+    } catch (RuntimeException e) {
+      log("Unable to load preview content", e);
+    } finally {
+      if (scanner != null) {
+        scanner.close();
+      }
+    }
+    return buffer.toString();
+  }
+
+  private static abstract class ColorChangeListener implements IPropertyChangeListener {
+    private final Device device;
+
+    private ColorChangeListener(Device device) {
+      this.device = device;
+    }
+
+    @Override public final void propertyChange(PropertyChangeEvent event) {
+      if (PROP_COLORCHANGE.equals(event.getProperty())) {
+        RGB rgb = (RGB) event.getNewValue();
+        updateColor(new Color(device, rgb));
+      }
+    }
+
+    abstract void updateColor(Color color);
+  }
+}