KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > preferences > XMLSyntaxColorTab


1 /*******************************************************************************
2  * Copyright (c) 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 API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.preferences;
12
13 import org.eclipse.jface.text.Document;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.pde.internal.ui.PDEUIMessages;
16 import org.eclipse.pde.internal.ui.editor.context.XMLDocumentSetupParticpant;
17 import org.eclipse.pde.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration;
18 import org.eclipse.pde.internal.ui.editor.text.IColorManager;
19 import org.eclipse.pde.internal.ui.editor.text.IPDEColorConstants;
20 import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration;
21
22 public class XMLSyntaxColorTab extends SyntaxColorTab {
23
24     private static final String JavaDoc[][] COLOR_STRINGS = new String JavaDoc[][] {
25             /* {Display name, IPreferenceStore key} */
26                     {PDEUIMessages.EditorPreferencePage_text, IPDEColorConstants.P_DEFAULT},
27                     {PDEUIMessages.EditorPreferencePage_proc, IPDEColorConstants.P_PROC_INSTR},
28                     {PDEUIMessages.EditorPreferencePage_tag, IPDEColorConstants.P_TAG},
29                     {PDEUIMessages.EditorPreferencePage_string, IPDEColorConstants.P_STRING},
30                     {PDEUIMessages.EditorPreferencePage_comment, IPDEColorConstants.P_XML_COMMENT}};
31
32     public XMLSyntaxColorTab(IColorManager manager) {
33         super(manager);
34     }
35     
36     protected IDocument getDocument() {
37         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
38         String JavaDoc delimiter = System.getProperty("line.separator"); //$NON-NLS-1$
39
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
40
buffer.append(delimiter);
41         buffer.append("<plugin>"); //$NON-NLS-1$
42
buffer.append(delimiter);
43         buffer.append("<!-- Comment -->"); //$NON-NLS-1$
44
buffer.append(delimiter);
45         buffer.append(" <extension point=\"some.id\">"); //$NON-NLS-1$
46
buffer.append(delimiter);
47         buffer.append(" <tag> body text </tag>"); //$NON-NLS-1$
48
buffer.append(delimiter);
49         buffer.append(" </extension>"); //$NON-NLS-1$
50
buffer.append(delimiter);
51         buffer.append("</plugin>"); //$NON-NLS-1$
52

53         IDocument document = new Document(buffer.toString());
54         new XMLDocumentSetupParticpant().setup(document);
55         return document;
56     }
57
58     protected ChangeAwareSourceViewerConfiguration getSourceViewerConfiguration() {
59         return new XMLConfiguration(fColorManager);
60     }
61
62     protected String JavaDoc[][] getColorStrings() {
63         return COLOR_STRINGS;
64     }
65 }
66
Popular Tags