refactory: added UI removed from core plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / text / DTDDocumentProvider.java
1 /*
2  * Copyright (c) 2002-2004 Widespace, OU and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     Igor Malinin - initial contribution
10  *
11  * $Id: DTDDocumentProvider.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
15
16 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
17
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.jface.text.IDocument;
20 import org.eclipse.jface.text.IDocumentPartitioner;
21
22 /**
23  * DTD document provider.
24  * 
25  * @author Igor Malinin
26  */
27 public class DTDDocumentProvider extends AbstractDocumentProvider {
28         /*
29          * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(Object)
30          */
31         protected IDocument createDocument(Object element) throws CoreException {
32                 IDocument document = super.createDocument(element);
33                 if (document != null) {
34                         IDocumentPartitioner partitioner = XMLPlugin.getDefault()
35                                         .getDTDTextTools().createDTDPartitioner();
36
37                         if (partitioner != null) {
38                                 partitioner.connect(document);
39                                 document.setDocumentPartitioner(partitioner);
40                         }
41                 }
42
43                 return document;
44         }
45 }