diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java index 94ec7da93f5..cee355b87f1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java @@ -64,7 +64,6 @@ public class FoldingTest extends TestCase { IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, true); - store.setValue(PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED, true); store.setValue(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, true); store.setValue(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, false); store.setValue(PreferenceConstants.EDITOR_FOLDING_HEADERS, false); @@ -82,7 +81,6 @@ public class FoldingTest extends TestCase { IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED); - store.setToDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS); diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index de541048d8b..66a450b146c 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -139,6 +139,8 @@ CodeFormatterPreferencePage.name=Code Style CodeAssistPreferencePage.name=Content Assist SmartTypingPreferencePage.name=Typing ColoringPreferencePage.name=Syntax Coloring +FoldingPreferencePage.name=Folding +HoverPreferencePage.name=Hovers todoPageName=C/C++ Task Tags todoTaskPrefName=Task Tags diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index ee629ab3515..dad49f76da3 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -585,6 +585,16 @@ category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage" class="org.eclipse.cdt.internal.ui.preferences.CEditorColoringPreferencePage" id="org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"/> + + - - + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties index 8bd76e1b85a..278296a4fb7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties @@ -276,8 +276,6 @@ Editor.error.revert.message=Internal error: Editor.error.no_input=Unable to read text editor input Editor.error.invalid_input=Invalid text editor input -CEditorPreferencePage.description= C/C++ Editor Preferences - # ------- OpenIncludeDeclarationAction------------ OpenIncludeAction.label=&Open diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java index d29da913da6..bd533cf38c9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java @@ -54,6 +54,7 @@ public interface ICHelpContextIds { public static final String C_EDITOR_NAVIGATION_PAGE = PREFIX + "c_editor_navigation"; //$NON-NLS-1$ public static final String C_EDITOR_HOVERS_PAGE = PREFIX + "c_editor_hov"; //$NON-NLS-1$ public static final String C_EDITOR_TYPING_PAGE = PREFIX + "c_editor_typing"; //$NON-NLS-1$; + public static final String C_EDITOR_FOLDING_PAGE = PREFIX + "c_editor_folding"; //$NON-NLS-1$; public static final String FILE_TYPES_STD_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$ public static final String FILE_TYPES_MAN_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$ public static final String FILE_TYPES_PREF_PAGE = PREFIX + "c_file_types"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 515d5e0b848..c6abf80a866 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -2915,10 +2915,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR protected String[] collectContextMenuPreferencePages() { // Add C/C++ Editor relevant pages String[] parentPrefPageIds = super.collectContextMenuPreferencePages(); - String[] prefPageIds = new String[parentPrefPageIds.length + 6]; + String[] prefPageIds = new String[parentPrefPageIds.length + 8]; int nIds = 0; prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$ prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$ + prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.HoverPreferencePage"; //$NON-NLS-1$ + prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.FoldingPreferencePage"; //$NON-NLS-1$ prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"; //$NON-NLS-1$ prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$ prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties index ccd4ac622a3..0d7a98c7f3d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties @@ -21,8 +21,6 @@ AddIncludeOnSelection.error.message4=BadLocationException: AddIncludeOnSelection.label=Add Include AddIncludeOnSelection.tooltip=Add Include Statement on Selection -CEditorPreferencePage.description= C Editor Preferences - OpenHierarchy.description=Show the type hierarchy of the selected element OpenHierarchy.dialog.message=&Select the type to open: OpenHierarchy.dialog.title=Open Type Hierarchy diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java index 2bed9190c03..64e1183fe78 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java @@ -692,9 +692,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener, * Invalidate text presentation of all positions. */ private void invalidateTextPresentation() { - for (int i= 0, n= fPositions.size(); i < n; i++) { - Position position= (Position) fPositions.get(i); - fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength()); + if (fPositions.size() > 1000) { + fSourceViewer.invalidateTextPresentation(); + } else { + for (int i= 0, n= fPositions.size(); i < n; i++) { + Position position= (Position) fPositions.get(i); + fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength()); + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java index d70c21e8a38..4b42f31da1a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java @@ -19,8 +19,11 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; - +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -34,21 +37,13 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.resource.JFaceResources; - -import org.eclipse.jface.text.Assert; - import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.cdt.internal.ui.util.Messages; - import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.internal.ui.util.PixelConverter; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index 7298a87b14e..9746787b7e9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -26,6 +26,7 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.viewers.IColorProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -40,6 +41,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; @@ -49,6 +51,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.ScrollBar; @@ -187,7 +190,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /** * Color list label provider. */ - private class ColorListLabelProvider extends LabelProvider { + private class ColorListLabelProvider extends LabelProvider implements IColorProvider { /* * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ @@ -196,6 +199,25 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return (String) element; return ((HighlightingColorListItem)element).getDisplayName(); } + + /* + * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) + */ + public Color getBackground(Object element) { + return null; + } + + /* + * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) + */ + public Color getForeground(Object element) { + if (element instanceof SemanticHighlightingColorListItem) { + if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) { + return Display.getDefault().getSystemColor(SWT.COLOR_GRAY); + } + } + return null; + } } /** @@ -294,6 +316,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { private ColorSelector fSyntaxForegroundColorEditor; private Label fColorEditorLabel; + private Button fEnableSemanticHighlightingCheckbox; private Button fBoldCheckBox; private Button fEnableCheckbox; /** @@ -451,6 +474,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { public void performDefaults() { super.performDefaults(); + fEnableSemanticHighlightingCheckbox.setSelection(getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)); + fListViewer.refresh(); + handleSyntaxColorListSelection(); uninstallSemanticHighlighting(); @@ -488,8 +514,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey())); fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey())); if (item instanceof SemanticHighlightingColorListItem) { - fEnableCheckbox.setEnabled(true); - boolean enable= getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey()); + boolean semanticHighlightingEnabled= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED); + fEnableCheckbox.setEnabled(semanticHighlightingEnabled); + boolean enable= semanticHighlightingEnabled && getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey()); fEnableCheckbox.setSelection(enable); fSyntaxForegroundColorEditor.getButton().setEnabled(enable); fColorEditorLabel.setEnabled(enable); @@ -534,6 +561,13 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { link.setLayoutData(gridData); addFiller(colorComposite, 1); + + fEnableSemanticHighlightingCheckbox= new Button(colorComposite, SWT.CHECK); + fEnableSemanticHighlightingCheckbox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_enable_semantic_highlighting); + gridData= new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalAlignment= GridData.BEGINNING; + gridData.horizontalSpan= 1; + fEnableSemanticHighlightingCheckbox.setLayoutData(gridData); Label label; label= new Label(colorComposite, SWT.LEFT); @@ -722,6 +756,23 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { } }); + fEnableSemanticHighlightingCheckbox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + if (item instanceof SemanticHighlightingColorListItem) { + boolean enable= fEnableSemanticHighlightingCheckbox.getSelection(); + getPreferenceStore().setValue(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, enable); + fListViewer.refresh(); + handleSyntaxColorListSelection(); + uninstallSemanticHighlighting(); + installSemanticHighlighting(); + } + } + }); + colorComposite.layout(false); return colorComposite; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java index ae2cec7b7eb..c896bc2b53b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2005 QNX Software Systems and others. + * Copyright (c) 2002, 2006 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 + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; @@ -15,19 +16,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.StringTokenizer; -import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; -import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; -import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; -import org.eclipse.cdt.internal.ui.util.PixelConverter; -import org.eclipse.cdt.internal.ui.util.SWTUtil; -import org.eclipse.cdt.internal.ui.util.TableLayoutComposite; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.text.Assert; +import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ColumnWeightData; @@ -60,10 +53,21 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; +import org.eclipse.cdt.internal.ui.util.PixelConverter; +import org.eclipse.cdt.internal.ui.util.SWTUtil; +import org.eclipse.cdt.internal.ui.util.TableLayoutComposite; + /** * CEditorHoverConfigurationBlock */ -public class CEditorHoverConfigurationBlock { +public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock { static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter; private static final int ENABLED_PROP= 0; @@ -152,11 +156,11 @@ public class CEditorHoverConfigurationBlock { //private Button fShowHoverAffordanceCheckbox; private Button fShowEditorAnnotationCheckbox; - private CEditorPreferencePage fMainPreferencePage; + private PreferencePage fMainPreferencePage; private StatusInfo fStatus; - public CEditorHoverConfigurationBlock(CEditorPreferencePage mainPreferencePage, OverlayPreferenceStore store) { + public CEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) { Assert.isNotNull(mainPreferencePage); Assert.isNotNull(store); fMainPreferencePage= mainPreferencePage; @@ -180,11 +184,8 @@ public class CEditorHoverConfigurationBlock { return keys; } - /** - * Creates page for hover preferences. - * - * @param parent the parent composite - * @return the control for the preference page + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite) */ public Control createControl(Composite parent) { @@ -380,7 +381,10 @@ public class CEditorHoverConfigurationBlock { return CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); } - void initialize() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize() + */ + public void initialize() { CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers(); fHoverConfigs= new HoverConfig[hoverDescs.length]; for (int i= 0; i < hoverDescs.length; i++) @@ -403,7 +407,10 @@ public class CEditorHoverConfigurationBlock { fHoverTableViewer.refresh(); } - void performOk() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk() + */ + public void performOk() { StringBuffer buf= new StringBuffer(); StringBuffer maskBuf= new StringBuffer(); for (int i= 0; i < fHoverConfigs.length; i++) { @@ -430,7 +437,10 @@ public class CEditorHoverConfigurationBlock { CUIPlugin.getDefault().resetCEditorTextHoverDescriptors(); } - void performDefaults() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults() + */ + public void performDefaults() { fStatus= new StatusInfo(); restoreFromPreferences(); initializeFields(); @@ -553,12 +563,8 @@ public class CEditorHoverConfigurationBlock { i++; } - if (fStatus.isOK()) - fMainPreferencePage.updateStatus(fStatus); - else { - fMainPreferencePage.setValid(false); - StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus); - } + fMainPreferencePage.setValid(fStatus.isOK()); + StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java new file mode 100644 index 00000000000..b9a006bdf40 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 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 + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.preferences; + + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; + +/** + * The page for setting the editor hover options. + */ +public final class CEditorHoverPreferencePage extends AbstractConfigurationBlockPreferencePage { + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() + */ + protected String getHelpId() { + return ICHelpContextIds.C_EDITOR_HOVERS_PAGE; + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() + */ + protected void setDescription() { + String description= PreferencesMessages.CEditorPreferencePage_hover_title; + setDescription(description); + } + + /* + * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() + */ + protected void setPreferenceStore() { + setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + } + + + protected Label createDescriptionLabel(Composite parent) { + return null; // no description for new look. + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) + */ + protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { + return new CEditorHoverConfigurationBlock(this, overlayPreferenceStore); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index 4443d02f193..a1b244d3c75 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -32,16 +32,12 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; -import org.eclipse.cdt.utils.ui.controls.TabFolderLayout; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -56,23 +52,13 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo {PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null }, }; - protected List fList; - protected ColorSelector fForegroundColorEditor; - protected Button fBoldCheckBox; - - private CEditorHoverConfigurationBlock fCEditorHoverConfigurationBlock; - private FoldingConfigurationBlock fFoldingConfigurationBlock; - private List fAppearanceColorList; - private ColorSelector fAppearanceColorEditor; - private Button fAppearanceColorDefault; public CEditorPreferencePage() { super(); - setDescription(CUIPlugin.getResourceString("CEditorPreferencePage.description")); //$NON-NLS-1$ } protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { @@ -265,6 +251,9 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null); } }); + // TODO replace by link-specific tooltips when + // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed + link.setToolTipText(PreferencesMessages.CEditorPreferencePage_link_tooltip); GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint= 150; // only expand further if anyone else requires it @@ -277,33 +266,16 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo */ protected Control createContents(Composite parent) { - fCEditorHoverConfigurationBlock= new CEditorHoverConfigurationBlock(this, fOverlayStore); - fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore); - fOverlayStore.load(); fOverlayStore.start(); createHeader(parent); - TabFolder folder = new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); - folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem item = new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.CEditorPreferencePage_generalTabTitle); - item.setControl(createAppearancePage(folder)); - - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.CEditorPreferencePage_hoverTab_title); - item.setControl(fCEditorHoverConfigurationBlock.createControl(folder)); - - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.CEditorPreferencePage_folding_title); - item.setControl(fFoldingConfigurationBlock.createControl(folder)); + createAppearancePage(parent); initialize(); - return folder; + return parent; } private void initialize() { @@ -320,45 +292,28 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo } }); - fFoldingConfigurationBlock.initialize(); - } /* - * @see PreferencePage#performOk() + * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performOk() */ public boolean performOk() { - fCEditorHoverConfigurationBlock.performOk(); - fFoldingConfigurationBlock.performOk(); return super.performOk(); } /* - * @see PreferencePage#performDefaults() + * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performDefaults() */ protected void performDefaults() { - super.performDefaults(); handleAppearanceColorListSelection(); - - fCEditorHoverConfigurationBlock.performDefaults(); - fFoldingConfigurationBlock.performDefaults(); - } /* - * @see DialogPage#dispose() + * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#dispose() */ public void dispose() { - - fFoldingConfigurationBlock.dispose(); - - if (fOverlayStore != null) { - fOverlayStore.stop(); - fOverlayStore = null; - } - super.dispose(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java index f3373d06036..551738d7164 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java @@ -16,16 +16,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor; -import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry; -import org.eclipse.cdt.internal.ui.util.PixelConverter; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.PreferenceConstants; -import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.text.Assert; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; @@ -48,12 +42,20 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; + +import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor; +import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry; +import org.eclipse.cdt.internal.ui.util.PixelConverter; + /** * Configures C Editor folding preferences. * * @since 3.0 */ -class FoldingConfigurationBlock { +class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { private static class ErrorPreferences implements ICFoldingPreferenceBlock { private String fMessage; @@ -135,13 +137,10 @@ class FoldingConfigurationBlock { return keys; } - /** - * Creates page for folding preferences. - * - * @param parent the parent composite - * @return the control for the preference page + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite) */ - Control createControl(Composite parent) { + public Control createControl(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); // assume parent page uses griddata @@ -307,18 +306,27 @@ class FoldingConfigurationBlock { prefs.initialize(); } - void initialize() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize() + */ + public void initialize() { restoreFromPreferences(); } - void performOk() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk() + */ + public void performOk() { for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); prefs.performOk(); } } - void performDefaults() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults() + */ + public void performDefaults() { restoreFromPreferences(); for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); @@ -326,7 +334,10 @@ class FoldingConfigurationBlock { } } - void dispose() { + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() + */ + public void dispose() { for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); prefs.dispose(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java new file mode 100644 index 00000000000..57d75fdb3b1 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 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 + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.preferences; + + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; + +/** + * The page for setting the editor folding options. + */ +public final class FoldingPreferencePage extends AbstractConfigurationBlockPreferencePage { + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() + */ + protected String getHelpId() { + return ICHelpContextIds.C_EDITOR_FOLDING_PAGE; + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() + */ + protected void setDescription() { + String description= PreferencesMessages.CEditorPreferencePage_folding_title; + setDescription(description); + } + + /* + * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() + */ + protected void setPreferenceStore() { + setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + } + + + protected Label createDescriptionLabel(Composite parent) { + return null; // no description for new look. + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) + */ + protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { + return new FoldingConfigurationBlock(overlayPreferenceStore); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index be541ae1a24..7c01ee4fabc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -60,7 +60,7 @@ public final class PreferencesMessages extends NLS { public static String TodoTaskInputDialog_error_entryExists; public static String TodoTaskInputDialog_error_noSpace; public static String CEditorPreferencePage_link; - public static String CEditorPreferencePage_generalTabTitle; + public static String CEditorPreferencePage_link_tooltip; public static String CEditorPreferencePage_colors; public static String CEditorPreferencePage_invalid_input; public static String CEditorPreferencePage_empty_input; @@ -99,6 +99,7 @@ public final class PreferencesMessages extends NLS { public static String CEditorColoringConfigurationBlock_coloring_category_preprocessor; public static String CEditorColoringConfigurationBlock_coloring_element; public static String CEditorColoringConfigurationBlock_link; + public static String CEditorColoringConfigurationBlock_enable_semantic_highlighting; public static String CEditorColoringConfigurationBlock_enable; public static String CEditorColoringConfigurationBlock_preview; public static String CEditorColoringConfigurationBlock_color; @@ -136,7 +137,7 @@ public final class PreferencesMessages extends NLS { public static String CFileTypeDialog_title; public static String CFileTypeDialog_patternLabel; public static String CFileTypeDialog_typeLabel; - public static String CEditorPreferencePage_hoverTab_title; + public static String CEditorPreferencePage_hover_title; public static String CEditorHoverConfigurationBlock_hoverPreferences; public static String CEditorHoverConfigurationBlock_keyModifier; public static String CEditorHoverConfigurationBlock_description; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index 8b42ca38a28..75a782818ce 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -60,8 +60,9 @@ TodoTaskInputDialog_error_comma=Name cannot contain a comma. TodoTaskInputDialog_error_entryExists=Entry with the same name already exists. TodoTaskInputDialog_error_noSpace=Name can not start or end with a whitespace. -CEditorPreferencePage_link=Note that some preferences may be set on the Text Editors preference page. -CEditorPreferencePage_generalTabTitle=Appeara&nce +CEditorPreferencePage_link=C/C++ Editor Preferences. Note that some preferences may be set on the Text Editors preference page. +CEditorPreferencePage_link_tooltip=Show the shared text editor preferences + CEditorPreferencePage_colors=Synta&x CEditorPreferencePage_invalid_input=Invalid input. @@ -102,6 +103,7 @@ CEditorColoringConfigurationBlock_coloring_category_preprocessor=Preprocessor CEditorColoringConfigurationBlock_coloring_element=Element: # DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts" CEditorColoringConfigurationBlock_link=Default colors and font can be configured on the Text Editors and on the Colors and Fonts preference page. +CEditorColoringConfigurationBlock_enable_semantic_highlighting=Enable semantic highlighting CEditorColoringConfigurationBlock_enable=Enab&le CEditorColoringConfigurationBlock_preview=Previe&w: CEditorColoringConfigurationBlock_color=C&olor: @@ -144,8 +146,8 @@ CFileTypeDialog_title=C/C++ File Type CFileTypeDialog_patternLabel=Pattern: CFileTypeDialog_typeLabel=Type: -# Hover tab -CEditorPreferencePage_hoverTab_title= Ho&vers +# Hover page +CEditorPreferencePage_hover_title= Ho&vers CEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences: CEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering: CEditorHoverConfigurationBlock_description= Description: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java index 43617cf9564..ca67f720c51 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java @@ -29,7 +29,6 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.PreferenceConstants; /** * Preference page for work in progress. @@ -84,10 +83,7 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor result.setLayout(layout); // Add your controls here - addCheckBox(result, "Enable semantic highlighting", PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED); //$NON-NLS-1$ - addCheckBox(result, "Enable folding of preprocessor branches (#if/#endif)", PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED); //$NON-NLS-1$ - addCheckBox(result, "Enable comment folding", PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED); //$NON-NLS-1$ - + applyDialogFont(result); return result; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java index dc82afb9f94..a20cc24ee2d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java @@ -11,11 +11,12 @@ package org.eclipse.cdt.internal.ui.text.folding; -import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; -import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jface.text.Assert; + +import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; +import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider; /** * Describes a contribution to the folding provider extension point. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java index bcc4c0c4580..766a3daf165 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java @@ -17,11 +17,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore; -import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.PreferenceConstants; -import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -31,7 +26,14 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; + +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; + +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; /** */ @@ -47,9 +49,12 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; - fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + String key= (String) fCheckBoxes.get(button); + fOverlayStore.setValue(key, button.getSelection()); + updateEnablement(key); } }; + private Button fInactiveCodeFoldingCheckBox; public DefaultCFoldingPreferenceBlock() { @@ -68,6 +73,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_COMMENTS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_HEADERS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED)); return (OverlayKey[]) overlayKeys.toArray(new OverlayKey[overlayKeys.size()]); } @@ -84,17 +90,19 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock layout.verticalSpacing= 3; layout.marginWidth= 0; inner.setLayout(layout); - - Label label= new Label(inner, SWT.LEFT); - label.setText(FoldingMessages.getString("DefaultCFoldingPreferenceBlock.title")); //$NON-NLS-1$ - - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.macros"), PreferenceConstants.EDITOR_FOLDING_MACROS, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.functions"), PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.methods"), PreferenceConstants.EDITOR_FOLDING_METHODS, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.structures"), PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.comments"), PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.headers"), PreferenceConstants.EDITOR_FOLDING_HEADERS, 0); //$NON-NLS-1$ - addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.inactive_code"), PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0); //$NON-NLS-1$ + + addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_preprocessor_enabled, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, 1); + ControlFactory.createEmptySpace(inner); + + Composite group= ControlFactory.createGroup(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_title, 1); + + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_macros, PreferenceConstants.EDITOR_FOLDING_MACROS, 0); + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_functions, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0); + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_methods, PreferenceConstants.EDITOR_FOLDING_METHODS, 0); + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_structures, PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0); + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_comments, PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0); + addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_headers, PreferenceConstants.EDITOR_FOLDING_HEADERS, 0); + fInactiveCodeFoldingCheckBox= addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_inactive_code, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0); return inner; } @@ -121,9 +129,16 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock Button b= (Button) it.next(); String key= (String) fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); + updateEnablement(key); } } - + + protected void updateEnablement(String key) { + if (PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED.equals(key)) { + fInactiveCodeFoldingCheckBox.setEnabled(fOverlayStore.getBoolean(key)); + } + } + /* * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#performOk() */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java index f71e57f106f..39425c2db3f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java @@ -24,12 +24,12 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; @@ -849,7 +849,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi fCollapseComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS); fCollapseInactiveCode= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE); fPreprocessorBranchFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED); - fCommentFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED); + fCommentFoldingEnabled= true; } private void update(FoldingStructureComputationContext ctx) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java index 0df9cb18d3e..10c5eb00e1f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java @@ -40,7 +40,7 @@ public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock { label.setLayoutData(gd); label= new Label(inner, SWT.CENTER); - label.setText(FoldingMessages.getString("EmptyCFoldingPreferenceBlock.emptyCaption")); //$NON-NLS-1$ + label.setText(FoldingMessages.EmptyCFoldingPreferenceBlock_emptyCaption); gd= new GridData(GridData.CENTER); label.setLayoutData(gd); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java index bb1837758cb..10792344e96 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java @@ -8,29 +8,30 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.ui.text.folding; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.eclipse.osgi.util.NLS; -/** - * @since 3.0 - */ -class FoldingMessages { +public final class FoldingMessages extends NLS { - private static final String BUNDLE_NAME= FoldingMessages.class.getName(); - - private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); + private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.text.folding.FoldingMessages";//$NON-NLS-1$ private FoldingMessages() { + // Do not instantiate } - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } + public static String DefaultCFoldingPreferenceBlock_title; + public static String DefaultCFoldingPreferenceBlock_macros; + public static String DefaultCFoldingPreferenceBlock_functions; + public static String DefaultCFoldingPreferenceBlock_methods; + public static String DefaultCFoldingPreferenceBlock_structures; + public static String DefaultCFoldingPreferenceBlock_comments; + public static String DefaultCFoldingPreferenceBlock_headers; + public static String DefaultCFoldingPreferenceBlock_inactive_code; + public static String DefaultCFoldingPreferenceBlock_preprocessor_enabled; + public static String EmptyCFoldingPreferenceBlock_emptyCaption; + + static { + NLS.initializeMessages(BUNDLE_NAME, FoldingMessages.class); } -} +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties index bb2b532e042..d32f71c07d6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties @@ -11,13 +11,14 @@ ############################################################################### -DefaultCFoldingPreferenceBlock.title= Initially fold these region types: -DefaultCFoldingPreferenceBlock.macros= &Macros -DefaultCFoldingPreferenceBlock.functions= &Functions -DefaultCFoldingPreferenceBlock.methods= &Methods -DefaultCFoldingPreferenceBlock.structures= &Structures -DefaultCFoldingPreferenceBlock.comments= &Comments -DefaultCFoldingPreferenceBlock.headers= &Header Comments -DefaultCFoldingPreferenceBlock.inactive_code= &Inactive Preprocessor Branches +DefaultCFoldingPreferenceBlock_title= Initially fold these region types: +DefaultCFoldingPreferenceBlock_macros= &Macros +DefaultCFoldingPreferenceBlock_functions= &Functions +DefaultCFoldingPreferenceBlock_methods= &Methods +DefaultCFoldingPreferenceBlock_structures= &Structures +DefaultCFoldingPreferenceBlock_comments= &Comments +DefaultCFoldingPreferenceBlock_headers= &Header Comments +DefaultCFoldingPreferenceBlock_inactive_code= &Inactive Preprocessor Branches +DefaultCFoldingPreferenceBlock_preprocessor_enabled= Enable folding of preprocessor branches (#if/#endif) -EmptyCFoldingPreferenceBlock.emptyCaption= +EmptyCFoldingPreferenceBlock_emptyCaption= diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index eba047022b5..97514b5c1d7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -872,16 +872,6 @@ public class PreferenceConstants { */ public static final String EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED= "editor_folding_preprocessor_enabled"; //$NON-NLS-1$ - /** - * A named preference that controls whether folding of comments is enabled. - *

- * Value is of type Boolean. - *

- * - * @since 4.0 - */ - public static final String EDITOR_FOLDING_COMMENTS_ENABLED= "editor_folding_comments_enabled"; //$NON-NLS-1$ - /** * A named preference that controls if templates are formatted when applied. *

@@ -1087,7 +1077,6 @@ public class PreferenceConstants { store.setDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS, false); store.setDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS, true); store.setDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, true); - store.setDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED, false); store.setDefault(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, false); store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true); diff --git a/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml b/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml index 03145983967..961e91a8df8 100644 --- a/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml +++ b/doc/org.eclipse.cdt.doc.user/contexts_CDT.xml @@ -128,6 +128,16 @@ + + Click below to see help. + + + + Click below to see help. + + Click below to see help.