KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > editors > xml > XMLDocumentProvider


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.editors.xml;
5
6 import org.eclipse.core.runtime.CoreException;
7 import org.eclipse.jface.text.IDocument;
8 import org.eclipse.jface.text.IDocumentPartitioner;
9 import org.eclipse.jface.text.rules.FastPartitioner;
10 import org.eclipse.ui.editors.text.FileDocumentProvider;
11
12 public class XMLDocumentProvider extends FileDocumentProvider {
13
14     protected IDocument createDocument(Object JavaDoc element) throws CoreException {
15         IDocument document = super.createDocument(element);
16         if (document != null) {
17             IDocumentPartitioner partitioner =
18                 new FastPartitioner(
19                     new XMLPartitionScanner(),
20                     new String JavaDoc[] {
21                         XMLPartitionScanner.XML_TAG,
22                         XMLPartitionScanner.XML_COMMENT });
23             partitioner.connect(document);
24             document.setDocumentPartitioner(partitioner);
25         }
26         return document;
27     }
28 }
Popular Tags