Bug 538862: Add support for HTML formatted descriptions of editor
template variables

  - Add support for HTML descriptions by Eclipse Platform
  - Convert description of template variables by LTK to HTML

Change-Id: I626a96806c4e5872a3eb212eaa4facdce83b6c00
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/templates/TemplateVariableProposal.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/templates/TemplateVariableProposal.java
index d1c7d19..35d0564 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/templates/TemplateVariableProposal.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ecommons/templates/TemplateVariableProposal.java
@@ -32,12 +32,12 @@
 public final class TemplateVariableProposal implements ICompletionProposal {
 	
 	
-	private final TemplateVariableResolver fVariable;
-	private final int fOffset;
-	private final int fLength;
-	private final ITextViewer fViewer;
+	private final TemplateVariableResolver variable;
+	private final int offset;
+	private final int length;
+	private final ITextViewer viewer;
 	
-	private Point fSelection;
+	private Point selection;
 	
 	
 	/**
@@ -49,39 +49,39 @@
 	 * @param viewer the viewer
 	 */
 	public TemplateVariableProposal(final TemplateVariableResolver variable, final int offset, final int length, final ITextViewer viewer) {
-		this.fVariable= variable;
-		this.fOffset= offset;
-		this.fLength= length;
-		this.fViewer= viewer;
+		this.variable= variable;
+		this.offset= offset;
+		this.length= length;
+		this.viewer= viewer;
 	}
 	
 	
 	@Override
 	public void apply(final IDocument document) {
 		try {
-			final String variable= this.fVariable.getType().equals("dollar") ? "$$" : "${" + this.fVariable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-			document.replace(this.fOffset, this.fLength, variable);
-			this.fSelection= new Point(this.fOffset + variable.length(), 0);
+			final String variable= this.variable.getType().equals("dollar") ? "$$" : "${" + this.variable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			document.replace(this.offset, this.length, variable);
+			this.selection= new Point(this.offset + variable.length(), 0);
 		}
 		catch (final BadLocationException e) {
-			final Shell shell= this.fViewer.getTextWidget().getShell();
+			final Shell shell= this.viewer.getTextWidget().getShell();
 			MessageDialog.openError(shell, TemplateMessages.TemplateVariableProposal_error_title, e.getMessage());
 		}
 	}
 	
 	@Override
 	public Point getSelection(final IDocument document) {
-		return this.fSelection;
-	}
-	
-	@Override
-	public String getAdditionalProposalInfo() {
-		return null;
+		return this.selection;
 	}
 	
 	@Override
 	public String getDisplayString() {
-		return this.fVariable.getType() + " - " + this.fVariable.getDescription(); //$NON-NLS-1$
+		return this.variable.getType();
+	}
+	
+	@Override
+	public String getAdditionalProposalInfo() {
+		return this.variable.getDescription();
 	}
 	
 	@Override
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.java
index e86ad9f..ec7a95a 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.java
@@ -27,8 +27,6 @@
 	public static String Templates_Variable_SelectionBegin_description;
 	public static String Templates_Variable_SelectionEnd_description;
 	
-	public static String Templates_Variable_SelectedLines_description;
-	
 	public static String Preview_label;
 	
 	public static String Config_DocTemplates_label;
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.properties b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.properties
index 478cddd..1055f33 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.properties
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/internal/ltk/ui/TemplatesMessages.properties
@@ -12,13 +12,11 @@
  #     Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
  #=============================================================================#
 
-Templates_Variable_File_description= Name of the enclosing code unit
-Templates_Variable_ToDo_description= ToDo task tag
-Templates_Variable_EnclosingProject_description= Name of the enclosing project
-Templates_Variable_SelectionBegin_description= Start of initial text selection
-Templates_Variable_SelectionEnd_description= End of initial text selection 
-
-Templates_Variable_SelectedLines_description= The selected lines
+Templates_Variable_File_description= <b>${file_name}</b><br/>Name of the enclosing code unit
+Templates_Variable_ToDo_description= <b>${todo}</b><br/>To-do task tag
+Templates_Variable_EnclosingProject_description= <b>${enclosing_project}</b><br/>Name of the enclosing project
+Templates_Variable_SelectionBegin_description= <b>${selection_begin}</b><br/>Start of initial text selection
+Templates_Variable_SelectionEnd_description= <b>${selection_end}</b><br/>End of initial text selection
 
 Preview_label= &Preview
 
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SourceEditorViewerConfiguration.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SourceEditorViewerConfiguration.java
index 5455802..2b399a8 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SourceEditorViewerConfiguration.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/SourceEditorViewerConfiguration.java
@@ -74,6 +74,7 @@
 import org.eclipse.statet.ecommons.text.ui.settings.TextStyleManager;
 import org.eclipse.statet.ecommons.ui.ISettingsChangedHandler;
 import org.eclipse.statet.ecommons.ui.dialogs.DialogUtils;
+import org.eclipse.statet.ecommons.ui.util.InformationDispatchHandler;
 
 import org.eclipse.statet.internal.ltk.ui.LTKUIPlugin;
 import org.eclipse.statet.ltk.ui.LTKUIPreferences;
@@ -105,9 +106,6 @@
 	public static final int COMPARE_MODE=                   1 << 4;
 	
 	
-	private static IInformationControlCreator ASSIST_INFO_CREATOR;
-	
-	
 	private static class AssistInformationControlCreator extends AbstractReusableInformationControlCreator {
 		
 		@Override
@@ -140,6 +138,11 @@
 		
 	};
 	
+	
+	private static IInformationControlCreator assistTemplateInformationControlCreator;
+	
+	private static IInformationControlCreator assistDefaultInformationControlCreator;
+	
 	private static final IInformationControlCreator DEFAULT_INFORMATION_CONTROL_CREATOR=
 			new IInformationControlCreator() {
 				
@@ -400,7 +403,8 @@
 				}
 				this.contentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
 				this.contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
-				this.contentAssistant.setInformationControlCreator(getAssistInformationControlCreator(sourceViewer));
+				this.contentAssistant.setInformationControlCreator(
+						getAssistInformationControlCreator(sourceViewer) );
 			}
 		}
 		return this.contentAssistant;
@@ -456,10 +460,22 @@
 	}
 	
 	protected IInformationControlCreator getAssistInformationControlCreator(final ISourceViewer sourceViewer) {
-		if (ASSIST_INFO_CREATOR == null) {
-			ASSIST_INFO_CREATOR= new AssistInformationControlCreator();
+		if ((getFlags() & TEMPLATE_MODE) != 0) {
+			if (assistTemplateInformationControlCreator == null) {
+				assistTemplateInformationControlCreator= new IInformationControlCreator() {
+					@Override
+					public IInformationControl createInformationControl(final Shell parent) {
+						return new DefaultInformationControl(parent,
+								InformationDispatchHandler.getAdditionalInfoAffordanceString() );
+					}
+				};
+			}
+			return assistTemplateInformationControlCreator;
 		}
-		return ASSIST_INFO_CREATOR;
+		if (assistDefaultInformationControlCreator == null) {
+			assistDefaultInformationControlCreator= new AssistInformationControlCreator();
+		}
+		return assistDefaultInformationControlCreator;
 	}
 	
 	@Override