01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.text;
11:
12: import org.eclipse.jface.text.IDocument;
13: import org.eclipse.jface.text.ITextHover;
14: import org.eclipse.jface.text.contentassist.ContentAssistant;
15: import org.eclipse.jface.text.contentassist.IContentAssistant;
16: import org.eclipse.jface.text.source.ISourceViewer;
17: import org.eclipse.pde.internal.ui.editor.PDESourcePage;
18: import org.eclipse.pde.internal.ui.editor.contentassist.XMLContentAssistProcessor;
19:
20: public class PluginXMLConfiguration extends XMLConfiguration {
21:
22: private ContentAssistant fContentAssistant;
23: private XMLContentAssistProcessor fContentAssistProcessor;
24: private PluginXMLTextHover fTextHover;
25:
26: public PluginXMLConfiguration(IColorManager colorManager,
27: PDESourcePage page) {
28: super (colorManager, page);
29: }
30:
31: public IContentAssistant getContentAssistant(
32: ISourceViewer sourceViewer) {
33: if (sourceViewer.isEditable() && fContentAssistant == null) {
34: fContentAssistProcessor = new XMLContentAssistProcessor(
35: fSourcePage);
36: fContentAssistant = new ContentAssistant();
37: fContentAssistant
38: .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
39: fContentAssistant.setContentAssistProcessor(
40: fContentAssistProcessor,
41: IDocument.DEFAULT_CONTENT_TYPE);
42: fContentAssistant.setContentAssistProcessor(
43: fContentAssistProcessor,
44: XMLPartitionScanner.XML_TAG);
45: fContentAssistant
46: .setInformationControlCreator(getInformationControlCreator(true));
47: fContentAssistant.setShowEmptyList(false);
48: fContentAssistant
49: .addCompletionListener(fContentAssistProcessor);
50: }
51: return fContentAssistant;
52: }
53:
54: public void dispose() {
55: if (fContentAssistProcessor != null)
56: fContentAssistProcessor.dispose();
57: super .dispose();
58: }
59:
60: public ITextHover getTextHover(ISourceViewer sourceViewer,
61: String contentType) {
62: if (fTextHover == null && fSourcePage != null)
63: fTextHover = new PluginXMLTextHover(fSourcePage);
64: return fTextHover;
65: }
66:
67: }
|