|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui.editors.xmleditor; |
|
19 |
|
20 import org.eclipse.core.runtime.CoreException; |
|
21 import org.eclipse.jface.text.IDocument; |
|
22 import org.eclipse.jface.text.IDocumentPartitioner; |
|
23 import org.eclipse.jface.text.rules.FastPartitioner; |
|
24 import org.eclipse.ui.editors.text.FileDocumentProvider; |
|
25 |
|
26 /** |
|
27 * @author barbararosi-schwartz |
|
28 * |
|
29 */ |
|
30 public class XMLDocumentProvider extends FileDocumentProvider { |
|
31 |
|
32 protected IDocument createDocument(Object element) throws CoreException { |
|
33 IDocument document = super.createDocument(element); |
|
34 if (document != null) { |
|
35 IDocumentPartitioner partitioner = new FastPartitioner( |
|
36 new XMLPartitionScanner(), new String[] { |
|
37 XMLPartitionScanner.XML_TAG, |
|
38 XMLPartitionScanner.XML_COMMENT }); |
|
39 partitioner.connect(document); |
|
40 document.setDocumentPartitioner(partitioner); |
|
41 } |
|
42 return document; |
|
43 } |
|
44 } |