[bugzilla 404624] Refactor Intent preference page to allow color
selection
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/configuration/IntentColorConstants.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/configuration/IntentColorConstants.java
index 4a886fa..75950a4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/configuration/IntentColorConstants.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/configuration/IntentColorConstants.java
@@ -10,6 +10,9 @@
  *******************************************************************************/
 package org.eclipse.mylyn.docs.intent.client.ui.editor.configuration;
 
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.mylyn.docs.intent.client.ui.IntentEditorActivator;
+import org.eclipse.mylyn.docs.intent.client.ui.preferences.IntentPreferenceConstants;
 import org.eclipse.swt.graphics.RGB;
 
 /**
@@ -24,12 +27,6 @@
 	// ----------------------------------
 	private static final RGB MU_BACKGROUND = new RGB(221, 221, 221);
 
-	private static final RGB MU_KEYWORD_FOREGROUND = new RGB(139, 10, 80);
-
-	private static final RGB MU_DEFAULT_FOREGROUND = new RGB(0, 0, 0);
-
-	private static final RGB MU_STRING_FOREGROUND = new RGB(0, 0, 180);
-
 	private static final RGB MU_DECORATION_LINE_FOREGROUND = new RGB(84, 84, 84);
 
 	private static final RGB MU_DECORATION_BACKGROUND = new RGB(195, 195, 195);
@@ -41,12 +38,6 @@
 	// ----------------------------------
 	private static final RGB DU_BACKGROUND = new RGB(255, 255, 255);
 
-	private static final RGB DU_KEYWORD_FOREGROUND = new RGB(139, 10, 80);
-
-	private static final RGB DU_DEFAULT_FOREGROUND = new RGB(0, 0, 0);
-
-	private static final RGB DU_TITLE_FOREGROUND = new RGB(0, 0, 0);
-
 	/**
 	 * IntentColorConstant constructor.
 	 */
@@ -66,15 +57,31 @@
 	}
 
 	public static RGB getDuDefaultForeground() {
-		return DU_DEFAULT_FOREGROUND;
+		return getRGBFromPreferences(IntentPreferenceConstants.DU_DEFAULT_FOREGROUND);
 	}
 
 	public static RGB getDuKeywordForeground() {
-		return DU_KEYWORD_FOREGROUND;
+		return getRGBFromPreferences(IntentPreferenceConstants.DU_KEYWORD_FOREGROUND);
 	}
 
 	public static RGB getDuTitleForeground() {
-		return DU_TITLE_FOREGROUND;
+		return getRGBFromPreferences(IntentPreferenceConstants.DU_TITLE_FOREGROUND);
+	}
+
+	public static RGB getDUListForeground() {
+		return getRGBFromPreferences(IntentPreferenceConstants.DU_LIST_FOREGROUND);
+	}
+
+	public static RGB getMuDefaultForeground() {
+		return getRGBFromPreferences(IntentPreferenceConstants.MU_DEFAULT_COLOR);
+	}
+
+	public static RGB getMuKeywordForeground() {
+		return getRGBFromPreferences(IntentPreferenceConstants.MU_KEYWORD_COLOR);
+	}
+
+	public static RGB getMuStringForeground() {
+		return getRGBFromPreferences(IntentPreferenceConstants.STRING_COLOR);
 	}
 
 	public static RGB getMuBackground() {
@@ -93,16 +100,10 @@
 		return MU_DECORATION_LINE_WIDTH;
 	}
 
-	public static RGB getMuDefaultForeground() {
-		return MU_DEFAULT_FOREGROUND;
-	}
+	private static RGB getRGBFromPreferences(String preferenceKey) {
+		return PreferenceConverter.getColor(IntentEditorActivator.getDefault().getPreferenceStore(),
+				preferenceKey);
 
-	public static RGB getMuKeywordForeground() {
-		return MU_KEYWORD_FOREGROUND;
-	}
-
-	public static RGB getMuStringForeground() {
-		return MU_STRING_FOREGROUND;
 	}
 
 }
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/scanner/IntentDescriptionUnitScanner.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/scanner/IntentDescriptionUnitScanner.java
index 83aa148..1a5d8ea 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/scanner/IntentDescriptionUnitScanner.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/scanner/IntentDescriptionUnitScanner.java
@@ -117,8 +117,9 @@
 		rules.add(new SingleLinePatternRule("-", "-", new Token(new TextAttribute(foreGroundColor, null,
 				TextAttribute.STRIKETHROUGH, IntentFontConstants.getDescriptionFont()))));
 		// Lists
-		rules.add(new EndOfLineRule("#", new Token(new TextAttribute(foreGroundColor, null, SWT.NONE)), '\\'));
-		rules.add(new EndOfLineRule("*", new Token(new TextAttribute(foreGroundColor, null, SWT.NONE,
+		Color listColor = colorManager.getColor(IntentColorConstants.getDUListForeground());
+		rules.add(new EndOfLineRule("#", new Token(new TextAttribute(listColor, null, SWT.NONE)), '\\'));
+		rules.add(new EndOfLineRule("*", new Token(new TextAttribute(listColor, null, SWT.NONE,
 				IntentFontConstants.getDescriptionFont())), '\\'));
 		// Other font decorations
 		rules.add(new SingleLinePatternRule("^", "^", new Token(new TextAttribute(foreGroundColor, null,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceConstants.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceConstants.java
index 6f33a42..dba9365 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceConstants.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceConstants.java
@@ -48,11 +48,28 @@
 	 */
 	String MATCHING_BRACKETS = "org.eclipse.mylyn.docs.intent.client.ui.preferences.matching_brackets";
 
+	/*
+	 * Colors preferences.
+	 */
 	/**
 	 * When matching brackets are displayed, specifies their color.
 	 */
 	String MATCHING_BRACKETS_COLOR = "org.eclipse.mylyn.docs.intent.client.ui.preferences.matching_brackets_color";
 
+	String MU_KEYWORD_COLOR = "org.eclipse.mylyn.docs.intent.client.ui.preferences.mu_keyword_color";
+
+	String MU_DEFAULT_COLOR = "org.eclipse.mylyn.docs.intent.client.ui.preferences.mu_default_color";
+
+	String STRING_COLOR = "org.eclipse.mylyn.docs.intent.client.ui.preferences.string_color";
+
+	String DU_KEYWORD_FOREGROUND = "org.eclipse.mylyn.docs.intent.client.ui.preferences.du_keyword_color";
+
+	String DU_DEFAULT_FOREGROUND = "org.eclipse.mylyn.docs.intent.client.ui.preferences.du_default_color";
+
+	String DU_TITLE_FOREGROUND = "org.eclipse.mylyn.docs.intent.client.ui.preferences.du_title_color";
+
+	String DU_LIST_FOREGROUND = "org.eclipse.mylyn.docs.intent.client.ui.preferences.du_list_color";
+
 	/*
 	 * Drag and drop preferences.
 	 */
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceInitializer.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceInitializer.java
index 5ecc3a1..f252158 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceInitializer.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferenceInitializer.java
@@ -27,6 +27,20 @@
 	// TODO extract to a color manager
 	private static final RGB MATCHING_BRACKET_COLOR = new RGB(192, 192, 192);
 
+	private static final RGB MU_KEYWORD_COLOR = new RGB(139, 10, 80);
+
+	private static final RGB MU_DEFAULT_COLOR = new RGB(0, 0, 0);
+
+	private static final RGB STRING_COLOR = new RGB(0, 0, 180);
+
+	private static final RGB DU_KEYWORD_COLOR = new RGB(139, 10, 80);
+
+	private static final RGB DU_DEFAULT_COLOR = new RGB(0, 0, 0);
+
+	private static final RGB DU_TITLE_COLOR = new RGB(0, 0, 0);
+
+	private static final RGB DU_LIST_COLOR = new RGB(84, 84, 84);
+
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -40,10 +54,19 @@
 		node.put(IntentPreferenceConstants.TEXT_WRAP, Boolean.TRUE.toString());
 		node.put(IntentPreferenceConstants.COLLAPSE_MODELING_UNITS, Boolean.FALSE.toString());
 		node.put(IntentPreferenceConstants.MATCHING_BRACKETS, Boolean.TRUE.toString());
-		node.put(IntentPreferenceConstants.MATCHING_BRACKETS_COLOR,
-				StringConverter.asString(MATCHING_BRACKET_COLOR));
 		node.put(IntentPreferenceConstants.SHOW_PREVIEW_PAGE, Boolean.TRUE.toString());
 		node.put(IntentPreferenceConstants.DND_DISPLAY_POP_UP, Boolean.FALSE.toString());
 		node.put(IntentPreferenceConstants.DND_USE_EXTERNAL_REFERENCES, Boolean.TRUE.toString());
+
+		// Colors
+		node.put(IntentPreferenceConstants.MATCHING_BRACKETS_COLOR,
+				StringConverter.asString(MATCHING_BRACKET_COLOR));
+		node.put(IntentPreferenceConstants.DU_DEFAULT_FOREGROUND, StringConverter.asString(DU_DEFAULT_COLOR));
+		node.put(IntentPreferenceConstants.DU_KEYWORD_FOREGROUND, StringConverter.asString(DU_KEYWORD_COLOR));
+		node.put(IntentPreferenceConstants.DU_TITLE_FOREGROUND, StringConverter.asString(DU_TITLE_COLOR));
+		node.put(IntentPreferenceConstants.DU_LIST_FOREGROUND, StringConverter.asString(DU_LIST_COLOR));
+		node.put(IntentPreferenceConstants.MU_DEFAULT_COLOR, StringConverter.asString(MU_DEFAULT_COLOR));
+		node.put(IntentPreferenceConstants.MU_KEYWORD_COLOR, StringConverter.asString(MU_KEYWORD_COLOR));
+		node.put(IntentPreferenceConstants.STRING_COLOR, StringConverter.asString(STRING_COLOR));
 	}
 }
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
index eab7ff7..304592e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
@@ -12,19 +12,46 @@
 
 import org.eclipse.jface.preference.BooleanFieldEditor;
 import org.eclipse.jface.preference.ColorFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.mylyn.docs.intent.client.ui.IntentEditorActivator;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorImpl;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.configuration.IntentEditorConfiguration;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.scanner.IntentPartitionScanner;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
 
 /**
- * The Intent preference page, allowing user to change some the Intent preferences.
+ * The Intent preference page, allowing user to change the Intent behavior and rendering.
  * 
  * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
  */
@@ -32,6 +59,8 @@
 
 	public static final String LINK_DROPPED_ELEMENTS_USING_EXTERNAL_REFERENCES = "Link dropped elements using External References";
 
+	private static final String INTENT_PREVIEW_EXAMPLE = "Section Title {\n\t Default text \n\t\"Strings\"\n\t* lists\n\t@M\n\t\tnew Element{}\n\tM@\n}";
+
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -39,78 +68,165 @@
 	 */
 	@Override
 	protected void createFieldEditors() {
+		Composite parent = getFieldEditorParent();
+		GridLayout gridLayout = new GridLayout(1, false);
+		gridLayout.marginHeight = 0;
+		gridLayout.marginWidth = 0;
+		gridLayout.verticalSpacing = 0;
+		parent.setLayout(gridLayout);
+		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+		parent.redraw();
+		TabFolder folder = new TabFolder(parent, SWT.NONE);
+		folder.setLayout(new TabFolderLayout());
+		folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
 		setPreferenceStore(IntentEditorActivator.getDefault().getPreferenceStore());
 
-		Composite parent = getFieldEditorParent();
-		if (parent.getLayout() == null) {
-			GridLayout gridLayout = new GridLayout(1, false);
-			parent.setLayout(gridLayout);
-		}
-		addUIFieds(parent);
-		addDnDFieds(parent);
-		addOtherFields(parent);
+		TabItem item = new TabItem(folder, SWT.NONE);
+		item.setText("Appearance");
+		item.setControl(createAppearancePage(folder));
+
+		item = new TabItem(folder, SWT.NONE);
+		item.setText("Colors");
+		item.setControl(createColorsPage(folder));
+
+		item = new TabItem(folder, SWT.NONE);
+		item.setText("Behavior (UI)");
+		item.setControl(createUIBehaviorPage(folder));
+
+		item = new TabItem(folder, SWT.NONE);
+		item.setText("Other");
+		item.setControl(createOtherPage(folder));
 	}
 
-	/**
-	 * Configure UI fields in the given parent composite.
-	 * 
-	 * @param parent
-	 *            the parent composite
-	 */
-	private void addUIFieds(Composite parent) {
-		// All preferences relative to UI
-		Composite uiGroup = createGroup(parent, "Intent editor");
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.TEXT_WRAP,
-				"Autowrap (line are automatically wrapped)", new Composite(uiGroup, SWT.NONE)));
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.COLLAPSE_MODELING_UNITS,
-				"Collapse ModelingUnits at editor opening", new Composite(uiGroup, SWT.NONE)));
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.MATCHING_BRACKETS, "Brackets matching",
-				new Composite(uiGroup, SWT.NONE)));
-		addField(new ColorFieldEditor(IntentPreferenceConstants.MATCHING_BRACKETS_COLOR, "Brackets color",
-				new Composite(uiGroup, SWT.NONE)));
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.SHOW_PREVIEW_PAGE,
-				"Show HTML Preview page", new Composite(uiGroup, SWT.NONE)));
+	private Control createAppearancePage(Composite parent) {
+		Composite composite = createComposite(parent);
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.TEXT_WRAP, "Autowrap",
+				"Intent editor should automatically wrap lines", composite));
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.SHOW_PREVIEW_PAGE,
+				"Show HTML Preview page",
+				"Intent editor should display a 'Preview' tab to get HTML preview of current editor",
+				composite));
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.COLLAPSE_MODELING_UNITS,
+				"Collapse ModelingUnits", "Intent editor should collapse Modeling Units at opening",
+				composite));
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.MATCHING_BRACKETS, "Brackets matching",
+				"Intent editor should match brackets", composite));
+		return composite;
+	}
 
-		// Adding a label explaining that Intent font preferences can be customized through the General >
+	private Control createColorsPage(Composite parent) {
+		Composite colorComposite = createComposite(parent);
+
+		// Add links explaining that Intent font preferences can be customized through the General >
 		// Appearance > Colors and Fonts preference page
-		Label fontInfo = new Label(uiGroup, SWT.NONE);
-		fontInfo.setText("Note: Intent fonts can be customized using the 'General>Appearance>Colors and Fonts' preference page");
+		final Link link = new Link(colorComposite, SWT.NONE);
+		link.setText("Note: Intent Font preferences can be configured through the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">'Colors and Fonts'</a> preference page.");
+		link.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				if ("org.eclipse.ui.preferencePages.ColorsAndFonts".equals(e.text)) {
+					PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null,
+							"selectFont:org.eclipse.jface.textfont");
+				}
+			}
+		});
+		final Link link2 = new Link(colorComposite, SWT.NONE);
+		link2.setText("See <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">'Text Editors'</a> for general text editor preferences.");
+		link2.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				if ("org.eclipse.ui.preferencePages.GeneralTextEditor".equals(e.text)) {
+					PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null, null);
+				}
+			}
+		});
 
+		// Create all color fields editors
+		ColorFieldEditor bracketsColor = new ColorFieldEditor(
+				IntentPreferenceConstants.MATCHING_BRACKETS_COLOR, "Brackets color", colorComposite);
+		addField(bracketsColor);
+		ColorFieldEditor stringColor = new ColorFieldEditor(IntentPreferenceConstants.STRING_COLOR,
+				"String color", colorComposite);
+		addField(stringColor);
+		ColorFieldEditor textColor = new ColorFieldEditor(IntentPreferenceConstants.DU_DEFAULT_FOREGROUND,
+				"Text color", colorComposite);
+		addField(textColor);
+		ColorFieldEditor duKeyWordColor = new ColorFieldEditor(
+				IntentPreferenceConstants.DU_KEYWORD_FOREGROUND, "Keyword color", colorComposite);
+		addField(duKeyWordColor);
+		ColorFieldEditor titleColor = new ColorFieldEditor(IntentPreferenceConstants.DU_TITLE_FOREGROUND,
+				"Title color", colorComposite);
+		addField(titleColor);
+		ColorFieldEditor listColor = new ColorFieldEditor(IntentPreferenceConstants.DU_LIST_FOREGROUND,
+				"List color", colorComposite);
+		addField(listColor);
+		ColorFieldEditor muDefaultColor = new ColorFieldEditor(IntentPreferenceConstants.MU_DEFAULT_COLOR,
+				"Modeling unit - default color", colorComposite);
+		addField(muDefaultColor);
+		ColorFieldEditor muKeywordColor = new ColorFieldEditor(IntentPreferenceConstants.MU_KEYWORD_COLOR,
+				"Modeling unit - keyword color", colorComposite);
+		addField(muKeywordColor);
+
+		// Create preview viewer
+		Label infoLabel2 = new Label(colorComposite, SWT.NONE);
+		infoLabel2.setText("Preview: ");
+		IntentEditorDocument document = createIntentPreviewViewer(colorComposite);
+
+		// Add change listener so that preview is refreshed when changing a color
+		bracketsColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		stringColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		duKeyWordColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		titleColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		listColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		muDefaultColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		muKeywordColor.getColorSelector().addListener(new RefreshPreviewEditorListener(document));
+		return colorComposite;
 	}
 
-	/**
-	 * Configure fields related to Drag and Drop in the given parent composite.
-	 * 
-	 * @param parent
-	 *            the parent composite
-	 */
-	private void addDnDFieds(Composite parent) {
-		// All preferences relative to UI
-		Composite uiGroup = createGroup(parent, "Drag and Drop Support'");
-		Label fontInfo = new Label(uiGroup, SWT.NONE);
+	private Control createUIBehaviorPage(Composite parent) {
+		Composite composite = createComposite(parent);
+
+		Composite dragAndDropGroup = createGroup(composite, "Drag and Drop Support");
+		Label fontInfo = new Label(dragAndDropGroup, SWT.NONE);
 		fontInfo.setText("These preferences allow to specify how should Intent react when dropping elements (e.g. a Java class) inside an Intent editor");
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.DND_DISPLAY_POP_UP, "Always ask",
-				new Composite(uiGroup, SWT.NONE)));
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.DND_USE_EXTERNAL_REFERENCES,
-				LINK_DROPPED_ELEMENTS_USING_EXTERNAL_REFERENCES, new Composite(uiGroup, SWT.NONE)));
+		addField(createBooleanFieldEditor(
+				IntentPreferenceConstants.DND_DISPLAY_POP_UP,
+				"Always ask",
+				"A pop-up should ask the behavior to apply. Otherwise the behavior checked below will be applied automatically.",
+				dragAndDropGroup));
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.DND_USE_EXTERNAL_REFERENCES,
+				LINK_DROPPED_ELEMENTS_USING_EXTERNAL_REFERENCES,
+				"There are 2 ways of linking dropped elements (see documentation for further details)",
+				dragAndDropGroup));
+		return composite;
+	}
+
+	private Control createOtherPage(Composite parent) {
+		Composite composite = createComposite(parent);
+
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.ACTIVATE_BACKUP,
+				"Activate back-up mechanism",
+				"Intent Documents should be backed-up in text files (only in Workspace mode)", composite));
+
+		addField(createBooleanFieldEditor(IntentPreferenceConstants.ACTIVATE_ADVANCE_LOGGING,
+				"Advanced logging", "(for Debug only) Each Intent client should log its activity", composite));
+		return composite;
 	}
 
 	/**
-	 * Configure intent other fields in the given parent composite.
+	 * Creates a composite to hold a tab of the preference page.
 	 * 
 	 * @param parent
-	 *            the parent composite
+	 *            the parent
+	 * @return a composite to hold a tab of the preference page
 	 */
-	private void addOtherFields(Composite parent) {
-		// All preferences relative to logging
-		Composite otherGroup = createGroup(parent, "Other");
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.ACTIVATE_ADVANCE_LOGGING,
-				"Advanced logging", new Composite(otherGroup, SWT.NONE)));
-		addField(new BooleanFieldEditor(IntentPreferenceConstants.ACTIVATE_BACKUP,
-				"Activate back-up mechanism", new Composite(otherGroup, SWT.NONE)));
-		Label fontInfo = new Label(otherGroup, SWT.NONE);
-		fontInfo.setText("If back-up is activated, Intent documents will be stored in text files (only in Workspace mode)");
-
+	private Composite createComposite(Composite parent) {
+		Font font = parent.getFont();
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setFont(font);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		composite.setLayout(layout);
+		return composite;
 	}
 
 	/**
@@ -136,6 +252,96 @@
 	}
 
 	/**
+	 * Creates a source viewer allowing to preview an Intent document (to see impact of color changes).
+	 * 
+	 * @param parent
+	 *            the parent of the source viewer to create
+	 * @return a source viewer allowing to preview an Intent document (to see impact of color changes)
+	 */
+	private IntentEditorDocument createIntentPreviewViewer(Composite parent) {
+		IntentEditor editor = new IntentEditorImpl();
+		IntentEditorDocument document = new IntentEditorDocument(editor);
+		IDocumentPartitioner partitioner = new FastPartitioner(new IntentPartitionScanner(),
+				IntentPartitionScanner.LEGAL_CONTENT_TYPES);
+		partitioner.connect(document);
+		document.setDocumentPartitioner(partitioner);
+
+		IntentEditorConfiguration viewerConfiguration = new IntentEditorConfiguration(editor, null);
+		int styles = SWT.V_SCROLL;
+		styles |= SWT.H_SCROLL;
+		styles |= SWT.MULTI;
+		styles |= SWT.BORDER;
+		styles |= SWT.FULL_SELECTION;
+		new Label(parent, SWT.NONE);
+		SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, styles);
+		StyledText styledText = sourceViewer.getTextWidget();
+		styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+		sourceViewer.configure(viewerConfiguration);
+		sourceViewer.setEditable(false);
+		Cursor arrowCursor = sourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
+		sourceViewer.getTextWidget().setCursor(arrowCursor);
+		sourceViewer.getTextWidget().setCaret(null);
+		sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());
+		sourceViewer.setDocument(document);
+		document.set(INTENT_PREVIEW_EXAMPLE);
+		return document;
+	}
+
+	/**
+	 * Creates a boolean field editor allowing to change the preference with the given id.
+	 * 
+	 * @param preferenceID
+	 *            the preference ID
+	 * @param text
+	 *            the text to display
+	 * @param a
+	 *            detailled explanation about the preference
+	 * @param composite
+	 *            the parent composite
+	 * @return a boolean field editor allowing to change the preference with the given id
+	 */
+	private FieldEditor createBooleanFieldEditor(String preferenceID, String text, String explanations,
+			Composite composite) {
+		BooleanFieldEditor booleanFieldEditor = new BooleanFieldEditor(preferenceID, text, new Composite(
+				composite, SWT.NONE)) {
+			private Label labelControl;
+
+			@Override
+			public Label getLabelControl(Composite parent) {
+				if (labelControl == null) {
+					labelControl = super.getLabelControl(parent);
+					FontData fontData = labelControl.getFont().getFontData()[0];
+					Font font = new Font(Display.getCurrent(), new FontData(fontData.getName(),
+							fontData.getHeight(), SWT.BOLD));
+					labelControl.setFont(font);
+				}
+				return labelControl;
+			}
+		};
+		createLabel(composite, explanations);
+		return booleanFieldEditor;
+	}
+
+	/**
+	 * Creates a label on the given composite with the given text.
+	 * 
+	 * @param composite
+	 *            the composite
+	 * @param text
+	 *            the label text
+	 * @return a label on the given composite with the given text
+	 */
+	private Label createLabel(Composite composite, String text) {
+		Label label = new Label(composite, SWT.RIGHT);
+		label.setText("- " + text);
+		FontData fontData = label.getFont().getFontData()[0];
+		Font font = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(),
+				SWT.ITALIC));
+		label.setFont(font);
+		return label;
+	}
+
+	/**
 	 * {@inheritDoc}
 	 * 
 	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
@@ -144,4 +350,68 @@
 
 	}
 
+	public class TabFolderLayout extends Layout {
+
+		protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+			if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
+				return new Point(wHint, hHint);
+
+			Control[] children = composite.getChildren();
+			int count = children.length;
+			int maxWidth = 0, maxHeight = 0;
+			for (int i = 0; i < count; i++) {
+				Control child = children[i];
+				Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+				maxWidth = Math.max(maxWidth, pt.x);
+				maxHeight = Math.max(maxHeight, pt.y);
+			}
+
+			if (wHint != SWT.DEFAULT)
+				maxWidth = wHint;
+			if (hHint != SWT.DEFAULT)
+				maxHeight = hHint;
+
+			return new Point(maxWidth, maxHeight);
+
+		}
+
+		protected void layout(Composite composite, boolean flushCache) {
+			Rectangle rect = composite.getClientArea();
+
+			Control[] children = composite.getChildren();
+			for (int i = 0; i < children.length; i++) {
+				children[i].setBounds(rect);
+			}
+		}
+	}
+
+	/**
+	 * An {@link IPropertyChangeListener} that refreshes the preview viewer.
+	 * 
+	 * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+	 */
+	private class RefreshPreviewEditorListener implements IPropertyChangeListener {
+
+		private IntentEditorDocument document;
+
+		/**
+		 * Constructor.
+		 * 
+		 * @param viewer
+		 *            the preview Viewer to refresh
+		 */
+		public RefreshPreviewEditorListener(IntentEditorDocument document) {
+			this.document = document;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+		 */
+		public void propertyChange(PropertyChangeEvent event) {
+			// TODO REFRESH PREVIEW VIEW
+		}
+
+	}
 }