KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > text > AntStorageDocumentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - Initial implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.editor.text;
12
13 import org.eclipse.jface.text.IDocument;
14 import org.eclipse.jface.text.IDocumentExtension3;
15 import org.eclipse.jface.text.IDocumentPartitioner;
16 import org.eclipse.jface.text.rules.FastPartitioner;
17 import org.eclipse.ui.editors.text.StorageDocumentProvider;
18
19 /**
20  * @since 3.0
21  */

22 public class AntStorageDocumentProvider extends StorageDocumentProvider {
23     
24     /*
25      * @see org.eclipse.ui.editors.text.StorageDocumentProvider#setupDocument(java.lang.Object,
26      * org.eclipse.jface.text.IDocument)
27      */

28     protected void setupDocument(Object JavaDoc element, IDocument document) {
29         if (document != null) {
30             IDocumentPartitioner partitioner= createDocumentPartitioner();
31             if (document instanceof IDocumentExtension3) {
32                 IDocumentExtension3 extension3= (IDocumentExtension3) document;
33                 extension3.setDocumentPartitioner(AntDocumentSetupParticipant.ANT_PARTITIONING, partitioner);
34             } else {
35                 document.setDocumentPartitioner(partitioner);
36             }
37             partitioner.connect(document);
38         }
39     }
40     
41     private IDocumentPartitioner createDocumentPartitioner() {
42         return new FastPartitioner(
43                 new AntEditorPartitionScanner(), new String JavaDoc[]{
44                         AntEditorPartitionScanner.XML_TAG,
45                         AntEditorPartitionScanner.XML_COMMENT,
46                         AntEditorPartitionScanner.XML_CDATA,
47                         AntEditorPartitionScanner.XML_DTD});
48     }
49 }
50
Popular Tags