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

UI for new code style preferences.

This commit is contained in:
Sergey Prigogin 2012-02-11 17:42:32 -08:00
parent aa4eae00dd
commit e65759e510
3 changed files with 51 additions and 4 deletions

View file

@ -23,14 +23,21 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
/**
* Configures C Editor typing preferences.
* Configures elements of C/C++ code style affecting refactoring.
*/
class CodeStyleBlock extends OptionsConfigurationBlock {
private static final Key CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER = getCDTUIKey(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);
private static final Key CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER =
getCDTUIKey(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);
private static final Key FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT =
getCDTUIKey(PreferenceConstants.FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT);
private static final Key FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER =
getCDTUIKey(PreferenceConstants.FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER);
private static Key[] getAllKeys() {
return new Key[] {
CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER,
FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT,
FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER,
};
}
@ -52,6 +59,12 @@ class CodeStyleBlock extends OptionsConfigurationBlock {
Composite composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_class_member_order);
fillClassMemberOrderSection(composite);
composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_parameter_order);
fillFunctionParameterOrderSection(composite);
composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_output_parameter_style);
fillFunctionOutputParameterStyleSection(composite);
scrolled.setContent(control);
final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrolled.setMinSize(size.x, size.y);
@ -69,6 +82,28 @@ class CodeStyleBlock extends OptionsConfigurationBlock {
CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, TRUE_FALSE, 0);
}
private void fillFunctionParameterOrderSection(Composite composite) {
GridLayout layout= new GridLayout();
layout.numColumns= 3;
composite.setLayout(layout);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_input_output,
FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT, FALSE_TRUE, 0);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_output_input,
FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT, TRUE_FALSE, 0);
}
private void fillFunctionOutputParameterStyleSection(Composite composite) {
GridLayout layout= new GridLayout();
layout.numColumns= 3;
composite.setLayout(layout);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_pass_by_reference,
FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER, FALSE_TRUE, 0);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_pass_by_pointer,
FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER, TRUE_FALSE, 0);
}
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
}

View file

@ -198,6 +198,12 @@ public final class PreferencesMessages extends NLS {
public static String CodeStyleBlock_class_member_order;
public static String CodeStyleBlock_public_private;
public static String CodeStyleBlock_private_public;
public static String CodeStyleBlock_function_parameter_order;
public static String CodeStyleBlock_input_output;
public static String CodeStyleBlock_output_input;
public static String CodeStyleBlock_function_output_parameter_style;
public static String CodeStyleBlock_pass_by_reference;
public static String CodeStyleBlock_pass_by_pointer;
public static String TodoTaskPreferencePage_title;
public static String TodoTaskPreferencePage_description;

View file

@ -231,8 +231,14 @@ 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
CodeStyleBlock_public_private=Pu&blic, protected, private
CodeStyleBlock_private_public=Pri&vate, protected, public
CodeStyleBlock_function_parameter_order=Function parameter order:
CodeStyleBlock_input_output=&Input parameters first
CodeStyleBlock_output_input=&Output parameters first
CodeStyleBlock_function_output_parameter_style=Output parameters of C++ functions:
CodeStyleBlock_pass_by_reference=Pass by &reference
CodeStyleBlock_pass_by_pointer=Pass by poi&nter
# Task tags.
TodoTaskPreferencePage_title=Task Tags