diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 07261fd7396..202b774b516 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -193,8 +193,9 @@ CPluginBuildPreferencePage.name=Build CPluginBuildConsolePreferencePage.name=Console CPluginGlobalBuildLogPreferencePage.name=Logging CPluginFileTypesPreferencePage.name=File Types -CodeFormatterPreferencePage.name=Code Style +CodeStylePreferencePage.name=Code Style codeTemplatePreferencePage.name=Code Templates +codeFormatterPreferencePage.name=Formatter nameStylePreferencePage.name=Name Style CodeAssistPreferencePage.name=Content Assist CodeAssistAdvancedPreferencePage.name=Advanced @@ -560,9 +561,10 @@ workingSetConfigurationsExtensionPoint=Working Set Configurations # Keywords for Preferences preferenceKeywords.common=c cpp cplusplus cdt -preferenceKeywords.codestyle=profile codestyle project specific comment indentation brace white space blank line new control statement wrapping tab parenthesis bracket +preferenceKeywords.codeformatter=profile codestyle project specific comment indentation brace white space blank line new control statement wrapping tab parenthesis bracket +preferenceKeywords.codestyle=class member visibility order ordering preferenceKeywords.codetemplates=comment code constructor method file type content -preferenceKeywords.namestyle=name file getter setter +preferenceKeywords.namestyle=name file getter setter field variable preferenceKeywords.todo=case sensitive task tag todo xxx fix fixme project comments preferenceKeywords.indexer=index skip references type macro search build configuration cache memory performance @@ -625,4 +627,4 @@ transfer.EditorBehavior.description = Preference related to how the editor proce # Refresh Exclusion Contributors RefreshExclusionContributor.name = Resources -extension-point.name = Refresh Exclusion Contributor \ No newline at end of file +extension-point.name = Refresh Exclusion Contributor diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index aa1b14bde18..5ccde09be0e 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -1127,10 +1127,10 @@ + class="org.eclipse.cdt.internal.ui.preferences.CodeStylePreferencePage" + id="org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"> @@ -1196,15 +1196,23 @@ + + + + @@ -1263,6 +1271,9 @@ + 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 47d21d1bf17..c883bbb98ee 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 @@ -85,6 +85,7 @@ public interface ICHelpContextIds { public static final String APPEARANCE_PREFERENCE_PAGE = PREFIX + "appearance_preference_page_context"; //$NON-NLS-1$ public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$ + public static final String CODE_STYLE_PREFERENCE_PAGE = PREFIX + "code_style_preference_context"; //$NON-NLS-1$ public static final String CODE_TEMPLATES_PREFERENCE_PAGE = PREFIX + "code_templates_preference_context"; //$NON-NLS-1$ public static final String NAME_STYLE_PREFERENCE_PAGE = PREFIX + "name_style_preference_context"; //$NON-NLS-1$ 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 8436fd1abd6..447a50882b5 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 @@ -7,10 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Sergey Prigogin, Google + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; @@ -53,7 +52,6 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; * @since 4.0 */ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock { - /** * Use as follows: * @@ -73,9 +71,9 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected final class SectionManager { /** The preference setting for keeping no section open. */ private static final String __NONE= "__none"; //$NON-NLS-1$ - private Set fSections= new HashSet(); + private final Set fSections= new HashSet(); private boolean fIsBeingManaged= false; - private ExpansionAdapter fListener= new ExpansionAdapter() { + private final ExpansionAdapter fListener= new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { ExpandableComposite source= (ExpandableComposite) e.getSource(); @@ -107,10 +105,12 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo } } }; + private Composite fBody; private final String fLastOpenKey; private final IPreferenceStore fDialogSettingsStore; - private ExpandableComposite fFirstChild= null; + private ExpandableComposite fFirstChild; + /** * Creates a new section manager. */ @@ -203,13 +203,14 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo } protected static final int INDENT= 20; - private OverlayPreferenceStore fStore; + private final OverlayPreferenceStore fStore; - private Map fCheckBoxes= new HashMap(); - private SelectionListener fCheckBoxListener= new SelectionListener() { + private final Map fCheckBoxes= new HashMap(); + private final SelectionListener fCheckBoxListener= new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; @@ -218,8 +219,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo }; - private Map fTextFields= new HashMap(); - private ModifyListener fTextFieldListener= new ModifyListener() { + private final Map fTextFields= new HashMap(); + private final ModifyListener fTextFieldListener= new ModifyListener() { @Override public void modifyText(ModifyEvent e) { Text text= (Text) e.widget; @@ -227,8 +228,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo } }; - private ArrayList fNumberFields= new ArrayList(); - private ModifyListener fNumberFieldListener= new ModifyListener() { + private final ArrayList fNumberFields= new ArrayList(); + private final ModifyListener fNumberFieldListener= new ModifyListener() { @Override public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); @@ -241,7 +242,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo * @see #createDependency(Button, Control) * @since 3.0 */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private final ArrayList fMasterSlaveListeners= new ArrayList(); private StatusInfo fStatus; private final PreferencePage fMainPage; @@ -326,8 +327,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo * @param isNumber true iff this text field is used to e4dit a number * @return the controls added */ - protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { - + protected Control[] addLabelledTextField(Composite composite, String label, String key, + int textLimit, int indentation, boolean isNumber) { PixelConverter pixelConverter= new PixelConverter(composite); Label labelControl= new Label(composite, SWT.NONE); @@ -376,7 +377,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo } protected static void indent(Control control) { - ((GridData) control.getLayoutData()).horizontalIndent+= INDENT; + ((GridData) control.getLayoutData()).horizontalIndent += INDENT; } @Override @@ -385,7 +386,6 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo } private void initializeFields() { - Iterator iter= fCheckBoxes.keySet().iterator(); while (iter.hasNext()) { Button b= (Button) iter.next(); @@ -425,9 +425,6 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo return fStatus; } - /* - * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() - */ @Override public void dispose() { } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java index 792ec6cd22c..5f9e6e4a016 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java @@ -7,13 +7,11 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Sergey Prigogin, Google + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; - import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.preference.IPreferencePageContainer; @@ -31,7 +29,6 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.CodeFormatterConfigurat * The page to configure the code formatter options. */ public class CodeFormatterPreferencePage extends PropertyAndPreferencePage { - public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$ public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$ 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 index f78f6a1a3b8..998a3a59408 100644 --- 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 @@ -37,7 +37,7 @@ public final class FoldingPreferencePage extends AbstractConfigurationBlockPrefe */ @Override protected void setDescription() { - String description= PreferencesMessages.CEditorPreferencePage_folding_title; + String description= PreferencesMessages.FoldingPreferencePage_folding_title; setDescription(description); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java index b501ace9195..9be6d2ce1bd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc and others. + * Copyright (c) 2011, 2012 Google, Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,27 +10,19 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; /* * The preference page for configuring styles of names. */ -public class NameStylePreferencePage extends PropertyAndPreferencePage { +public class NameStylePreferencePage extends ConfigurationBlockPropertyAndPreferencePage { public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.NameStylePreferencePage"; //$NON-NLS-1$ public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.NameStylePreferencePage"; //$NON-NLS-1$ - private NameStyleBlock fConfigurationBlock; - public NameStylePreferencePage() { setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); // Only used when the page is shown programmatically. @@ -38,68 +30,13 @@ public class NameStylePreferencePage extends PropertyAndPreferencePage { } @Override - public void createControl(Composite parent) { - IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); - fConfigurationBlock= new NameStyleBlock(getNewStatusChangedListener(), - getProject(), container); - - super.createControl(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), - ICHelpContextIds.NAME_STYLE_PREFERENCE_PAGE); + protected OptionsConfigurationBlock createConfigurationBlock(IWorkbenchPreferenceContainer container) { + return new NameStyleBlock(getNewStatusChangedListener(), getProject(), container); } @Override - protected Control createPreferenceContent(Composite composite) { - return fConfigurationBlock.createContents(composite); - } - - @Override - protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { - super.enableProjectSpecificSettings(useProjectSpecificSettings); - if (fConfigurationBlock != null) { - fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings); - } - } - - @Override - public boolean performOk() { - if (fConfigurationBlock != null) { - return fConfigurationBlock.performOk(); - } - return true; - } - - @Override - protected void performDefaults() { - super.performDefaults(); - if (fConfigurationBlock != null) { - fConfigurationBlock.performDefaults(); - } - } - - @Override - public void dispose() { - if (fConfigurationBlock != null) { - fConfigurationBlock.dispose(); - } - super.dispose(); - } - - public void statusChanged(IStatus status) { - setValid(!status.matches(IStatus.ERROR)); - StatusUtil.applyToStatusLine(this, status); - } - - @Override - public void performApply() { - if (fConfigurationBlock != null) { - fConfigurationBlock.performApply(); - } - } - - @Override - protected boolean hasProjectSpecificOptions(IProject project) { - return fConfigurationBlock.hasProjectSpecificOptions(project); + protected String getHelpId() { + return ICHelpContextIds.NAME_STYLE_PREFERENCE_PAGE; } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java index 9eba37ac81f..17a3fca734c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; @@ -39,6 +40,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; @@ -62,6 +64,8 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener; * an options configuration page. */ public abstract class OptionsConfigurationBlock { + protected static final String[] FALSE_TRUE = new String[] { "false", "true" }; //$NON-NLS-1$//$NON-NLS-2$ + protected static final String[] TRUE_FALSE = new String[] { "true", "false" }; //$NON-NLS-1$//$NON-NLS-2$ public static final class Key { private final String fQualifier; @@ -106,9 +110,6 @@ public abstract class OptionsConfigurationBlock { } } - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ @Override public String toString() { return fQualifier + '/' + fKey; @@ -149,7 +150,7 @@ public abstract class OptionsConfigurationBlock { } } } - return fValues.length -1; // assume the last option is the least severe + return fValues.length - 1; // assume the last option is the least severe } } @@ -380,6 +381,30 @@ public abstract class OptionsConfigurationBlock { return checkBox; } + protected Button addRadioButton(Composite parent, String label, Key key, String[] values, int indent) { + ControlData data= new ControlData(key, values); + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan= 3; + gd.horizontalIndent= indent; + + Button radioButton= new Button(parent, SWT.RADIO); + radioButton.setFont(JFaceResources.getDialogFont()); + radioButton.setText(label); + radioButton.setData(data); + radioButton.setLayoutData(gd); + radioButton.addSelectionListener(getSelectionListener()); + + makeScrollableCompositeAware(radioButton); + + String currValue= getValue(key); + radioButton.setSelection(data.getSelection(currValue) == 0); + + fCheckBoxes.add(radioButton); + + return radioButton; + } + protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) { GridData gd= new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1); @@ -481,6 +506,14 @@ public abstract class OptionsConfigurationBlock { return textBox; } + protected Composite addSubsection(Composite parent, String label) { + Group group= new Group(parent, SWT.SHADOW_NONE); + group.setText(label); + GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); + group.setLayoutData(data); + return group; + } + protected ScrolledPageContent getParentScrolledComposite(Control control) { Control parent= control.getParent(); while (!(parent instanceof ScrolledPageContent) && parent != null) { 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 584cd1f279b..a4d76943d35 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 @@ -151,7 +151,7 @@ public final class PreferencesMessages extends NLS { public static String BuildLogPreferencePage_LogLocation; public static String GlobalBuildLogPreferencePage_EnableLogging; public static String GlobalBuildLogPreferencePage_LogLocation; - public static String CEditorPreferencePage_folding_title; + public static String FoldingPreferencePage_folding_title; public static String FoldingConfigurationBlock_enable; public static String FoldingConfigurationBlock_combo_caption; public static String FoldingConfigurationBlock_info_no_preferences; @@ -194,6 +194,11 @@ public final class PreferencesMessages extends NLS { public static String CodeFormatterPreferencePage_title; public static String CodeFormatterPreferencePage_description; + public static String CodeStylePreferencePage_title; + public static String CodeStyleBlock_class_member_order; + public static String CodeStyleBlock_public_private; + public static String CodeStyleBlock_private_public; + public static String TodoTaskPreferencePage_title; public static String TodoTaskPreferencePage_description; public static String TodoTaskConfigurationBlock_markers_tasks_high_priority; 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 b3357307250..aa5574d29d8 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 @@ -184,7 +184,7 @@ GlobalBuildLogPreferencePage_EnableLogging=Enable global build &logging GlobalBuildLogPreferencePage_LogLocation=Log &file location: #Folding -CEditorPreferencePage_folding_title= &Folding +FoldingPreferencePage_folding_title= &Folding FoldingConfigurationBlock_enable= Enable folding when &opening a new editor FoldingConfigurationBlock_combo_caption= Select folding to &use: @@ -224,9 +224,15 @@ CEditorPreferencePage_smartPaste=Adjust &indentation CEditorPreferencePage_typing_smartTab= &Tab key adjusts indentation of the current line CEditorPreferencePage_WorkspaceDefaultLabel=Workspace default: -# Code Formatting -CodeFormatterPreferencePage_title=Code Style -CodeFormatterPreferencePage_description=Sele&ct a profile: +# Code Formatter +CodeFormatterPreferencePage_title=Formatter +CodeFormatterPreferencePage_description=A&ctive profile: + +# Code Style +CodeStylePreferencePage_title=Code Style +CodeStyleBlock_class_member_order=Class member visiblity order: +CodeStyleBlock_public_private=P&ublic, protected, private +CodeStyleBlock_private_public=P&rivate, protected, public # Task tags. TodoTaskPreferencePage_title=Task Tags 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 1e553a04244..56c5245cee2 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 @@ -2101,6 +2101,9 @@ public class PreferenceConstants { store.setDefault(NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp"); //$NON-NLS-1$ store.setDefault(NAME_STYLE_CPP_TEST_WORD_DELIMITER, ""); //$NON-NLS-1$ + // Code style + store.setDefault(CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, false); + // Colors that are set by the current theme CUIPreferenceInitializer.setThemeBasedPreferences(store, false); }