diff options
10 files changed, 144 insertions, 31 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java index 3310adb1be1..2248b1a2e4c 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRuler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,26 +14,35 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Control; /** - * This interface defines a visual component which may serve - * text viewers as an overview annotation presentation area. This means, - * presentation of annotations is independent from the actual view port of - * the text viewer. The annotations of the viewer's whole document are - * visible in the overview ruler. + * This interface defines a visual component which may serve text viewers as an overview annotation + * presentation area. This means, presentation of annotations is independent from the actual view + * port of the text viewer. The annotations of the viewer's whole document are visible in the + * overview ruler. * <p> * This interfaces embodies three contracts: * <ul> - * <li> The overview ruler retrieves the annotations it presents from an annotation model. - * <li> The ruler is a visual component which must be integrated in a hierarchy of SWT controls. - * <li> The ruler provides interested clients with mapping and - * interaction information. This covers the mapping between - * coordinates of the ruler's control and line numbers based - * on the connected text viewer's document (<code>IVerticalRulerInfo</code>). - * </ul></p> + * <li>The overview ruler retrieves the annotations it presents from an annotation model. + * <li>The ruler is a visual component which must be integrated in a hierarchy of SWT controls. + * <li>The ruler provides interested clients with mapping and interaction information. This covers + * the mapping between coordinates of the ruler's control and line numbers based on the connected + * text viewer's document (<code>IVerticalRulerInfo</code>). + * </ul> + * </p> * <p> - * Clients may implement this interface or use the default implementation provided - * by <code>OverviewRuler</code>.</p> - * + * In order to provide backward compatibility for clients of <code>IOverviewRuler</code>, extension + * interfaces are used as a means of evolution. The following extension interfaces exist: + * <ul> + * <li>{@link org.eclipse.jface.text.source.IOverviewRulerExtension} since version 3.8 + * allowing the ruler to set whether to use saturated colors.</li> + * </ul> + * </p> + * <p> + * Clients may implement this interface or use the default implementation provided by + * <code>OverviewRuler</code>. + * </p> + * * @see org.eclipse.jface.text.ITextViewer + * @see org.eclipse.jface.text.source.IOverviewRulerExtension * @since 2.1 */ public interface IOverviewRuler extends IVerticalRuler { diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRulerExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRulerExtension.java new file mode 100644 index 00000000000..82fcc0a63c2 --- /dev/null +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IOverviewRulerExtension.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jface.text.source; + + +/** + * Extension interface for {@link org.eclipse.jface.text.source.IOverviewRuler}. + * <p> + * Allows to set whether to use saturated colors in the overview ruler. + * </p> + * + * @see org.eclipse.jface.text.source.IOverviewRuler + * @since 3.8 + */ +public interface IOverviewRulerExtension { + + /** + * Sets whether to use saturated colors in the overview ruler. + * <p> + * The initial value is defined by the ruler implementation. + * </p> + * + * @param useSaturatedColors <code>true</code> if saturated colors should be used, + * <code>false</code> otherwise + */ + void setUseSaturatedColors(boolean useSaturatedColors); +} diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java index d673ec40009..84eb4de76e6 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java @@ -57,15 +57,19 @@ import org.eclipse.jface.text.source.projection.AnnotationBag; /** - * Ruler presented next to a source viewer showing all annotations of the - * viewer's annotation model in a compact format. The ruler has the same height - * as the source viewer. + * Ruler presented next to a source viewer showing all annotations of the viewer's annotation model + * in a compact format. The ruler has the same height as the source viewer. * <p> - * Clients usually instantiate and configure objects of this class.</p> - * + * This overview ruler uses non-saturated colors unless {@link #setUseSaturatedColors(boolean)} gets + * called. + * </p> + * <p> + * Clients usually instantiate and configure objects of this class. + * </p> + * * @since 2.1 */ -public class OverviewRuler implements IOverviewRuler { +public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler { /** * Internal listener class. @@ -487,6 +491,13 @@ public class OverviewRuler implements IOverviewRuler { * @since 3.4 */ private boolean fIsTemporaryAnnotationDiscolored; + + /** + * Tells whether saturated colors are used in the overview ruler. + * + * @since 3.8 + */ + private boolean fUseSaturatedColors= false; /** @@ -775,8 +786,8 @@ public class OverviewRuler implements IOverviewRuler { fAnnotationHeight= hh; if (!areColorsComputed) { - fill= getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY); stroke= getStrokeColor(annotationType, style[t] == FilterIterator.TEMPORARY); + fill= fUseSaturatedColors ? stroke : getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY); areColorsComputed= true; } @@ -1497,4 +1508,13 @@ public class OverviewRuler implements IOverviewRuler { if (overview.length() > 0) fHeader.setToolTipText(overview); } + + /** + * {@inheritDoc} + * + * @since 3.8 + */ + public void setUseSaturatedColors(boolean useSaturatedColor) { + fUseSaturatedColors= useSaturatedColor; + } } diff --git a/org.eclipse.ui.editors/META-INF/MANIFEST.MF b/org.eclipse.ui.editors/META-INF/MANIFEST.MF index 59deb7b62c2..748e2f413e6 100644 --- a/org.eclipse.ui.editors/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.editors/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true -Bundle-Version: 3.7.0.qualifier +Bundle-Version: 3.8.0.qualifier Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName @@ -19,7 +19,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - org.eclipse.jface.text;bundle-version="[3.7.0,4.0.0)", + org.eclipse.jface.text;bundle-version="[3.8.0,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.7.0,4.0.0)", org.eclipse.core.filebuffers;visibility:=reexport;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", diff --git a/org.eclipse.ui.editors/plugin.properties b/org.eclipse.ui.editors/plugin.properties index bb6a0a4d1b2..786d117dd42 100644 --- a/org.eclipse.ui.editors/plugin.properties +++ b/org.eclipse.ui.editors/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2010 IBM Corporation and others. +# Copyright (c) 2000, 2011 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -120,7 +120,7 @@ conversionSubMenu.label= Con&vert Line Delimiters To preferenceKeywords.general= text editor tabs spaces width undo history ruler print margin overview hyperlink overwrite colors line numbers range indicator typing appearance derived navigation smart caret positioning invisible whitespace characters drag drop dnd hovers sticky enrich rich preferenceKeywords.annotations= annotations vertical ruler overview colors text editor preferenceKeywords.quickdiff= quick diff compare reference colors text editor changes -preferenceKeywords.accessibility= accessibility caret cursor quick diff text editor +preferenceKeywords.accessibility= accessibility caret cursor quick diff text editor ruler preferenceKeywords.spelling= spelling spell checking dictionary correction check text editor preferenceKeywords.linkedmode= editor linked mode template preferenceKeywords.hyperlinkDetectors= hyperlinking text editor on demand link navigation modifier key diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java index 1ccbf51f2e1..7596bb84f6d 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -363,6 +363,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.USE_SATURATED_COLORS_IN_OVERVIEW_RULER)); OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); @@ -407,6 +408,10 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork Preference quickDiffTextMode= new Preference(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, label, null); addCheckBox(appearanceComposite, quickDiffTextMode, new BooleanDomain(), 0); + label= TextEditorMessages.TextEditorPreferencePage_accessibility_useSaturatedColorsInOverviewRuler; + Preference useSaturatedColors= new Preference(AbstractDecoratedTextEditorPreferenceConstants.USE_SATURATED_COLORS_IN_OVERVIEW_RULER, label, null); + addCheckBox(appearanceComposite, useSaturatedColors, new BooleanDomain(), 0); + return appearanceComposite; } diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java index 6d80df98a89..2110f278a39 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,6 +47,7 @@ final class TextEditorMessages extends NLS { public static String TextEditorPreferencePage_findScopeColor; public static String TextEditorPreferencePage_accessibility_disableCustomCarets; public static String TextEditorPreferencePage_accessibility_wideCaret; + public static String TextEditorPreferencePage_accessibility_useSaturatedColorsInOverviewRuler; public static String TextEditorPreferencePage_showAffordance; public static String TextEditorPreferencePage_selectionForegroundColor; public static String TextEditorPreferencePage_selectionBackgroundColor; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties index ac2bf2c75bb..2d2eba92c28 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2010 IBM Corporation and others. +# Copyright (c) 2000, 2011 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -29,6 +29,7 @@ TextEditorPreferencePage_backgroundColor=Background color TextEditorPreferencePage_findScopeColor=Find scope TextEditorPreferencePage_accessibility_disableCustomCarets= Use &custom caret TextEditorPreferencePage_accessibility_wideCaret= &Enable thick caret +TextEditorPreferencePage_accessibility_useSaturatedColorsInOverviewRuler=U&se saturated colors in overview ruler TextEditorDefaultsPreferencePage_carriageReturn=Carriage Return ( \u00a4 ) TextEditorDefaultsPreferencePage_transparencyLevel=&Transparency level (0 is transparent and 255 is opaque): TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties=Configure visibility of whitespace characters in different regions of a line of text: diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java index 06fd1eb6918..5d264cbd6be 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java @@ -101,6 +101,7 @@ import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IChangeRulerColumn; import org.eclipse.jface.text.source.IOverviewRuler; +import org.eclipse.jface.text.source.IOverviewRulerExtension; import org.eclipse.jface.text.source.ISharedTextColors; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewerExtension; @@ -214,6 +215,13 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor { */ public final static String DEFAULT_OVERVIEW_RULER_CONTEXT_MENU_ID= "#OverviewRulerContext"; //$NON-NLS-1$ + /** + * Preference key that controls whether to use saturated colors in the overview ruler. + * + * @since 3.8 + */ + private static final String USE_SATURATED_COLORS_IN_OVERVIEW_RULER= AbstractDecoratedTextEditorPreferenceConstants.USE_SATURATED_COLORS_IN_OVERVIEW_RULER; + /** * Adapter class for <code>IGotoMarker</code>. @@ -452,6 +460,9 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor { if (isPrefQuickDiffAlwaysOn()) showChangeInformation(true); + if (fOverviewRuler instanceof IOverviewRulerExtension) + ((IOverviewRulerExtension)fOverviewRuler).setUseSaturatedColors(isPrefUseSaturatedColorsOn()); + if (!isOverwriteModeEnabled()) enableOverwriteMode(false); @@ -649,6 +660,18 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor { } /** + * Checks if the preference to use saturated colors is enabled for the overview ruler. + * + * @return <code>true</code> if the saturated colors preference is enabled, <code>false</code> + * otherwise + * @since 3.8 + */ + private boolean isPrefUseSaturatedColorsOn() { + IPreferenceStore store= getPreferenceStore(); + return store != null ? store.getBoolean(USE_SATURATED_COLORS_IN_OVERVIEW_RULER) : false; + } + + /** * Initializes the given line number ruler column from the preference store. * * @param rulerColumn the ruler column to be initialized @@ -802,6 +825,13 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor { return; } + if (USE_SATURATED_COLORS_IN_OVERVIEW_RULER.equals(property)) { + if (fOverviewRuler instanceof IOverviewRulerExtension) { + ((IOverviewRulerExtension)fOverviewRuler).setUseSaturatedColors(isPrefUseSaturatedColorsOn()); + fOverviewRuler.update(); + } + } + if (DISABLE_OVERWRITE_MODE.equals(property)) { enableOverwriteMode(isOverwriteModeEnabled()); return; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java index ed63933bd15..22a9a61e167 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -254,6 +254,17 @@ public class AbstractDecoratedTextEditorPreferenceConstants { public static final String EDITOR_WIDE_CARET= AbstractTextEditor.PREFERENCE_WIDE_CARET; /** + * A named preference that controls whether to use saturated colors in the overview ruler. + * <p> + * Value is of type <code>Boolean</code>. If <code>true</code>, saturated colors are used + * </p> + * + * @since 3.8 + * @see org.eclipse.jface.text.source.IOverviewRulerExtension#setUseSaturatedColors(boolean) + */ + public static final String USE_SATURATED_COLORS_IN_OVERVIEW_RULER= "Accessibility.UseSaturatedColors"; //$NON-NLS-1$; + + /** * A named preference that holds the color used as the text selection foreground. * This value has no effect if the system default color is used. * <p> @@ -677,6 +688,7 @@ public class AbstractDecoratedTextEditorPreferenceConstants { store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, false); store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, true); + store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_SATURATED_COLORS_IN_OVERVIEW_RULER, false); store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR, true); store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR, true); |