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.1 2004-09-02 18:28:03 jsurfer Exp $
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
16 import org.eclipse.jface.text.IDocument;
17 import org.eclipse.jface.text.ITextDoubleClickStrategy;
18 import org.eclipse.jface.text.presentation.IPresentationReconciler;
19 import org.eclipse.jface.text.presentation.PresentationReconciler;
20 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
21 import org.eclipse.jface.text.source.ISourceViewer;
22 import org.eclipse.jface.text.source.SourceViewerConfiguration;
24 import net.sourceforge.phpeclipse.ui.text.TextDoubleClickStrategy;
25 import net.sourceforge.phpeclipse.xml.ui.text.DTDTextTools;
29 * DTD editor configuration.
31 * @author Igor Malinin
33 public class DTDConfiguration extends SourceViewerConfiguration {
34 private DTDTextTools dtdTextTools;
36 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, String)
49 public ITextDoubleClickStrategy getDoubleClickStrategy(
50 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 ) {
76 IDocument.DEFAULT_CONTENT_TYPE,
77 XMLPartitionScanner.XML_PI,
78 XMLPartitionScanner.XML_COMMENT,
79 XMLPartitionScanner.XML_DECL,
80 XMLPartitionScanner.DTD_CONDITIONAL,
85 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
87 public IPresentationReconciler getPresentationReconciler(
88 ISourceViewer sourceViewer
90 PresentationReconciler reconciler = new PresentationReconciler();
92 DefaultDamagerRepairer dr;
94 dr = new DefaultDamagerRepairer( dtdTextTools.getDTDTextScanner() );
95 reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
96 reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
98 reconciler.setDamager( dr, XMLPartitionScanner.XML_PI );
99 reconciler.setRepairer( dr, XMLPartitionScanner.XML_PI );
101 dr = new DefaultDamagerRepairer( dtdTextTools.getXMLPIScanner() );
103 reconciler.setDamager( dr, XMLPartitionScanner.XML_PI );
104 reconciler.setRepairer( dr, XMLPartitionScanner.XML_PI );
106 dr = new DefaultDamagerRepairer( dtdTextTools.getXMLCommentScanner() );
108 reconciler.setDamager( dr, XMLPartitionScanner.XML_COMMENT );
109 reconciler.setRepairer( dr, XMLPartitionScanner.XML_COMMENT );
111 dr = new DefaultDamagerRepairer( dtdTextTools.getXMLDeclScanner() );
113 reconciler.setDamager( dr, XMLPartitionScanner.XML_DECL );
114 reconciler.setRepairer( dr, XMLPartitionScanner.XML_DECL );
116 dr = new DefaultDamagerRepairer( dtdTextTools.getDTDConditionalScanner() );
118 reconciler.setDamager( dr, XMLPartitionScanner.DTD_CONDITIONAL );
119 reconciler.setRepairer( dr, XMLPartitionScanner.DTD_CONDITIONAL );