diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java index 4aaa8192dd0..00242740695 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 QNX Software Systems and others. + * Copyright (c) 2000, 2013 QNX Software Systems 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 @@ -10,6 +10,7 @@ * Anton Leherbauer (Wind River Systems) * IBM Corporation * Patrick Hofer - Bug 326265 + * Andrew Gvozdev *******************************************************************************/ package org.eclipse.cdt.make.internal.ui.editor; @@ -19,6 +20,7 @@ import org.eclipse.cdt.make.core.makefile.IDirective; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.actions.FoldingActionGroup; import org.eclipse.cdt.make.internal.ui.preferences.MakefileEditorPreferenceConstants; +import org.eclipse.cdt.make.internal.ui.text.ColorManager; import org.eclipse.cdt.make.internal.ui.text.makefile.MakefileWordDetector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.ListenerList; @@ -32,6 +34,7 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.rules.IWordDetector; +import org.eclipse.jface.text.source.DefaultCharacterPairMatcher; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; @@ -52,11 +55,11 @@ import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; +import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; public class MakefileEditor extends TextEditor implements ISelectionChangedListener, IReconcilingParticipant { - /** * The page that shows the outline. */ @@ -65,6 +68,12 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe ProjectionMakefileUpdater fProjectionMakefileUpdater; private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter; + /** Pairs of brackets, used to match. */ + protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' }; + + /** Matches the brackets. */ + protected DefaultCharacterPairMatcher fBracketMatcher = new DefaultCharacterPairMatcher(BRACKETS); + /** * The action group for folding. * @since 7.1 @@ -99,9 +108,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe super(); } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor() - */ @Override protected void initializeEditor() { setRangeIndicator(new DefaultRangeIndicator()); @@ -113,15 +119,17 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe setSourceViewerConfiguration(new MakefileSourceConfiguration(chainedStore, this)); } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ @Override public void dispose() { if (fProjectionMakefileUpdater != null) { fProjectionMakefileUpdater.uninstall(); fProjectionMakefileUpdater= null; } + if (fBracketMatcher != null) { + fBracketMatcher.dispose(); + fBracketMatcher = null; + } + super.dispose(); } @@ -129,9 +137,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe return MakeUIPlugin.getDefault().getPreferenceStore().getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); } - /* - * @see org.eclipse.ui.texteditor.AbstractTextEditor#rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) - */ @Override protected void rulerContextMenuAboutToShow(IMenuManager menu) { super.rulerContextMenuAboutToShow(menu); @@ -149,9 +154,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ @Override public void createPartControl(Composite parent) { super.createPartControl(parent); @@ -165,7 +167,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe projectionViewer.doOperation(ProjectionViewer.TOGGLE); } -// ProjectionAnnotationModel model= (ProjectionAnnotationModel) getAdapter(ProjectionAnnotationModel.class); + // ProjectionAnnotationModel model= (ProjectionAnnotationModel) getAdapter(ProjectionAnnotationModel.class); fProjectionMakefileUpdater= new ProjectionMakefileUpdater(); if (fProjectionMakefileUpdater != null) { @@ -184,9 +186,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe return viewer; } - /* (non-Javadoc) - * Method declared on IAdaptable - */ @SuppressWarnings("rawtypes") @Override public Object getAdapter(Class key) { @@ -203,9 +202,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe return super.getAdapter(key); } - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ @Override public void doSave(IProgressMonitor monitor) { super.doSave(monitor); @@ -214,9 +210,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe } } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() - */ @Override protected void createActions() { super.createActions(); @@ -249,9 +242,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe fFoldingGroup = new FoldingActionGroup(this, getSourceViewer()); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); @@ -334,9 +324,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe } } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) - */ @Override protected void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); @@ -432,26 +419,23 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe } } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent) - */ @Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; - String property = event.getProperty(); + String property = event.getProperty(); - MakefileSourceConfiguration makeConf = getMakefileSourceConfiguration(); - if (makeConf != null) { - if (makeConf.affectsBehavior(event)) { - makeConf.adaptToPreferenceChange(event); - sourceViewer.invalidateTextPresentation(); - } - } + MakefileSourceConfiguration makeConf = getMakefileSourceConfiguration(); + if (makeConf != null) { + if (makeConf.affectsBehavior(event)) { + makeConf.adaptToPreferenceChange(event); + sourceViewer.invalidateTextPresentation(); + } + } - if (MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) { + if (MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) { if (sourceViewer instanceof ProjectionViewer) { ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer; if (fProjectionMakefileUpdater != null) @@ -468,9 +452,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe super.handlePreferenceStoreChanged(event); } - /* - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages() - */ @Override protected String[] collectContextMenuPreferencePages() { // Add Makefile Editor relevant pages @@ -483,9 +464,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe return prefPageIds; } - /* - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isTabsToSpacesConversionEnabled() - */ @Override protected boolean isTabsToSpacesConversionEnabled() { // always false for Makefiles @@ -494,7 +472,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe } /* - * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes() * @see http://bugs.eclipse.org/172331 */ @Override @@ -502,9 +479,17 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe setKeyBindingScopes(new String [] { "org.eclipse.cdt.make.ui.makefileEditorScope" } ); //$NON-NLS-1$ } - @Override - public int getOrientation() { - return SWT.LEFT_TO_RIGHT; // bug 271449: Makefile editor should always be left to right - } + @Override + public int getOrientation() { + return SWT.LEFT_TO_RIGHT; // bug 271449: Makefile editor should always be left to right + } + + @Override + protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { + super.configureSourceViewerDecorationSupport(support); + //Enhance the stock source viewer decorator with a bracket matcher + support.setCharacterPairMatcher(fBracketMatcher); + support.setMatchingCharacterPainterPreferenceKeys(MakefileEditorPreferenceConstants.EDITOR_MATCHING_BRACKETS, ColorManager.MAKE_MATCHING_BRACKETS_COLOR); + } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferenceConstants.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferenceConstants.java index a8dc66e2403..58cce19b217 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferenceConstants.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferenceConstants.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2002, 2005 QNX Software Systems and others. + * Copyright (c) 2002, 2013 QNX Software Systems 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: - * QNX Software Systems - Initial API and implementation + * QNX Software Systems - Initial API and implementation + * Andrew Gvozdev *******************************************************************************/ package org.eclipse.cdt.make.internal.ui.preferences; @@ -17,9 +18,8 @@ import org.eclipse.jface.preference.IPreferenceStore; * MakefileEditorPreferenceConstants */ public class MakefileEditorPreferenceConstants { - /** - * + * Constructor. */ private MakefileEditorPreferenceConstants() { } @@ -30,8 +30,8 @@ public class MakefileEditorPreferenceConstants { */ public static final String CURRENT_LINE_COLOR = "org.eclipse.cdt.make.ui.currentLineHightlightColor"; //$NON-NLS-1$ public static final String LINE_NUMBER_RULER_COLOR = "org.eclipse.cdt.make.ui.lineNumberForegroundColor"; //$NON-NLS-1$ - public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.make.ui.printMarginColor"; //$NON-NLS-1$ - + public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.make.ui.printMarginColor"; //$NON-NLS-1$ + /** * Preference key suffix for bold text style preference keys. * @@ -43,24 +43,18 @@ public class MakefileEditorPreferenceConstants { */ public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$ - public static final String EDITOR_FOLDING_MACRODEF = "editor_folding_default_macrodef"; //$NON-NLS-1$ - - public static final String EDITOR_FOLDING_RULE = "editor_folding_default_rule"; //$NON-NLS-1$ - - public static final String EDITOR_FOLDING_CONDITIONAL = "editor_folding_default_conditional"; //$NON-NLS-1$ - public static final String EDITOR_FOLDING_ENABLED = "editor_folding_enabled"; //$NON-NLS-1$ - + public static final String EDITOR_MATCHING_BRACKETS = "editor_matching_brackets"; //$NON-NLS-1$ + public static void initializeDefaultValues(IPreferenceStore store) { - - store.setDefault(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED, false); - store.setDefault(MakefileEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF, false); - store.setDefault(MakefileEditorPreferenceConstants.EDITOR_FOLDING_RULE, true); - store.setDefault(MakefileEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL, true); - + store.setDefault(EDITOR_FOLDING_ENABLED, false); + store.setDefault(EDITOR_FOLDING_MACRODEF, false); + store.setDefault(EDITOR_FOLDING_RULE, true); + store.setDefault(EDITOR_FOLDING_CONDITIONAL, true); + store.setDefault(EDITOR_MATCHING_BRACKETS, true); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferencePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferencePage.java index 4340980f901..418bc055349 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferencePage.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileEditorPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. + * Copyright (c) 2002, 2013 QNX Software Systems 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 @@ -9,8 +9,8 @@ * QNX Software Systems - Initial API and implementation * IBM Corporation * Anton Leherbauer (Wind River Systems) + * Andrew Gvozdev *******************************************************************************/ - package org.eclipse.cdt.make.internal.ui.preferences; import java.util.ArrayList; @@ -54,12 +54,11 @@ import org.eclipse.ui.model.WorkbenchViewerComparator; * The page for setting the editor options. */ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferencePage { - /** The keys of the overlay store. */ private String[][] fSyntaxColorListModel; private TableViewer fHighlightingColorListViewer; - private final List fHighlightingColorList= new ArrayList(5); + private final List fHighlightingColorList= new ArrayList(7); Button fAppearanceColorDefault; ColorSelector fSyntaxForegroundColorEditor; @@ -145,26 +144,14 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen * @since 3.0 */ private class ColorListLabelProvider extends LabelProvider implements IColorProvider { - - /* - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ @Override public String getText(Object element) { return ((HighlightingColorListItem)element).getDisplayName(); } - - /* - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ @Override public Color getForeground(Object element) { return ((HighlightingColorListItem)element).getItemColor(); } - - /* - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ @Override public Color getBackground(Object element) { return null; @@ -177,34 +164,20 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen * @since 3.0 */ private class ColorListContentProvider implements IStructuredContentProvider { - - /* - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ @Override public Object[] getElements(Object inputElement) { return ((List)inputElement).toArray(); } - - /* - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ @Override public void dispose() { } - - /* - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } - - /** - * + * Constructor. */ public MakefileEditorPreferencePage() { super(); @@ -217,15 +190,17 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_macro_ref"), ColorManager.MAKE_MACRO_REF_COLOR, null}, //$NON-NLS-1$ {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_macro_def"), ColorManager.MAKE_MACRO_DEF_COLOR, null}, //$NON-NLS-1$ {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_function"), ColorManager.MAKE_FUNCTION_COLOR, null}, //$NON-NLS-1$ - {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_keyword"), ColorManager.MAKE_KEYWORD_COLOR, null}, //$NON-NLS-1$ - {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_default"), ColorManager.MAKE_DEFAULT_COLOR, null}, //$NON-NLS-1$ - }; + {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_keyword"), ColorManager.MAKE_KEYWORD_COLOR, null}, //$NON-NLS-1$ + {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_matching_bracket"), ColorManager.MAKE_MATCHING_BRACKETS_COLOR, null}, //$NON-NLS-1$ + {MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_default"), ColorManager.MAKE_DEFAULT_COLOR, null}, //$NON-NLS-1$ + }; ArrayList overlayKeys= new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, MakefileEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, MakefileEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, MakefileEditorPreferenceConstants.EDITOR_FOLDING_RULE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, MakefileEditorPreferenceConstants.EDITOR_MATCHING_BRACKETS)); for (int i= 0; i < fSyntaxColorListModel.length; i++) { String colorKey= fSyntaxColorListModel[i][1]; @@ -243,9 +218,6 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + MakefileEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)); } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ @Override protected Control createContents(Composite parent) { MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_EDITOR_PREFERENCE_PAGE); @@ -271,14 +243,13 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen } private void initialize() { - initializeFields(); for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) { fHighlightingColorList.add( - new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], - fSyntaxColorListModel[i][1] + MakefileEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, - fSyntaxColorListModel[i][1] + MakefileEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); + new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], + fSyntaxColorListModel[i][1] + MakefileEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, + fSyntaxColorListModel[i][1] + MakefileEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); } fHighlightingColorListViewer.setInput(fHighlightingColorList); fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); @@ -296,9 +267,6 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen fFoldingCheckbox.setSelection(enabled); } - /* (non-Javadoc) - * @see org.eclipse.ant.internal.ui.preferences.AbstractMakefileEditorPreferencePage#handleDefaults() - */ @Override protected void handleDefaults() { handleSyntaxColorListSelection(); @@ -306,7 +274,6 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen } private Control createSyntaxPage(Composite parent) { - Composite colorComposite= new Composite(parent, SWT.NONE); colorComposite.setLayout(new GridLayout()); @@ -423,7 +390,6 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - /* check box for new editors */ fFoldingCheckbox= new Button(composite, SWT.CHECK); fFoldingCheckbox.setText(MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.foldingenable")); //$NON-NLS-1$ @@ -448,8 +414,14 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen HighlightingColorListItem item= getHighlightingColorListItem(); RGB rgb= PreferenceConverter.getColor(getOverlayStore(), item.getColorKey()); fSyntaxForegroundColorEditor.setColorValue(rgb); - fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey())); - fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey())); + // Do not show "Bold" and "Italic" for matching brackets which is annotated as a highlighted box + boolean isTextType = ! MakefilePreferencesMessages.getString("MakefileEditorPreferencePage.makefile_editor_matching_bracket").equals(item.getDisplayName()); //$NON-NLS-1$ + fBoldCheckBox.setVisible(isTextType); + fItalicCheckBox.setVisible(isTextType); + if (isTextType) { + fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey())); + fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey())); + } } /** @@ -463,9 +435,6 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen return (HighlightingColorListItem) selection.getFirstElement(); } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ @Override public boolean performOk() { return super.performOk(); @@ -479,6 +448,7 @@ public class MakefileEditorPreferencePage extends AbstractMakefileEditorPreferen PreferenceConverter.setDefault(prefs, ColorManager.MAKE_KEYWORD_COLOR, ColorManager.MAKE_KEYWORD_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MACRO_DEF_COLOR, ColorManager.MAKE_MACRO_DEF_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MACRO_REF_COLOR, ColorManager.MAKE_MACRO_REF_RGB); + PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MATCHING_BRACKETS_COLOR, ColorManager.MAKE_MATCHING_BRACKETS_RGB); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefilePreferencesMessages.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefilePreferencesMessages.properties index 64b7d046363..e3ccfc80fad 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefilePreferencesMessages.properties +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefilePreferencesMessages.properties @@ -47,13 +47,14 @@ MakefileEditorPreferencePage.italic=I&talic MakefileEditorPreferencePage.folding= &Folding MakefileEditorPreferencePage.foldingenable= Enable folding when &opening a new editor -MakefileEditorPreferencePage.makefile_editor_comment=comment -MakefileEditorPreferencePage.makefile_editor_macro_def=macro definition -MakefileEditorPreferencePage.makefile_editor_macro_ref=macro reference -MakefileEditorPreferencePage.makefile_editor_function=function -MakefileEditorPreferencePage.makefile_editor_keyword=keyword -MakefileEditorPreferencePage.makefile_editor_target=target -MakefileEditorPreferencePage.makefile_editor_default=default +MakefileEditorPreferencePage.makefile_editor_comment=Comment +MakefileEditorPreferencePage.makefile_editor_macro_def=Macro definition +MakefileEditorPreferencePage.makefile_editor_macro_ref=Macro reference +MakefileEditorPreferencePage.makefile_editor_function=Function +MakefileEditorPreferencePage.makefile_editor_keyword=Keyword +MakefileEditorPreferencePage.makefile_editor_target=Target +MakefileEditorPreferencePage.makefile_editor_matching_bracket=Matching brackets highlight +MakefileEditorPreferencePage.makefile_editor_default=Default MakefileSettingsPreferencePage.style=Style of Makefile MakefileSettingsPreferencePage.path.label=Makefile include directories diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/ColorManager.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/ColorManager.java index 20fe2083bd3..24d7ee1f640 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/ColorManager.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/ColorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 QNX Software Systems and others. + * Copyright (c) 2000, 2013 QNX Software Systems 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 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Andrew Gvozdev *******************************************************************************/ package org.eclipse.cdt.make.internal.ui.text; @@ -27,6 +28,7 @@ public class ColorManager implements ISharedTextColors { public static final String MAKE_MACRO_REF_COLOR = "org.eclipse.cdt.make.ui.editor.macro_ref"; //$NON-NLS-1$ public static final String MAKE_MACRO_DEF_COLOR = "org.eclipse.cdt.make.ui.editor.macro_def"; //$NON-NLS-1$ public static final String MAKE_DEFAULT_COLOR = "org.eclipse.cdt.make.ui.editor.default"; //$NON-NLS-1$ + public static final String MAKE_MATCHING_BRACKETS_COLOR = "org.eclipse.cdt.make.ui.editor.matching.brackets.color"; //$NON-NLS-1$ public static final RGB MAKE_COMMENT_RGB = new RGB(128, 0, 0); public static final RGB MAKE_KEYWORD_RGB = new RGB(128, 255, 0); @@ -34,6 +36,7 @@ public class ColorManager implements ISharedTextColors { public static final RGB MAKE_MACRO_DEF_RGB = new RGB(0, 0, 128); public static final RGB MAKE_MACRO_REF_RGB = new RGB(0, 128, 0); public static final RGB MAKE_DEFAULT_RGB = new RGB(0, 0, 0); + public static final RGB MAKE_MATCHING_BRACKETS_RGB = new RGB(170,170,170); private static ColorManager fgColorManager; @@ -56,7 +59,7 @@ public class ColorManager implements ISharedTextColors { public void dispose() { Iterator e = fColorTable.values().iterator(); while (e.hasNext()) - (e.next()).dispose(); + (e.next()).dispose(); } /* (non-Javadoc)