1 11 package org.eclipse.pde.internal.ui.editor.text; 12 13 import org.eclipse.jface.text.IDocument; 14 import org.eclipse.jface.text.ITextHover; 15 import org.eclipse.jface.text.contentassist.ContentAssistant; 16 import org.eclipse.jface.text.contentassist.IContentAssistant; 17 import org.eclipse.jface.text.source.ISourceViewer; 18 import org.eclipse.pde.internal.ui.editor.PDESourcePage; 19 import org.eclipse.pde.internal.ui.editor.contentassist.XMLContentAssistProcessor; 20 21 public class PluginXMLConfiguration extends XMLConfiguration { 22 23 private ContentAssistant fContentAssistant; 24 private XMLContentAssistProcessor fContentAssistProcessor; 25 private PluginXMLTextHover fTextHover; 26 27 public PluginXMLConfiguration(IColorManager colorManager, PDESourcePage page) { 28 super(colorManager, page); 29 } 30 31 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { 32 if (sourceViewer.isEditable() && fContentAssistant == null) { 33 fContentAssistProcessor = new XMLContentAssistProcessor(fSourcePage); 34 fContentAssistant = new ContentAssistant(); 35 fContentAssistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); 36 fContentAssistant.setContentAssistProcessor(fContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE); 37 fContentAssistant.setContentAssistProcessor(fContentAssistProcessor, XMLPartitionScanner.XML_TAG); 38 fContentAssistant.setInformationControlCreator(getInformationControlCreator(true)); 39 fContentAssistant.setShowEmptyList(false); 40 fContentAssistant.addCompletionListener(fContentAssistProcessor); 41 } 42 return fContentAssistant; 43 } 44 45 public void dispose() { 46 if (fContentAssistProcessor != null) 47 fContentAssistProcessor.dispose(); 48 super.dispose(); 49 } 50 51 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { 52 if (fTextHover == null && fSourcePage != null) 53 fTextHover = new PluginXMLTextHover(fSourcePage); 54 return fTextHover; 55 } 56 } 57 | Popular Tags |