01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.context;
11:
12: import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
13: import org.eclipse.jface.text.*;
14: import org.eclipse.jface.text.rules.FastPartitioner;
15: import org.eclipse.pde.internal.ui.editor.text.XMLPartitionScanner;
16:
17: public class XMLDocumentSetupParticpant implements
18: IDocumentSetupParticipant {
19:
20: public static final String XML_PARTITIONING = "_pde_xml_partitioning"; //$NON-NLS-1$
21:
22: public void setup(IDocument document) {
23: IDocumentPartitioner partitioner = createDocumentPartitioner();
24: if (partitioner != null) {
25: partitioner.connect(document);
26: if (document instanceof IDocumentExtension3) {
27: IDocumentExtension3 de3 = (IDocumentExtension3) document;
28: de3.setDocumentPartitioner(XML_PARTITIONING,
29: partitioner);
30: } else {
31: document.setDocumentPartitioner(partitioner);
32: }
33: }
34: }
35:
36: private IDocumentPartitioner createDocumentPartitioner() {
37: return new FastPartitioner(new XMLPartitionScanner(),
38: XMLPartitionScanner.PARTITIONS);
39: }
40:
41: }
|