Bug 62403 - Create separate Code Assist page
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntCodeAssistPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntCodeAssistPreferencePage.java
index d131f0d..e468ffb 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntCodeAssistPreferencePage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntCodeAssistPreferencePage.java
@@ -134,7 +134,7 @@
 		stylesComposite.setFont(font);
 		
 		label= new Label(stylesComposite, SWT.LEFT);
-		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.Col&or__6")); //$NON-NLS-1$
+		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.6")); //$NON-NLS-1$
 		label.setFont(font);
 		gd= new GridData();
 		gd.horizontalAlignment= GridData.BEGINNING;
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
index 76880af..4c8aefe 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
@@ -10,14 +10,36 @@
  *******************************************************************************/
 package org.eclipse.ant.internal.ui.preferences;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 
+import org.eclipse.ant.internal.ui.editor.AbstractAntSourceViewerConfiguration;
+import org.eclipse.ant.internal.ui.editor.templates.AntTemplateViewerConfiguration;
+import org.eclipse.ant.internal.ui.editor.text.AntDocumentSetupParticipant;
 import org.eclipse.ant.internal.ui.editor.text.IAntEditorColorConstants;
+import org.eclipse.ant.internal.ui.model.AntUIPlugin;
 import org.eclipse.ant.internal.ui.model.IAntUIHelpContextIds;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.GridData;
@@ -25,33 +47,177 @@
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.List;
 import org.eclipse.swt.widgets.TabFolder;
 import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.editors.text.EditorsUI;
 import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.model.WorkbenchViewerSorter;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
 
 /*
  * The page for setting the editor options.
  */
 public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage {
+	
+	/**
+	 * Item in the highlighting color list.
+	 * 
+	 * @since 3.0
+	 */
+	private class HighlightingColorListItem {
+		/** Display name */
+		private String fDisplayName;
+		/** Color preference key */
+		private String fColorKey;
+		/** Bold preference key */
+		private String fBoldKey;
+		/** Italic preference key */
+		private String fItalicKey;
+		/** Item color */
+		private Color fItemColor;
 		
+		/**
+		 * Initialize the item with the given values.
+		 * 
+		 * @param displayName the display name
+		 * @param colorKey the color preference key
+		 * @param boldKey the bold preference key
+		 * @param italicKey the italic preference key
+		 * @param itemColor the item color
+		 */
+		public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, Color itemColor) {
+			fDisplayName= displayName;
+			fColorKey= colorKey;
+			fBoldKey= boldKey;
+			fItalicKey= italicKey;
+			fItemColor= itemColor;
+		}
+		
+		/**
+		 * @return the bold preference key
+		 */
+		public String getBoldKey() {
+			return fBoldKey;
+		}
+		
+		/**
+		 * @return the bold preference key
+		 */
+		public String getItalicKey() {
+			return fItalicKey;
+		}
+		
+		/**
+		 * @return the color preference key
+		 */
+		public String getColorKey() {
+			return fColorKey;
+		}
+		
+		/**
+		 * @return the display name
+		 */
+		public String getDisplayName() {
+			return fDisplayName;
+		}
+		
+		/**
+		 * @return the item color
+		 */
+		public Color getItemColor() {
+			return fItemColor;
+		}
+	}
+	
+	/**
+	 * Color list label provider.
+	 * 
+	 * @since 3.0
+	 */
+	private class ColorListLabelProvider extends LabelProvider implements IColorProvider {
+
+		/*
+		 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+		 */
+		public String getText(Object element) {
+			return ((HighlightingColorListItem)element).getDisplayName();
+		}
+		
+		/*
+		 * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+		 */
+		public Color getForeground(Object element) {
+			return ((HighlightingColorListItem)element).getItemColor();
+		}
+
+		/*
+		 * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+		 */
+		public Color getBackground(Object element) {
+			return null;
+		}
+	}
+	
+	/**
+	 * Color list content provider.
+	 * 
+	 * @since 3.0
+	 */
+	private class ColorListContentProvider implements IStructuredContentProvider {
+
+		/*
+		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+		 */
+		public Object[] getElements(Object inputElement) {
+			return ((java.util.List)inputElement).toArray();
+		}
+
+		/*
+		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+		 */
+		public void dispose() {
+		}
+
+		/*
+		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+		 */
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		}
+	}
+	
+	/** The keys of the overlay store. */
+	private String[][] fSyntaxColorListModel;
+	
 	private final String[][] fAppearanceColorListModel= new String[][] {
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.lineNumberForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.currentLineHighlighColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.printMarginColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_text_1"), IAntEditorColorConstants.TEXT_COLOR, null}, //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_processing_instuctions_2"),  IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR, null}, //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_constant_strings_3"),  IAntEditorColorConstants.STRING_COLOR, null},  //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_tags_4"),    IAntEditorColorConstants.TAG_COLOR, null},  //$NON-NLS-1$
-		{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_comments_5"), IAntEditorColorConstants.XML_COMMENT_COLOR, null} //$NON-NLS-1$
+		{AntPreferencesMessages.getString("AntEditorPreferencePage.lineNumberForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, null}, //$NON-NLS-1$
+		{AntPreferencesMessages.getString("AntEditorPreferencePage.currentLineHighlighColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, null}, //$NON-NLS-1$
+		{AntPreferencesMessages.getString("AntEditorPreferencePage.printMarginColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, null}, //$NON-NLS-1$
+		{AntPreferencesMessages.getString("AntEditorPreferencePage.41"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR}, //$NON-NLS-1$
+		{AntPreferencesMessages.getString("AntEditorPreferencePage.42"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR}, //$NON-NLS-1$
 	};
 	
 	private List fAppearanceColorList;
 	
 	private ColorEditor fAppearanceColorEditor;
+	private Button fAppearanceColorDefault;
+	private ColorEditor fSyntaxForegroundColorEditor;
+	private ColorEditor fBackgroundColorEditor;
+	private Button fBackgroundDefaultRadioButton;
+	private Button fBackgroundCustomRadioButton;
+	private Button fBackgroundColorButton;
+	private Button fBoldCheckBox;
+	private Button fItalicCheckBox;
+	
+	private TableViewer fHighlightingColorListViewer;
+	private final java.util.List fHighlightingColorList= new ArrayList(5);
+	
+	private SourceViewer fPreviewViewer;
+	private AntPreviewerUpdater fPreviewerUpdater;
 	
 	public AntEditorPreferencePage() {
 		super();
@@ -59,8 +225,24 @@
 	}
 	
 	protected OverlayPreferenceStore createOverlayStore() {
-		
+		fSyntaxColorListModel= new String[][] {
+				{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_text_1"), IAntEditorColorConstants.TEXT_COLOR, null}, //$NON-NLS-1$
+				{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_processing_instuctions_2"),  IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR, null}, //$NON-NLS-1$
+				{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_constant_strings_3"),  IAntEditorColorConstants.STRING_COLOR, null},  //$NON-NLS-1$
+				{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_tags_4"),    IAntEditorColorConstants.TAG_COLOR, null},  //$NON-NLS-1$
+				{AntPreferencesMessages.getString("AntEditorPreferencePage.Ant_editor_comments_5"), IAntEditorColorConstants.XML_COMMENT_COLOR, null} //$NON-NLS-1$
+			};
 		ArrayList overlayKeys= new ArrayList();
+		
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND));
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT));
+		
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR));
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR));
+
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR));
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR));
+
 
 		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
 		
@@ -90,22 +272,41 @@
 		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AntEditorPreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));		
 		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AntEditorPreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS));
 	
-		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IAntEditorColorConstants.TEXT_COLOR));
-		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR));
-		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IAntEditorColorConstants.STRING_COLOR));
-		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IAntEditorColorConstants.TAG_COLOR));
-		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IAntEditorColorConstants.XML_COMMENT_COLOR));
-
+		for (int i= 0; i < fSyntaxColorListModel.length; i++) {
+			String colorKey= fSyntaxColorListModel[i][1];
+			addTextKeyToCover(overlayKeys, colorKey);
+		}
+		
 		OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
 		overlayKeys.toArray(keys);
 		return new OverlayPreferenceStore(getPreferenceStore(), keys);
 	}
 
+	private void addTextKeyToCover(ArrayList overlayKeys, String mainKey) {
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey));
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX));
+		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX));
+	}
+	
 	private void handleAppearanceColorListSelection() {	
 		int i= fAppearanceColorList.getSelectionIndex();
 		String key= fAppearanceColorListModel[i][1];
 		RGB rgb= PreferenceConverter.getColor(getOverlayStore(), key);
-		fAppearanceColorEditor.setColorValue(rgb);		
+		fAppearanceColorEditor.setColorValue(rgb);	
+		updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]);
+	}
+	
+	private void updateAppearanceColorWidgets(String systemDefaultKey) {
+		if (systemDefaultKey == null) {
+			fAppearanceColorDefault.setSelection(false);
+			fAppearanceColorDefault.setVisible(false);
+			fAppearanceColorEditor.getButton().setEnabled(true);
+		} else {
+			boolean systemDefault= getOverlayStore().getBoolean(systemDefaultKey);
+			fAppearanceColorDefault.setSelection(systemDefault);
+			fAppearanceColorDefault.setVisible(true);
+			fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
+		}
 	}
 	
 	private Control createAppearancePage(Composite parent) {
@@ -169,7 +370,7 @@
 		fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
 		fAppearanceColorList.setFont(font);
 		gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
-		gd.heightHint= convertHeightInCharsToPixels(8);
+		gd.heightHint= convertHeightInCharsToPixels(6);
 		fAppearanceColorList.setLayoutData(gd);
 						
 		Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
@@ -183,7 +384,7 @@
 		
 		label= new Label(stylesComposite, SWT.LEFT);
 		label.setFont(font);
-		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.color")); //$NON-NLS-1$
+		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.6")); //$NON-NLS-1$
 		gd= new GridData();
 		gd.horizontalAlignment= GridData.BEGINNING;
 		label.setLayoutData(gd);
@@ -203,6 +404,29 @@
 				handleAppearanceColorListSelection();
 			}
 		});
+		
+		SelectionListener colorDefaultSelectionListener= new SelectionListener() {
+			public void widgetSelected(SelectionEvent e) {
+				boolean systemDefault= fAppearanceColorDefault.getSelection();
+				fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
+				
+				int i= fAppearanceColorList.getSelectionIndex();
+				String key= fAppearanceColorListModel[i][2];
+				if (key != null)
+					getOverlayStore().setValue(key, systemDefault);
+			}
+			public void widgetDefaultSelected(SelectionEvent e) {}
+		};
+		
+		fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
+		fAppearanceColorDefault.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.0")); //$NON-NLS-1$
+		gd= new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalAlignment= GridData.BEGINNING;
+		gd.horizontalSpan= 2;
+		fAppearanceColorDefault.setLayoutData(gd);
+		fAppearanceColorDefault.setVisible(false);
+		fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
+		
 		foregroundColorButton.addSelectionListener(new SelectionListener() {
 			public void widgetDefaultSelected(SelectionEvent e) {
 				// do nothing
@@ -221,7 +445,7 @@
 	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
 	 */
 	protected Control createContents(Composite parent) {
-
+		initializeDefaultColors();
 		WorkbenchHelp.setHelp(getControl(), IAntUIHelpContextIds.ANT_EDITOR_PREFERENCE_PAGE);
 		getOverlayStore().load();
 		getOverlayStore().start();
@@ -233,6 +457,10 @@
 		TabItem item= new TabItem(folder, SWT.NONE);
 		item.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.general")); //$NON-NLS-1$
 		item.setControl(createAppearancePage(folder));
+		
+		item= new TabItem(folder, SWT.NONE);
+		item.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.1")); //$NON-NLS-1$
+		item.setControl(createSyntaxPage(folder));
 					
 		initialize();
 		
@@ -240,10 +468,42 @@
 		return folder;
 	}
 	
+	private void initializeDefaultColors() {	
+		if (!getPreferenceStore().contains(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
+			RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
+			PreferenceConverter.setDefault(getOverlayStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, rgb);
+			PreferenceConverter.setDefault(getPreferenceStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, rgb);
+		}
+		if (!getPreferenceStore().contains(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND)) {
+			RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
+			PreferenceConverter.setDefault(getOverlayStore(), AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, rgb);
+			PreferenceConverter.setDefault(getPreferenceStore(), AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, rgb);
+		}
+		if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR)) {
+			RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB();
+			PreferenceConverter.setDefault(getOverlayStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb);
+			PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb);
+		}
+		if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR)) {
+			RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).getRGB();
+			PreferenceConverter.setDefault(getOverlayStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb);
+			PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb);
+		}
+	}
+	
 	private void initialize() {
 		
 		initializeFields();
 		
+		for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) {
+			fHighlightingColorList.add(
+				new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1],
+						fSyntaxColorListModel[i][1] + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, 
+						fSyntaxColorListModel[i][1] + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null));
+		}
+		fHighlightingColorListViewer.setInput(fHighlightingColorList);
+		fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0)));
+		
 		for (int i= 0; i < fAppearanceColorListModel.length; i++) {
 			fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
 		}
@@ -255,12 +515,244 @@
 				}
 			}
 		});
+		
+		initializeBackgroundColorFields();
 	}
 	
+	/**
+	 * 
+	 */
+	private void initializeBackgroundColorFields() {
+		RGB rgb= PreferenceConverter.getColor(getOverlayStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+		fBackgroundColorEditor.setColorValue(rgb);		
+		
+		boolean dflt= getOverlayStore().getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+		fBackgroundDefaultRadioButton.setSelection(dflt);
+		fBackgroundCustomRadioButton.setSelection(!dflt);
+		fBackgroundColorButton.setEnabled(!dflt);
+	}
+
 	/* (non-Javadoc)
 	 * @see org.eclipse.ant.internal.ui.preferences.AbstractAntEditorPreferencePage#handleDefaults()
 	 */
 	protected void handleDefaults() {
 		handleAppearanceColorListSelection();
+		handleSyntaxColorListSelection();
+		initializeBackgroundColorFields();
+	}
+	
+	private Control createSyntaxPage(Composite parent) {
+		
+		Composite colorComposite= new Composite(parent, SWT.NONE);
+		colorComposite.setLayout(new GridLayout());
+
+		Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
+		GridLayout layout= new GridLayout();
+		layout.numColumns= 3;
+		backgroundComposite.setLayout(layout);
+		backgroundComposite.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.2")); //$NON-NLS-1$
+	
+		SelectionListener backgroundSelectionListener= new SelectionListener() {
+			public void widgetSelected(SelectionEvent e) {				
+				boolean custom= fBackgroundCustomRadioButton.getSelection();
+				fBackgroundColorButton.setEnabled(custom);
+				getOverlayStore().setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, !custom);
+			}
+			public void widgetDefaultSelected(SelectionEvent e) {}
+		};
+
+		fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
+		fBackgroundDefaultRadioButton.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.3")); //$NON-NLS-1$
+		fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
+
+		fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
+		fBackgroundCustomRadioButton.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.4")); //$NON-NLS-1$
+		fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
+		
+		fBackgroundColorEditor= new ColorEditor(backgroundComposite);
+		fBackgroundColorButton= fBackgroundColorEditor.getButton();
+		
+		Label label= new Label(colorComposite, SWT.LEFT);
+		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.5")); //$NON-NLS-1$
+		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		Composite editorComposite= new Composite(colorComposite, SWT.NONE);
+		layout= new GridLayout();
+		layout.numColumns= 2;
+		layout.marginHeight= 0;
+		layout.marginWidth= 0;
+		editorComposite.setLayout(layout);
+		GridData gd= new GridData(GridData.FILL_BOTH);
+		editorComposite.setLayoutData(gd);		
+
+		fHighlightingColorListViewer= new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
+		fHighlightingColorListViewer.setLabelProvider(new ColorListLabelProvider());
+		fHighlightingColorListViewer.setContentProvider(new ColorListContentProvider());
+		fHighlightingColorListViewer.setSorter(new WorkbenchViewerSorter());
+		gd= new GridData(GridData.FILL_BOTH);
+		gd.heightHint= convertHeightInCharsToPixels(5);
+		fHighlightingColorListViewer.getControl().setLayoutData(gd);
+						
+		Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
+		layout= new GridLayout();
+		layout.marginHeight= 0;
+		layout.marginWidth= 0;
+		layout.numColumns= 2;
+		stylesComposite.setLayout(layout);
+		stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		label= new Label(stylesComposite, SWT.LEFT);
+		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.6")); //$NON-NLS-1$
+		gd= new GridData();
+		gd.horizontalAlignment= GridData.BEGINNING;
+		label.setLayoutData(gd);
+
+		fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite);
+		Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
+		gd= new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalAlignment= GridData.BEGINNING;
+		foregroundColorButton.setLayoutData(gd);
+		
+		fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
+		fBoldCheckBox.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.7")); //$NON-NLS-1$
+		gd= new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalAlignment= GridData.BEGINNING;
+		gd.horizontalSpan= 2;
+		fBoldCheckBox.setLayoutData(gd);
+		
+		fItalicCheckBox= new Button(stylesComposite, SWT.CHECK);
+		fItalicCheckBox.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.8")); //$NON-NLS-1$
+		gd= new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalAlignment= GridData.BEGINNING;
+		gd.horizontalSpan= 2;
+		fItalicCheckBox.setLayoutData(gd);
+		
+		label= new Label(colorComposite, SWT.LEFT);
+		label.setText(AntPreferencesMessages.getString("AntEditorPreferencePage.9")); //$NON-NLS-1$
+		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		
+		Control previewer= createPreviewer(colorComposite);
+		gd= new GridData(GridData.FILL_BOTH);
+		gd.widthHint= convertWidthInCharsToPixels(20);
+		gd.heightHint= convertHeightInCharsToPixels(5);
+		previewer.setLayoutData(gd);
+
+		fHighlightingColorListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				handleSyntaxColorListSelection();
+			}
+		});
+		
+		foregroundColorButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				HighlightingColorListItem item= getHighlightingColorListItem();
+				PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
+			}
+		});
+
+		fBackgroundColorButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				PreferenceConverter.setValue(getOverlayStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, fBackgroundColorEditor.getColorValue());					
+			}
+		});
+
+		fBoldCheckBox.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				HighlightingColorListItem item= getHighlightingColorListItem();
+				getOverlayStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection());
+			}
+		});
+				
+		fItalicCheckBox.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				HighlightingColorListItem item= getHighlightingColorListItem();
+				getOverlayStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection());
+			}
+		});
+				
+		return colorComposite;
+	}
+	
+	private Control createPreviewer(Composite parent) {
+		fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+        
+		AbstractAntSourceViewerConfiguration configuration = new AntTemplateViewerConfiguration();        
+	
+		fPreviewViewer.configure(configuration);
+		fPreviewViewer.setEditable(false);	
+		Font font= JFaceResources.getFont(JFaceResources.TEXT_FONT);
+		fPreviewViewer.getTextWidget().setFont(font);    
+		
+		IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() });
+		fPreviewerUpdater= new AntPreviewerUpdater(fPreviewViewer, configuration, store);
+		
+		String content= loadPreviewContentFromFile("SyntaxPreviewCode.txt"); //$NON-NLS-1$
+		IDocument document = new Document(content);       
+		new AntDocumentSetupParticipant().setup(document);
+		fPreviewViewer.setDocument(document);
+		
+		return fPreviewViewer.getControl();
+	}
+	
+	private void handleSyntaxColorListSelection() {
+		HighlightingColorListItem item= getHighlightingColorListItem();
+		RGB rgb= PreferenceConverter.getColor(getOverlayStore(), item.getColorKey());
+		fSyntaxForegroundColorEditor.setColorValue(rgb);		
+		fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey()));
+		fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey()));
+	}
+	
+	/**
+	 * Returns the current highlighting color list item.
+	 * 
+	 * @return the current highlighting color list item
+	 * @since 3.0
+	 */
+	private HighlightingColorListItem getHighlightingColorListItem() {
+		IStructuredSelection selection= (IStructuredSelection) fHighlightingColorListViewer.getSelection();
+		return (HighlightingColorListItem) selection.getFirstElement();
+	}
+	
+	private String loadPreviewContentFromFile(String filename) {
+		String line;
+		String separator= System.getProperty("line.separator"); //$NON-NLS-1$
+		StringBuffer buffer= new StringBuffer(512);
+		BufferedReader reader= null;
+		try {
+			reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+			while ((line= reader.readLine()) != null) {
+				buffer.append(line);
+				buffer.append(separator);
+			}
+		} catch (IOException io) {
+			AntUIPlugin.log(io);
+		} finally {
+			if (reader != null) {
+				try { reader.close(); } catch (IOException e) {}
+			}
+		}
+		return buffer.toString();
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+	 */
+	public void dispose() {
+		super.dispose();
+		if (fPreviewerUpdater != null) {
+			fPreviewerUpdater.dispose();
+		}
 	}
 }
\ No newline at end of file