KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > text > PluginXMLConfiguration


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc contentType) {
52         if (fTextHover == null && fSourcePage != null)
53             fTextHover = new PluginXMLTextHover(fSourcePage);
54         return fTextHover;
55     }
56 }
57
Popular Tags