1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Preference page for setting class member visibility order.

This commit is contained in:
Sergey Prigogin 2012-01-06 20:02:15 -08:00
parent a23acf3d6e
commit bd7f95875d
11 changed files with 106 additions and 114 deletions

View file

@ -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
extension-point.name = Refresh Exclusion Contributor

View file

@ -1127,10 +1127,10 @@
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<page
name="%CodeFormatterPreferencePage.name"
name="%CodeStylePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage">
class="org.eclipse.cdt.internal.ui.preferences.CodeStylePreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeStylePreferencePage">
<keywordReference id="org.eclipse.cdt.ui.codestyle"/>
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
@ -1196,15 +1196,23 @@
</page>
<page
name="%codeTemplatePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
category="org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage">
<keywordReference id="org.eclipse.cdt.ui.codetemplates"/>
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<page
name="%codeFormatterPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage">
<keywordReference id="org.eclipse.cdt.ui.codestyle"/>
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<page
name="%nameStylePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
category="org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage"
id="org.eclipse.cdt.ui.preferences.NameStylePreferencePage">
<keywordReference id="org.eclipse.cdt.ui.namestyle"/>
@ -1263,6 +1271,9 @@
<keyword
label="%preferenceKeywords.namestyle"
id="org.eclipse.cdt.ui.namestyle"/>
<keyword
label="%preferenceKeywords.codeformatter"
id="org.eclipse.cdt.ui.codeformatter"/>
<keyword
label="%preferenceKeywords.todo"
id="org.eclipse.cdt.ui.todo"/>

View file

@ -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$

View file

@ -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<ExpandableComposite> fSections= new HashSet<ExpandableComposite>();
private final Set<ExpandableComposite> fSections= new HashSet<ExpandableComposite>();
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<Object, String> fCheckBoxes= new HashMap<Object, String>();
private SelectionListener fCheckBoxListener= new SelectionListener() {
private final Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
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<Object, String> fTextFields= new HashMap<Object, String>();
private ModifyListener fTextFieldListener= new ModifyListener() {
private final Map<Object, String> fTextFields= new HashMap<Object, String>();
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<Text> fNumberFields= new ArrayList<Text>();
private ModifyListener fNumberFieldListener= new ModifyListener() {
private final ArrayList<Text> fNumberFields= new ArrayList<Text>();
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<Object> fMasterSlaveListeners= new ArrayList<Object>();
private final ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
private StatusInfo fStatus;
private final PreferencePage fMainPage;
@ -326,8 +327,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
* @param isNumber <code>true</code> 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<Object> 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() {
}

View file

@ -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$

View file

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

View file

@ -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

View file

@ -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) {

View file

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

View file

@ -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

View file

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