01: package org.drools.eclipse.editors;
02:
03: import org.drools.eclipse.editors.scanners.DRLPartionScanner;
04: import org.eclipse.core.resources.IFile;
05: import org.eclipse.jface.text.IDocument;
06: import org.eclipse.jface.text.IDocumentPartitioner;
07: import org.eclipse.jface.text.rules.FastPartitioner;
08: import org.eclipse.jface.text.source.IAnnotationModel;
09: import org.eclipse.ui.editors.text.TextFileDocumentProvider;
10:
11: /**
12: * Simple document provider.
13: *
14: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
15: */
16: public class DRLDocumentProvider extends TextFileDocumentProvider {
17:
18: public IDocument getDocument(Object element) {
19: IDocument document = getParentDocument(element);
20: if (document != null) {
21: IDocumentPartitioner partitioner = new FastPartitioner(
22: new DRLPartionScanner(),
23: DRLPartionScanner.LEGAL_CONTENT_TYPES);
24: partitioner.connect(document);
25: document.setDocumentPartitioner(partitioner);
26: }
27: return document;
28: }
29:
30: protected IAnnotationModel createAnnotationModel(IFile file) {
31: return new DRLAnnotationModel(file);
32: }
33:
34: protected IDocument getParentDocument(Object element) {
35: return super.getDocument(element);
36: }
37:
38: }
|