01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.ui.examples.templateeditor.editors;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.jface.text.IDocument;
14: import org.eclipse.jface.text.IDocumentPartitioner;
15: import org.eclipse.jface.text.rules.FastPartitioner;
16: import org.eclipse.ui.editors.text.FileDocumentProvider;
17:
18: public class XMLDocumentProvider extends FileDocumentProvider {
19:
20: protected IDocument createDocument(Object element)
21: throws CoreException {
22: IDocument document = super .createDocument(element);
23: if (document != null) {
24: IDocumentPartitioner partitioner = new FastPartitioner(
25: new XMLPartitionScanner(), new String[] {
26: XMLPartitionScanner.XML_TAG,
27: XMLPartitionScanner.XML_COMMENT });
28: partitioner.connect(document);
29: document.setDocumentPartitioner(partitioner);
30: }
31: return document;
32: }
33: }
|