Bug 220571 - Use new simpler Text API
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java
index b10d4b1..10236fe 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java
@@ -1,8 +1,8 @@
 /*******************************************************************************
- * Copyright (c) 2002, 2007 GEBIT Gesellschaft fuer EDV-Beratung
- * und Informatik-Technologien mbH, 
+ * Copyright (c) 2002, 2008 GEBIT Gesellschaft fuer EDV-Beratung
+ * und Informatik-Technologien mbH,
  * Berlin, Duesseldorf, Frankfurt (Germany) and others.
- * All rights reserved. This program and the accompanying materials 
+ * 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
@@ -20,6 +20,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Shell;
+
 import org.eclipse.ant.internal.ui.AntSourceViewerConfiguration;
 import org.eclipse.ant.internal.ui.ColorManager;
 import org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormattingStrategy;
@@ -32,8 +36,10 @@
 import org.eclipse.ant.internal.ui.editor.text.XMLReconcilingStrategy;
 import org.eclipse.ant.internal.ui.editor.text.XMLTextHover;
 import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
-import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
+
 import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
 import org.eclipse.jface.text.DefaultInformationControl;
 import org.eclipse.jface.text.IAutoEditStrategy;
 import org.eclipse.jface.text.IDocument;
@@ -50,11 +56,6 @@
 import org.eclipse.jface.text.reconciler.IReconciler;
 import org.eclipse.jface.text.source.IAnnotationHover;
 import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Shell;
 
 /**
  * The source viewer configuration for the Ant Editor.
@@ -75,14 +76,14 @@
     public AntEditorSourceViewerConfiguration(AntEditor editor) {
 	    super();
 	    fEditor= editor;
-    }    
+    }
 
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(ISourceViewer)
      */
     public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
         fContentAssistant= new ContentAssistant();
-        AntEditorCompletionProcessor processor = new AntEditorCompletionProcessor(fEditor.getAntModel()); 
+        AntEditorCompletionProcessor processor = new AntEditorCompletionProcessor(fEditor.getAntModel());
 		fContentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
 		fContentAssistant.setContentAssistProcessor(processor, AntEditorPartitionScanner.XML_TAG);
         fContentAssistant.setDocumentPartitioning(AntDocumentSetupParticipant.ANT_PARTITIONING);
@@ -99,8 +100,8 @@
 		fContentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
 		fContentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
 
-		ColorManager manager= ColorManager.getDefault();	
-		Color background= getColor(AntEditorPreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);			
+		ColorManager manager= ColorManager.getDefault();
+		Color background= getColor(AntEditorPreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
 		fContentAssistant.setContextInformationPopupBackground(background);
 		fContentAssistant.setContextSelectorBackground(background);
 		fContentAssistant.setProposalSelectorBackground(background);
@@ -143,7 +144,7 @@
 	public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
 		return new IInformationControlCreator() {
             public IInformationControl createInformationControl(Shell parent) {
-                return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
+                return new DefaultInformationControl(parent, false);
             }
         };
 	}
@@ -194,7 +195,7 @@
 			if (cp != null) {
 				cp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
 			}
-		}		
+		}
 	}
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentFormatter(org.eclipse.jface.text.source.ISourceViewer)
@@ -242,9 +243,7 @@
 	public static IInformationControlCreator getInformationPresenterControlCreator() {
 		return new IInformationControlCreator() {
 			public IInformationControl createInformationControl(Shell parent) {
-				int shellStyle= SWT.RESIZE;
-				int style= SWT.V_SCROLL | SWT.H_SCROLL;
-				return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
+				return new DefaultInformationControl(parent, true);
 			}
 		};
 	}
@@ -270,7 +269,7 @@
 				if (i != 0) {
 		    		prefix.append('\t');
 				}
-			} else {    
+			} else {
 			    for (int j= 0; j < i; j++) {
 			    	prefix.append(' ');
 			    }
@@ -284,7 +283,7 @@
 
 		list.add(""); //$NON-NLS-1$
 		
-		return (String[]) list.toArray(new String[list.size()]);	
+		return (String[]) list.toArray(new String[list.size()]);
 	}
 	
 	/*
@@ -293,14 +292,14 @@
 	public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
 		if (AntEditorPartitionScanner.XML_COMMENT.equals(contentType)) {
 			return super.getAutoEditStrategies(sourceViewer, contentType);
-		} 
+		}
 		if (fAutoEditorStategies == null) {
 			fAutoEditorStategies= new AntAutoEditStrategy[] {new AntAutoEditStrategy(fEditor.getAntModel())};
 		}
 		return fAutoEditorStategies;
 	}
     
-   /* 
+   /*
     * @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getHyperlinkDetectorTargets(org.eclipse.jface.text.source.ISourceViewer)
     */
 	protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java
index 684d829..f36c02d 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -11,15 +11,6 @@
 
 package org.eclipse.ant.internal.ui.editor;
 
-import org.eclipse.ant.internal.ui.AntSourceViewerConfiguration;
-import org.eclipse.ant.internal.ui.editor.text.AntDocumentSetupParticipant;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.DisposeEvent;
@@ -37,13 +28,22 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 
+import org.eclipse.ant.internal.ui.AntSourceViewerConfiguration;
+import org.eclipse.ant.internal.ui.editor.text.AntDocumentSetupParticipant;
+
+import org.eclipse.jface.resource.JFaceResources;
+
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlExtension;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
 public class AntSourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener {
 	/** The control's shell */
 	private Shell fShell;
 	
-	/** Border thickness in pixels. */
-	private static final int BORDER= 1;
-	
 	/** The control's source viewer */
 	private SourceViewer fViewer;
 	
@@ -54,15 +54,14 @@
 		GridLayout layout;
 		GridData gd;
 
-		fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | SWT.NO_TRIM);
-		Display display= fShell.getDisplay();		
+		fShell= new Shell(parent, SWT.ON_TOP | SWT.TOOL);
+		Display display= fShell.getDisplay();
 		fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
 
 		Composite composite= fShell;
 		layout= new GridLayout(1, false);
-		int border= ((SWT.NO_TRIM & SWT.NO_TRIM) == 0) ? 0 : BORDER;
-		layout.marginHeight= border;
-		layout.marginWidth= border;
+		layout.marginHeight= 0;
+		layout.marginWidth= 0;
 		composite.setLayout(layout);
 		gd= new GridData(GridData.FILL_HORIZONTAL);
 		composite.setLayoutData(gd);
@@ -91,9 +90,9 @@
           
 		SourceViewerConfiguration configuration = new AntSourceViewerConfiguration();
 		viewer.configure(configuration);
-		viewer.setEditable(false);	
+		viewer.setEditable(false);
 		Font font= JFaceResources.getFont(JFaceResources.TEXT_FONT);
-		viewer.getTextWidget().setFont(font);    
+		viewer.getTextWidget().setFont(font);
 		        
 		return viewer;
     }
@@ -106,7 +105,7 @@
 			fViewer.setInput(null);
 			return;
 		}
-		IDocument document = new Document(content);       
+		IDocument document = new Document(content);
 		new AntDocumentSetupParticipant().setup(document);
 		fViewer.setDocument(document);
 	}
@@ -143,10 +142,10 @@
 	 */
 	public void setLocation(Point location) {
 		Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
-		Point textLocation= fText.getLocation();				
-		location.x += trim.x - textLocation.x;		
-		location.y += trim.y - textLocation.y;		
-		fShell.setLocation(location);		
+		Point textLocation= fText.getLocation();
+		location.x += trim.x - textLocation.x;
+		location.y += trim.y - textLocation.y;
+		fShell.setLocation(location);
 	}
 
 	/* (non-Javadoc)
@@ -235,4 +234,4 @@
 		fShell= null;
 		fText= null;
 	}
-}
+}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
index a0164e4..2bf7d3c 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -18,6 +18,9 @@
 import org.apache.tools.ant.types.AbstractFileSet;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.PatternSet;
+
+import org.eclipse.swt.widgets.Shell;
+
 import org.eclipse.ant.internal.ui.debug.model.AntProperty;
 import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
 import org.eclipse.ant.internal.ui.debug.model.AntValue;
@@ -27,10 +30,11 @@
 import org.eclipse.ant.internal.ui.model.AntModel;
 import org.eclipse.ant.internal.ui.model.AntPropertyNode;
 import org.eclipse.ant.internal.ui.model.IAntModel;
+
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.ui.DebugUITools;
+
 import org.eclipse.jface.internal.text.html.HTMLPrinter;
-import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
+
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.DefaultInformationControl;
 import org.eclipse.jface.text.IDocument;
@@ -46,10 +50,11 @@
 import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.IAnnotationModel;
 import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
+
 import org.eclipse.ui.editors.text.EditorsUI;
 
+import org.eclipse.debug.ui.DebugUITools;
+
 
 public class XMLTextHover implements ITextHover, ITextHoverExtension, IInformationProviderExtension2 {
 
@@ -222,7 +227,7 @@
 		if (textViewer != null) {
 			return getRegion(textViewer, offset);
 		}
-		return null;	
+		return null;
 	}
 
 	public static IRegion getRegion(ITextViewer textViewer, int offset) {
@@ -231,7 +236,7 @@
 		int start= -1;
 		int end= -1;
 	    IRegion region= null;
-		try {	
+		try {
 			int pos= offset;
 			char c;
             
@@ -330,9 +335,7 @@
 	public IInformationControlCreator getHoverControlCreator() {
 		return new IInformationControlCreator() {
 			public IInformationControl createInformationControl(Shell parent) {
-				return new DefaultInformationControl(parent, SWT.NONE, 
-						new HTMLTextPresenter(true),
-						EditorsUI.getTooltipAffordanceString());
+				return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
 			}
 		};
 	}
@@ -347,7 +350,7 @@
     private AntStackFrame getFrame() {
         IAdaptable adaptable = DebugUITools.getDebugContext();
         if (adaptable != null) {
-            return (AntStackFrame)adaptable.getAdapter(AntStackFrame.class); 
+            return (AntStackFrame)adaptable.getAdapter(AntStackFrame.class);
         }
         return null;
     }
@@ -359,5 +362,4 @@
 	public IInformationControlCreator getInformationPresenterControlCreator() {
 		return AntEditorSourceViewerConfiguration.getInformationPresenterControlCreator();
 	}
-
-}
+}
\ No newline at end of file