1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

80104 - Maintain consistency with JDT UI

Extracted Folding and Hovers tab pages into separate preference pages
This commit is contained in:
Anton Leherbauer 2006-11-13 09:44:14 +00:00
parent c7d8278a6a
commit 908501d4a6
26 changed files with 364 additions and 197 deletions

View file

@ -64,7 +64,6 @@ public class FoldingTest extends TestCase {
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, true); 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_PREPROCESSOR_BRANCHES_ENABLED, true);
store.setValue(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, false); store.setValue(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, false);
store.setValue(PreferenceConstants.EDITOR_FOLDING_HEADERS, false); store.setValue(PreferenceConstants.EDITOR_FOLDING_HEADERS, false);
@ -82,7 +81,6 @@ public class FoldingTest extends TestCase {
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
store.setToDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED); 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_PREPROCESSOR_BRANCHES_ENABLED);
store.setToDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE);
store.setToDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS); store.setToDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS);

View file

@ -139,6 +139,8 @@ CodeFormatterPreferencePage.name=Code Style
CodeAssistPreferencePage.name=Content Assist CodeAssistPreferencePage.name=Content Assist
SmartTypingPreferencePage.name=Typing SmartTypingPreferencePage.name=Typing
ColoringPreferencePage.name=Syntax Coloring ColoringPreferencePage.name=Syntax Coloring
FoldingPreferencePage.name=Folding
HoverPreferencePage.name=Hovers
todoPageName=C/C++ Task Tags todoPageName=C/C++ Task Tags
todoTaskPrefName=Task Tags todoTaskPrefName=Task Tags

View file

@ -585,6 +585,16 @@
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage" category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CEditorColoringPreferencePage" class="org.eclipse.cdt.internal.ui.preferences.CEditorColoringPreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"/> id="org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"/>
<page
name="%FoldingPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.FoldingPreferencePage"
id="org.eclipse.cdt.ui.preferences.FoldingPreferencePage"/>
<page
name="%HoverPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CEditorHoverPreferencePage"
id="org.eclipse.cdt.ui.preferences.HoverPreferencePage"/>
<page <page
name="%CPluginTemplatePreferencePage.name" name="%CPluginTemplatePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage" category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
@ -637,12 +647,12 @@
class="org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage" class="org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage"
id="org.eclipse.cdt.ui.preferences.IndexerPreferencePage" id="org.eclipse.cdt.ui.preferences.IndexerPreferencePage"
name="%indexerPrefName"/> name="%indexerPrefName"/>
<page <!--page
name="%WorkInProgress.name" name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage" class="org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage"
id="org.eclipse.cdt.ui.preferneces.WorkInProgressPreferencePage"> id="org.eclipse.cdt.ui.preferneces.WorkInProgressPreferencePage">
</page> </page-->
</extension> </extension>
<extension <extension
point="org.eclipse.ui.editorActions"> point="org.eclipse.ui.editorActions">

View file

@ -276,8 +276,6 @@ Editor.error.revert.message=Internal error:
Editor.error.no_input=Unable to read text editor input Editor.error.no_input=Unable to read text editor input
Editor.error.invalid_input=Invalid text editor input Editor.error.invalid_input=Invalid text editor input
CEditorPreferencePage.description= C/C++ Editor Preferences
# ------- OpenIncludeDeclarationAction------------ # ------- OpenIncludeDeclarationAction------------
OpenIncludeAction.label=&Open OpenIncludeAction.label=&Open

View file

@ -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_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_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_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_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_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$ public static final String FILE_TYPES_PREF_PAGE = PREFIX + "c_file_types"; //$NON-NLS-1$

View file

@ -2915,10 +2915,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
protected String[] collectContextMenuPreferencePages() { protected String[] collectContextMenuPreferencePages() {
// Add C/C++ Editor relevant pages // Add C/C++ Editor relevant pages
String[] parentPrefPageIds = super.collectContextMenuPreferencePages(); String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
String[] prefPageIds = new String[parentPrefPageIds.length + 6]; String[] prefPageIds = new String[parentPrefPageIds.length + 8];
int nIds = 0; int nIds = 0;
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$ 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.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.CodeColoringPreferencePage"; //$NON-NLS-1$
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$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$ prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$

View file

@ -21,8 +21,6 @@ AddIncludeOnSelection.error.message4=BadLocationException:
AddIncludeOnSelection.label=Add Include AddIncludeOnSelection.label=Add Include
AddIncludeOnSelection.tooltip=Add Include Statement on Selection AddIncludeOnSelection.tooltip=Add Include Statement on Selection
CEditorPreferencePage.description= C Editor Preferences
OpenHierarchy.description=Show the type hierarchy of the selected element OpenHierarchy.description=Show the type hierarchy of the selected element
OpenHierarchy.dialog.message=&Select the type to open: OpenHierarchy.dialog.message=&Select the type to open:
OpenHierarchy.dialog.title=Open Type Hierarchy OpenHierarchy.dialog.title=Open Type Hierarchy

View file

@ -692,9 +692,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* Invalidate text presentation of all positions. * Invalidate text presentation of all positions.
*/ */
private void invalidateTextPresentation() { private void invalidateTextPresentation() {
for (int i= 0, n= fPositions.size(); i < n; i++) { if (fPositions.size() > 1000) {
Position position= (Position) fPositions.get(i); fSourceViewer.invalidateTextPresentation();
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength()); } else {
for (int i= 0, n= fPositions.size(); i < n; i++) {
Position position= (Position) fPositions.get(i);
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
}
} }
} }

View file

@ -19,8 +19,11 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus; 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.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; 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.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; 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.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite; 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.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.util.Messages;
import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.PixelConverter;
/** /**

View file

@ -26,6 +26,7 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider; 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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC; 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.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.ScrollBar;
@ -187,7 +190,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
/** /**
* Color list label provider. * 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) * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/ */
@ -196,6 +199,25 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
return (String) element; return (String) element;
return ((HighlightingColorListItem)element).getDisplayName(); 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 ColorSelector fSyntaxForegroundColorEditor;
private Label fColorEditorLabel; private Label fColorEditorLabel;
private Button fEnableSemanticHighlightingCheckbox;
private Button fBoldCheckBox; private Button fBoldCheckBox;
private Button fEnableCheckbox; private Button fEnableCheckbox;
/** /**
@ -451,6 +474,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
public void performDefaults() { public void performDefaults() {
super.performDefaults(); super.performDefaults();
fEnableSemanticHighlightingCheckbox.setSelection(getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED));
fListViewer.refresh();
handleSyntaxColorListSelection(); handleSyntaxColorListSelection();
uninstallSemanticHighlighting(); uninstallSemanticHighlighting();
@ -488,8 +514,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey())); fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey()));
fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey())); fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey()));
if (item instanceof SemanticHighlightingColorListItem) { if (item instanceof SemanticHighlightingColorListItem) {
fEnableCheckbox.setEnabled(true); boolean semanticHighlightingEnabled= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
boolean enable= getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey()); fEnableCheckbox.setEnabled(semanticHighlightingEnabled);
boolean enable= semanticHighlightingEnabled && getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
fEnableCheckbox.setSelection(enable); fEnableCheckbox.setSelection(enable);
fSyntaxForegroundColorEditor.getButton().setEnabled(enable); fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
fColorEditorLabel.setEnabled(enable); fColorEditorLabel.setEnabled(enable);
@ -534,6 +561,13 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
link.setLayoutData(gridData); link.setLayoutData(gridData);
addFiller(colorComposite, 1); 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 label;
label= new Label(colorComposite, SWT.LEFT); 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); colorComposite.layout(false);
return colorComposite; return colorComposite;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences; package org.eclipse.cdt.internal.ui.preferences;
@ -15,19 +16,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.core.runtime.Assert;
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.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.Dialog; 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.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData; 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.swt.widgets.Text;
import org.eclipse.ui.PlatformUI; 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 * CEditorHoverConfigurationBlock
*/ */
public class CEditorHoverConfigurationBlock { public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock {
static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter; static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter;
private static final int ENABLED_PROP= 0; private static final int ENABLED_PROP= 0;
@ -152,11 +156,11 @@ public class CEditorHoverConfigurationBlock {
//private Button fShowHoverAffordanceCheckbox; //private Button fShowHoverAffordanceCheckbox;
private Button fShowEditorAnnotationCheckbox; private Button fShowEditorAnnotationCheckbox;
private CEditorPreferencePage fMainPreferencePage; private PreferencePage fMainPreferencePage;
private StatusInfo fStatus; private StatusInfo fStatus;
public CEditorHoverConfigurationBlock(CEditorPreferencePage mainPreferencePage, OverlayPreferenceStore store) { public CEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
Assert.isNotNull(mainPreferencePage); Assert.isNotNull(mainPreferencePage);
Assert.isNotNull(store); Assert.isNotNull(store);
fMainPreferencePage= mainPreferencePage; fMainPreferencePage= mainPreferencePage;
@ -180,11 +184,8 @@ public class CEditorHoverConfigurationBlock {
return keys; return keys;
} }
/** /*
* Creates page for hover preferences. * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite)
*
* @param parent the parent composite
* @return the control for the preference page
*/ */
public Control createControl(Composite parent) { public Control createControl(Composite parent) {
@ -380,7 +381,10 @@ public class CEditorHoverConfigurationBlock {
return CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); return CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
} }
void initialize() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
*/
public void initialize() {
CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers(); CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
fHoverConfigs= new HoverConfig[hoverDescs.length]; fHoverConfigs= new HoverConfig[hoverDescs.length];
for (int i= 0; i < hoverDescs.length; i++) for (int i= 0; i < hoverDescs.length; i++)
@ -403,7 +407,10 @@ public class CEditorHoverConfigurationBlock {
fHoverTableViewer.refresh(); fHoverTableViewer.refresh();
} }
void performOk() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
*/
public void performOk() {
StringBuffer buf= new StringBuffer(); StringBuffer buf= new StringBuffer();
StringBuffer maskBuf= new StringBuffer(); StringBuffer maskBuf= new StringBuffer();
for (int i= 0; i < fHoverConfigs.length; i++) { for (int i= 0; i < fHoverConfigs.length; i++) {
@ -430,7 +437,10 @@ public class CEditorHoverConfigurationBlock {
CUIPlugin.getDefault().resetCEditorTextHoverDescriptors(); CUIPlugin.getDefault().resetCEditorTextHoverDescriptors();
} }
void performDefaults() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
*/
public void performDefaults() {
fStatus= new StatusInfo(); fStatus= new StatusInfo();
restoreFromPreferences(); restoreFromPreferences();
initializeFields(); initializeFields();
@ -553,12 +563,8 @@ public class CEditorHoverConfigurationBlock {
i++; i++;
} }
if (fStatus.isOK()) fMainPreferencePage.setValid(fStatus.isOK());
fMainPreferencePage.updateStatus(fStatus); StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
else {
fMainPreferencePage.setValid(false);
StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
}
} }

View file

@ -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);
}
}

View file

@ -32,16 +32,12 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener; 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.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; 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.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.editor.CEditor; 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 }, {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 List fAppearanceColorList;
private ColorSelector fAppearanceColorEditor; private ColorSelector fAppearanceColorEditor;
private Button fAppearanceColorDefault; private Button fAppearanceColorDefault;
public CEditorPreferencePage() { public CEditorPreferencePage() {
super(); super();
setDescription(CUIPlugin.getResourceString("CEditorPreferencePage.description")); //$NON-NLS-1$
} }
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
@ -265,6 +251,9 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null); 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 gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridData.widthHint= 150; // only expand further if anyone else requires it 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) { protected Control createContents(Composite parent) {
fCEditorHoverConfigurationBlock= new CEditorHoverConfigurationBlock(this, fOverlayStore);
fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore);
fOverlayStore.load(); fOverlayStore.load();
fOverlayStore.start(); fOverlayStore.start();
createHeader(parent); createHeader(parent);
TabFolder folder = new TabFolder(parent, SWT.NONE); createAppearancePage(parent);
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));
initialize(); initialize();
return folder; return parent;
} }
private void initialize() { 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() { public boolean performOk() {
fCEditorHoverConfigurationBlock.performOk();
fFoldingConfigurationBlock.performOk();
return super.performOk(); return super.performOk();
} }
/* /*
* @see PreferencePage#performDefaults() * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performDefaults()
*/ */
protected void performDefaults() { protected void performDefaults() {
super.performDefaults(); super.performDefaults();
handleAppearanceColorListSelection(); handleAppearanceColorListSelection();
fCEditorHoverConfigurationBlock.performDefaults();
fFoldingConfigurationBlock.performDefaults();
} }
/* /*
* @see DialogPage#dispose() * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#dispose()
*/ */
public void dispose() { public void dispose() {
fFoldingConfigurationBlock.dispose();
if (fOverlayStore != null) {
fOverlayStore.stop();
fOverlayStore = null;
}
super.dispose(); super.dispose();
} }

View file

@ -16,16 +16,10 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor; import org.eclipse.core.runtime.Assert;
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.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider; 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.Control;
import org.eclipse.swt.widgets.Label; 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. * Configures C Editor folding preferences.
* *
* @since 3.0 * @since 3.0
*/ */
class FoldingConfigurationBlock { class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
private static class ErrorPreferences implements ICFoldingPreferenceBlock { private static class ErrorPreferences implements ICFoldingPreferenceBlock {
private String fMessage; private String fMessage;
@ -135,13 +137,10 @@ class FoldingConfigurationBlock {
return keys; return keys;
} }
/** /*
* Creates page for folding preferences. * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite)
*
* @param parent the parent composite
* @return the control for the preference page
*/ */
Control createControl(Composite parent) { public Control createControl(Composite parent) {
Composite composite= new Composite(parent, SWT.NULL); Composite composite= new Composite(parent, SWT.NULL);
// assume parent page uses griddata // assume parent page uses griddata
@ -307,18 +306,27 @@ class FoldingConfigurationBlock {
prefs.initialize(); prefs.initialize();
} }
void initialize() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
*/
public void initialize() {
restoreFromPreferences(); restoreFromPreferences();
} }
void performOk() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
*/
public void performOk() {
for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next();
prefs.performOk(); prefs.performOk();
} }
} }
void performDefaults() { /*
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
*/
public void performDefaults() {
restoreFromPreferences(); restoreFromPreferences();
for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); 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();) { for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next();
prefs.dispose(); prefs.dispose();

View file

@ -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);
}
}

View file

@ -60,7 +60,7 @@ public final class PreferencesMessages extends NLS {
public static String TodoTaskInputDialog_error_entryExists; public static String TodoTaskInputDialog_error_entryExists;
public static String TodoTaskInputDialog_error_noSpace; public static String TodoTaskInputDialog_error_noSpace;
public static String CEditorPreferencePage_link; 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_colors;
public static String CEditorPreferencePage_invalid_input; public static String CEditorPreferencePage_invalid_input;
public static String CEditorPreferencePage_empty_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_category_preprocessor;
public static String CEditorColoringConfigurationBlock_coloring_element; public static String CEditorColoringConfigurationBlock_coloring_element;
public static String CEditorColoringConfigurationBlock_link; public static String CEditorColoringConfigurationBlock_link;
public static String CEditorColoringConfigurationBlock_enable_semantic_highlighting;
public static String CEditorColoringConfigurationBlock_enable; public static String CEditorColoringConfigurationBlock_enable;
public static String CEditorColoringConfigurationBlock_preview; public static String CEditorColoringConfigurationBlock_preview;
public static String CEditorColoringConfigurationBlock_color; public static String CEditorColoringConfigurationBlock_color;
@ -136,7 +137,7 @@ public final class PreferencesMessages extends NLS {
public static String CFileTypeDialog_title; public static String CFileTypeDialog_title;
public static String CFileTypeDialog_patternLabel; public static String CFileTypeDialog_patternLabel;
public static String CFileTypeDialog_typeLabel; 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_hoverPreferences;
public static String CEditorHoverConfigurationBlock_keyModifier; public static String CEditorHoverConfigurationBlock_keyModifier;
public static String CEditorHoverConfigurationBlock_description; public static String CEditorHoverConfigurationBlock_description;

View file

@ -60,8 +60,9 @@ TodoTaskInputDialog_error_comma=Name cannot contain a comma.
TodoTaskInputDialog_error_entryExists=Entry with the same name already exists. TodoTaskInputDialog_error_entryExists=Entry with the same name already exists.
TodoTaskInputDialog_error_noSpace=Name can not start or end with a whitespace. TodoTaskInputDialog_error_noSpace=Name can not start or end with a whitespace.
CEditorPreferencePage_link=Note that some preferences may be set on the <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a> preference page. CEditorPreferencePage_link=C/C++ Editor Preferences. Note that some preferences may be set on the <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a> preference page.
CEditorPreferencePage_generalTabTitle=Appeara&nce CEditorPreferencePage_link_tooltip=Show the shared text editor preferences
CEditorPreferencePage_colors=Synta&x CEditorPreferencePage_colors=Synta&x
CEditorPreferencePage_invalid_input=Invalid input. CEditorPreferencePage_invalid_input=Invalid input.
@ -102,6 +103,7 @@ CEditorColoringConfigurationBlock_coloring_category_preprocessor=Preprocessor
CEditorColoringConfigurationBlock_coloring_element=Element: CEditorColoringConfigurationBlock_coloring_element=Element:
# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts" # 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 <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">Text Editors</a> and on the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">Colors and Fonts</a> preference page. CEditorColoringConfigurationBlock_link=Default colors and font can be configured on the <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">Text Editors</a> and on the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">Colors and Fonts</a> preference page.
CEditorColoringConfigurationBlock_enable_semantic_highlighting=Enable semantic highlighting
CEditorColoringConfigurationBlock_enable=Enab&le CEditorColoringConfigurationBlock_enable=Enab&le
CEditorColoringConfigurationBlock_preview=Previe&w: CEditorColoringConfigurationBlock_preview=Previe&w:
CEditorColoringConfigurationBlock_color=C&olor: CEditorColoringConfigurationBlock_color=C&olor:
@ -144,8 +146,8 @@ CFileTypeDialog_title=C/C++ File Type
CFileTypeDialog_patternLabel=Pattern: CFileTypeDialog_patternLabel=Pattern:
CFileTypeDialog_typeLabel=Type: CFileTypeDialog_typeLabel=Type:
# Hover tab # Hover page
CEditorPreferencePage_hoverTab_title= Ho&vers CEditorPreferencePage_hover_title= Ho&vers
CEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences: CEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences:
CEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering: CEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering:
CEditorHoverConfigurationBlock_description= Description: CEditorHoverConfigurationBlock_description= Description:

View file

@ -29,7 +29,6 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
/** /**
* Preference page for work in progress. * Preference page for work in progress.
@ -84,10 +83,7 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
result.setLayout(layout); result.setLayout(layout);
// Add your controls here // 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); applyDialogFont(result);
return result; return result;
} }

View file

@ -11,11 +11,12 @@
package org.eclipse.cdt.internal.ui.text.folding; package org.eclipse.cdt.internal.ui.text.folding;
import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; import org.eclipse.core.runtime.Assert;
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; 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. * Describes a contribution to the folding provider extension point.

View file

@ -17,11 +17,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; 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.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent; 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.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; 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) { public void widgetSelected(SelectionEvent e) {
Button button= (Button) e.widget; 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() { 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_COMMENTS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_HEADERS)); 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_INACTIVE_CODE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
return (OverlayKey[]) overlayKeys.toArray(new OverlayKey[overlayKeys.size()]); return (OverlayKey[]) overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
} }
@ -84,17 +90,19 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
layout.verticalSpacing= 3; layout.verticalSpacing= 3;
layout.marginWidth= 0; layout.marginWidth= 0;
inner.setLayout(layout); inner.setLayout(layout);
Label label= new Label(inner, SWT.LEFT); addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_preprocessor_enabled, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, 1);
label.setText(FoldingMessages.getString("DefaultCFoldingPreferenceBlock.title")); //$NON-NLS-1$ ControlFactory.createEmptySpace(inner);
addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.macros"), PreferenceConstants.EDITOR_FOLDING_MACROS, 0); //$NON-NLS-1$ Composite group= ControlFactory.createGroup(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_title, 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(group, FoldingMessages.DefaultCFoldingPreferenceBlock_macros, PreferenceConstants.EDITOR_FOLDING_MACROS, 0);
addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.structures"), PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0); //$NON-NLS-1$ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_functions, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0);
addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.comments"), PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0); //$NON-NLS-1$ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_methods, PreferenceConstants.EDITOR_FOLDING_METHODS, 0);
addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.headers"), PreferenceConstants.EDITOR_FOLDING_HEADERS, 0); //$NON-NLS-1$ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_structures, PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0);
addCheckBox(inner, FoldingMessages.getString("DefaultCFoldingPreferenceBlock.inactive_code"), PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0); //$NON-NLS-1$ 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; return inner;
} }
@ -121,9 +129,16 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
Button b= (Button) it.next(); Button b= (Button) it.next();
String key= (String) fCheckBoxes.get(b); String key= (String) fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key)); 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() * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#performOk()
*/ */

View file

@ -24,12 +24,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Stack; import java.util.Stack;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
@ -849,7 +849,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
fCollapseComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS); fCollapseComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS);
fCollapseInactiveCode= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE); fCollapseInactiveCode= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE);
fPreprocessorBranchFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED); fPreprocessorBranchFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED);
fCommentFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS_ENABLED); fCommentFoldingEnabled= true;
} }
private void update(FoldingStructureComputationContext ctx) { private void update(FoldingStructureComputationContext ctx) {

View file

@ -40,7 +40,7 @@ public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
label.setLayoutData(gd); label.setLayoutData(gd);
label= new Label(inner, SWT.CENTER); 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); gd= new GridData(GridData.CENTER);
label.setLayoutData(gd); label.setLayoutData(gd);

View file

@ -8,29 +8,30 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text.folding; package org.eclipse.cdt.internal.ui.text.folding;
import java.util.MissingResourceException; import org.eclipse.osgi.util.NLS;
import java.util.ResourceBundle;
/** public final class FoldingMessages extends NLS {
* @since 3.0
*/
class FoldingMessages {
private static final String BUNDLE_NAME= FoldingMessages.class.getName(); private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.text.folding.FoldingMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
private FoldingMessages() { private FoldingMessages() {
// Do not instantiate
} }
public static String getString(String key) { public static String DefaultCFoldingPreferenceBlock_title;
try { public static String DefaultCFoldingPreferenceBlock_macros;
return RESOURCE_BUNDLE.getString(key); public static String DefaultCFoldingPreferenceBlock_functions;
} catch (MissingResourceException e) { public static String DefaultCFoldingPreferenceBlock_methods;
return '!' + key + '!'; 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);
} }
} }

View file

@ -11,13 +11,14 @@
############################################################################### ###############################################################################
DefaultCFoldingPreferenceBlock.title= Initially fold these region types: DefaultCFoldingPreferenceBlock_title= Initially fold these region types:
DefaultCFoldingPreferenceBlock.macros= &Macros DefaultCFoldingPreferenceBlock_macros= &Macros
DefaultCFoldingPreferenceBlock.functions= &Functions DefaultCFoldingPreferenceBlock_functions= &Functions
DefaultCFoldingPreferenceBlock.methods= &Methods DefaultCFoldingPreferenceBlock_methods= &Methods
DefaultCFoldingPreferenceBlock.structures= &Structures DefaultCFoldingPreferenceBlock_structures= &Structures
DefaultCFoldingPreferenceBlock.comments= &Comments DefaultCFoldingPreferenceBlock_comments= &Comments
DefaultCFoldingPreferenceBlock.headers= &Header Comments DefaultCFoldingPreferenceBlock_headers= &Header Comments
DefaultCFoldingPreferenceBlock.inactive_code= &Inactive Preprocessor Branches DefaultCFoldingPreferenceBlock_inactive_code= &Inactive Preprocessor Branches
DefaultCFoldingPreferenceBlock_preprocessor_enabled= Enable folding of preprocessor branches (#if/#endif)
EmptyCFoldingPreferenceBlock.emptyCaption= EmptyCFoldingPreferenceBlock_emptyCaption=

View file

@ -872,16 +872,6 @@ public class PreferenceConstants {
*/ */
public static final String EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED= "editor_folding_preprocessor_enabled"; //$NON-NLS-1$ 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.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @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. * A named preference that controls if templates are formatted when applied.
* <p> * <p>
@ -1087,7 +1077,6 @@ public class PreferenceConstants {
store.setDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS, false); store.setDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS, false);
store.setDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS, true); store.setDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS, true);
store.setDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 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_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, false);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);

View file

@ -128,6 +128,16 @@
<topic href="reference/cdt_u_c_editor_hov.htm" <topic href="reference/cdt_u_c_editor_hov.htm"
label="Editor Hovers Preferences"/> label="Editor Hovers Preferences"/>
</context> </context>
<context id ="c_editor_typing">
<description>Click below to see help.</description>
<topic href="reference/cdt_u_c_pref.htm"
label="C/C++ Preferences"/>
</context>
<context id ="c_editor_folding">
<description>Click below to see help.</description>
<topic href="reference/cdt_u_c_pref.htm"
label="C/C++ Preferences"/>
</context>
<context id ="c_editor_navigation"> <context id ="c_editor_navigation">
<description>Click below to see help.</description> <description>Click below to see help.</description>
<topic href="reference/cdt_u_c_editor_navigation.htm" <topic href="reference/cdt_u_c_editor_navigation.htm"