2 * Copyright (c) 2002-2004 Widespace, OU and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Igor Malinin - initial contribution
11 * $Id: DTDConfiguration.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
16 import net.sourceforge.phpeclipse.ui.text.TextDoubleClickStrategy;
17 import net.sourceforge.phpeclipse.xml.ui.text.DTDTextTools;
19 import org.eclipse.jface.text.IDocument;
20 import org.eclipse.jface.text.ITextDoubleClickStrategy;
21 import org.eclipse.jface.text.presentation.IPresentationReconciler;
22 import org.eclipse.jface.text.presentation.PresentationReconciler;
23 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
24 import org.eclipse.jface.text.source.ISourceViewer;
25 import org.eclipse.jface.text.source.SourceViewerConfiguration;
28 * DTD editor configuration.
30 * @author Igor Malinin
32 public class DTDConfiguration extends SourceViewerConfiguration {
33 private DTDTextTools dtdTextTools;
35 private ITextDoubleClickStrategy dcsDefault;
37 private ITextDoubleClickStrategy dcsSimple;
39 public DTDConfiguration(DTDTextTools tools) {
42 dcsDefault = new TextDoubleClickStrategy();
43 dcsSimple = new SimpleDoubleClickStrategy();
47 * @see SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer,
50 public ITextDoubleClickStrategy getDoubleClickStrategy(
51 ISourceViewer sourceViewer, String contentType) {
52 if (XMLPartitionScanner.XML_PI.equals(contentType)) {
56 if (XMLPartitionScanner.XML_COMMENT.equals(contentType)) {
60 if (XMLPartitionScanner.XML_DECL.equals(contentType)) {
64 if (XMLPartitionScanner.DTD_CONDITIONAL.equals(contentType)) {
72 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
74 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
75 return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
76 XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT,
77 XMLPartitionScanner.XML_DECL,
78 XMLPartitionScanner.DTD_CONDITIONAL, };
82 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
84 public IPresentationReconciler getPresentationReconciler(
85 ISourceViewer sourceViewer) {
86 PresentationReconciler reconciler = new PresentationReconciler();
88 DefaultDamagerRepairer dr;
90 dr = new DefaultDamagerRepairer(dtdTextTools.getDTDTextScanner());
91 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
92 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
94 reconciler.setDamager(dr, XMLPartitionScanner.XML_PI);
95 reconciler.setRepairer(dr, XMLPartitionScanner.XML_PI);
97 dr = new DefaultDamagerRepairer(dtdTextTools.getXMLPIScanner());
99 reconciler.setDamager(dr, XMLPartitionScanner.XML_PI);
100 reconciler.setRepairer(dr, XMLPartitionScanner.XML_PI);
102 dr = new DefaultDamagerRepairer(dtdTextTools.getXMLCommentScanner());
104 reconciler.setDamager(dr, XMLPartitionScanner.XML_COMMENT);
105 reconciler.setRepairer(dr, XMLPartitionScanner.XML_COMMENT);
107 dr = new DefaultDamagerRepairer(dtdTextTools.getXMLDeclScanner());
109 reconciler.setDamager(dr, XMLPartitionScanner.XML_DECL);
110 reconciler.setRepairer(dr, XMLPartitionScanner.XML_DECL);
112 dr = new DefaultDamagerRepairer(dtdTextTools.getDTDConditionalScanner());
114 reconciler.setDamager(dr, XMLPartitionScanner.DTD_CONDITIONAL);
115 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_CONDITIONAL);