1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.text;
13 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.text.IAutoEditStrategy;
16 import org.eclipse.jface.text.IInformationControlCreator;
17 import org.eclipse.jface.text.ITextHover;
18 import org.eclipse.jface.text.formatter.IContentFormatter;
19 import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
20 import org.eclipse.jface.text.information.IInformationPresenter;
21 import org.eclipse.jface.text.source.IAnnotationHover;
22 import org.eclipse.jface.text.source.ISourceViewer;
24 import org.eclipse.ui.texteditor.ITextEditor;
26 import org.eclipse.jdt.ui.text.IColorManager;
27 import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
31 * A simple {@linkplain org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration Java source viewer configuration}.
33 * This simple source viewer configuration basically provides syntax coloring
34 * and disables all other features like code assist, quick outlines, hyperlinking, etc.
39 public class SimpleJavaSourceViewerConfiguration extends JavaSourceViewerConfiguration {
42 private boolean fConfigureFormatter;
45 * Creates a new Java source viewer configuration for viewers in the given editor
46 * using the given preference store, the color manager and the specified document partitioning.
48 * @param colorManager the color manager
49 * @param preferenceStore the preference store, can be read-only
50 * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
51 * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
52 * @param configureFormatter <code>true</code> if a content formatter should be configured
54 public SimpleJavaSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning, boolean configureFormatter) {
55 super(colorManager, preferenceStore, editor, partitioning);
56 fConfigureFormatter= configureFormatter;
60 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
63 public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
68 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
71 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
76 * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
79 public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
84 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
87 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
92 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
95 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
100 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
103 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
108 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
111 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
112 if (fConfigureFormatter)
113 return super.getContentFormatter(sourceViewer);
119 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
122 public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
127 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
130 public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
135 * @see org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#getOutlinePresenter(org.eclipse.jface.text.source.ISourceViewer, boolean)
138 public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
143 * @see org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#getHierarchyPresenter(org.eclipse.jface.text.source.ISourceViewer, boolean)
146 public IInformationPresenter getHierarchyPresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
151 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
154 public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {