KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.filebuffers.IDocumentSetupParticipant;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.jface.text.IDocumentExtension3;
16 import org.eclipse.jface.text.IDocumentPartitioner;
17 import org.eclipse.jface.text.rules.FastPartitioner;
18
19 /**
20  * The document setup participant for Ant.
21  */

22 public class AntDocumentSetupParticipant implements IDocumentSetupParticipant {
23
24     /**
25      * The name of the Ant partitioning.
26      * @since 3.0
27      */

28     public final static String JavaDoc ANT_PARTITIONING= "org.eclipse.ant.ui.antPartitioning"; //$NON-NLS-1$
29

30     public AntDocumentSetupParticipant() {
31     }
32     
33     /* (non-Javadoc)
34      * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
35      */

36     public void setup(IDocument document) {
37         if (document instanceof IDocumentExtension3) {
38             IDocumentExtension3 extension3= (IDocumentExtension3) document;
39             IDocumentPartitioner partitioner = createDocumentPartitioner();
40             extension3.setDocumentPartitioner(ANT_PARTITIONING, partitioner);
41             partitioner.connect(document);
42         }
43     }
44     
45     private IDocumentPartitioner createDocumentPartitioner() {
46         return new FastPartitioner(
47                 new AntEditorPartitionScanner(), new String JavaDoc[]{
48                         AntEditorPartitionScanner.XML_TAG,
49                         AntEditorPartitionScanner.XML_COMMENT,
50                         AntEditorPartitionScanner.XML_CDATA,
51                         AntEditorPartitionScanner.XML_DTD});
52     }
53 }
54
Popular Tags