1 11 package org.eclipse.jdt.internal.ui.refactoring.contentassist; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Combo; 15 import org.eclipse.swt.widgets.Shell; 16 import org.eclipse.swt.widgets.Text; 17 18 import org.eclipse.jface.contentassist.SubjectControlContentAssistant; 19 import org.eclipse.jface.internal.text.html.HTMLTextPresenter; 20 21 import org.eclipse.jface.text.DefaultInformationControl; 22 import org.eclipse.jface.text.IDocument; 23 import org.eclipse.jface.text.IInformationControl; 24 import org.eclipse.jface.text.IInformationControlCreator; 25 import org.eclipse.jface.text.contentassist.IContentAssistProcessor; 26 import org.eclipse.jface.text.contentassist.IContentAssistant; 27 28 import org.eclipse.ui.contentassist.ContentAssistHandler; 29 30 import org.eclipse.jdt.internal.ui.JavaPlugin; 31 import org.eclipse.jdt.internal.ui.text.ContentAssistPreference; 32 33 34 37 public class ControlContentAssistHelper { 38 39 43 public static void createTextContentAssistant(final Text text, IContentAssistProcessor processor) { 44 ContentAssistHandler.createHandlerForText(text, createJavaContentAssistant(processor)); 45 } 46 47 51 public static void createComboContentAssistant(final Combo combo, IContentAssistProcessor processor) { 52 ContentAssistHandler.createHandlerForCombo(combo, createJavaContentAssistant(processor)); 53 } 54 55 public static SubjectControlContentAssistant createJavaContentAssistant(IContentAssistProcessor processor) { 56 final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant(); 57 58 contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); 59 60 ContentAssistPreference.configure(contentAssistant, JavaPlugin.getDefault().getPreferenceStore()); 61 contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); 62 contentAssistant.setInformationControlCreator(new IInformationControlCreator() { 63 public IInformationControl createInformationControl(Shell parent) { 64 return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true)); 65 } 66 }); 67 68 return contentAssistant; 69 } 70 71 } 72 | Popular Tags |