diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index ec2b1af6ed5..07940aa01da 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2012 IBM Corporation, QNX Software Systems, and others.
+# Copyright (c) 2003, 2013 IBM Corporation, QNX Software Systems, and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -196,6 +196,7 @@ CPluginFileTypesPreferencePage.name=File Types
CodeStylePreferencePage.name=Code Style
codeTemplatePreferencePage.name=Code Templates
codeFormatterPreferencePage.name=Formatter
+includeStylePreferencePage.name=Includes
nameStylePreferencePage.name=Name Style
CodeAssistPreferencePage.name=Content Assist
CodeAssistAdvancedPreferencePage.name=Advanced
@@ -566,7 +567,8 @@ preferenceKeywords.common=c cpp cplusplus cdt
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 field variable
+preferenceKeywords.includestyle=include includes style header file system
+preferenceKeywords.namestyle=name style 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
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 727ae91b283..a244e6e268f 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -1223,6 +1223,14 @@
+
+
+
+
+
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 fd83696f119..b56cc60ed52 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
@@ -87,6 +87,7 @@ public interface ICHelpContextIds {
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 INCLUDE_STYLE_PREFERENCE_PAGE = PREFIX + "include_style_preference_context"; //$NON-NLS-1$
public static final String NAME_STYLE_PREFERENCE_PAGE = PREFIX + "name_style_preference_context"; //$NON-NLS-1$
// Console view
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java
new file mode 100644
index 00000000000..be0c1cd36aa
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java
@@ -0,0 +1,370 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle;
+import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle.IncludeKind;
+import org.eclipse.cdt.internal.ui.refactoring.includes.IncludePreferences;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * The preference block for configuring styles of different categories of include statements.
+ */
+public class IncludeCategoriesBlock extends OptionsConfigurationBlock {
+ private static final Key KEY_STYLE_GROUP_RELATED = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_GROUP_RELATED);
+ private static final Key KEY_STYLE_PARTNER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_PARTNER);
+ private static final Key KEY_STYLE_GROUP_PARTNER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_GROUP_PARTNER);
+ private static final Key KEY_STYLE_SAME_FOLDER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_SAME_FOLDER);
+ private static final Key KEY_STYLE_GROUP_SAME_FOLDER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_GROUP_SAME_FOLDER);
+ private static final Key KEY_STYLE_SUBFOLDER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_SUBFOLDER);
+ private static final Key KEY_STYLE_GROUP_SUBFOLDER = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_GROUP_SUBFOLDER);
+ private static final Key KEY_STYLE_GROUP_SYSTEM = getCDTUIKey(IncludePreferences.INCLUDE_STYLE_GROUP_SYSTEM);
+
+ private static Key[] getAllKeys() {
+ return new Key[] {
+ KEY_STYLE_GROUP_RELATED,
+ KEY_STYLE_PARTNER,
+ KEY_STYLE_GROUP_PARTNER,
+ KEY_STYLE_SAME_FOLDER,
+ KEY_STYLE_GROUP_SAME_FOLDER,
+ KEY_STYLE_SUBFOLDER,
+ KEY_STYLE_GROUP_SUBFOLDER,
+ KEY_STYLE_GROUP_SYSTEM,
+ };
+ }
+
+ private final Category[] rootCategories;
+ private TreeListDialogField categoryTree;
+ private PixelConverter pixelConverter;
+ private StackLayout editorAreaStack;
+ private Category selectedCategory;
+
+ public IncludeCategoriesBlock(IStatusChangeListener context, IProject project,
+ IWorkbenchPreferenceContainer container) {
+ super(context, project, getAllKeys(), container);
+ rootCategories = createCategories();
+ }
+
+ private static Category[] createCategories() {
+ Category related = new Category(PreferencesMessages.IncludeCategoriesBlock_related_headers_node,
+ PreferencesMessages.IncludeCategoriesBlock_related_headers_node_description)
+ .setGroupingKey(KEY_STYLE_GROUP_RELATED);
+ new Category(PreferencesMessages.IncludeCategoriesBlock_partner_header_node,
+ PreferencesMessages.IncludeCategoriesBlock_partner_header_node_description, related)
+ .setIncludeKind(IncludeKind.PARTNER)
+ .setGroupingKey(KEY_STYLE_GROUP_PARTNER)
+ .setStyleKey(KEY_STYLE_PARTNER);
+ new Category(PreferencesMessages.IncludeCategoriesBlock_same_folder_header_node,
+ PreferencesMessages.IncludeCategoriesBlock_same_folder_header_node_description, related)
+ .setIncludeKind(IncludeKind.IN_SAME_FOLDER)
+ .setGroupingKey(KEY_STYLE_GROUP_SAME_FOLDER)
+ .setStyleKey(KEY_STYLE_SAME_FOLDER);
+ new Category(PreferencesMessages.IncludeCategoriesBlock_subfolder_header_node,
+ PreferencesMessages.IncludeCategoriesBlock_subfolder_header_node_description, related)
+ .setIncludeKind(IncludeKind.IN_SUBFOLDERS)
+ .setGroupingKey(KEY_STYLE_GROUP_SUBFOLDER)
+ .setStyleKey(KEY_STYLE_SUBFOLDER);
+ Category system = new Category(PreferencesMessages.IncludeCategoriesBlock_system_headers_node,
+ PreferencesMessages.IncludeCategoriesBlock_system_headers_node_description)
+ .setGroupingKey(KEY_STYLE_GROUP_SYSTEM);
+ return new Category[] { related, system };
+ }
+
+ public void postSetSelection(Object element) {
+ categoryTree.postSetSelection(new StructuredSelection(element));
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ pixelConverter = new PixelConverter(parent);
+
+ setShell(parent.getShell());
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ IncludeStyleAdapter adapter = new IncludeStyleAdapter();
+ categoryTree = new TreeListDialogField(adapter, null, new IncludeStyleLabelProvider());
+ categoryTree.setDialogFieldListener(adapter);
+ categoryTree.setLabelText(PreferencesMessages.NameStyleBlock_categories_label);
+ categoryTree.setViewerComparator(adapter);
+
+ createCategories();
+
+ for (Category category : rootCategories) {
+ categoryTree.addElement(category);
+ }
+
+ Label label = categoryTree.getLabelControl(composite);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.verticalAlignment = GridData.BEGINNING;
+ label.setLayoutData(gd);
+
+ Control tree = categoryTree.getTreeControl(composite);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = false;
+ gd.widthHint = pixelConverter.convertWidthInCharsToPixels(50);
+ gd.heightHint = pixelConverter.convertHeightInCharsToPixels(12);
+ tree.setLayoutData(gd);
+
+ createCategoryEditorArea(composite);
+
+ categoryTree.setTreeExpansionLevel(2);
+ categoryTree.selectFirstElement();
+
+ updateControls();
+ return composite;
+ }
+
+ private void createCategoryEditorArea(Composite parent) {
+ Composite editorArea = new Composite(parent, SWT.NONE);
+ editorArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+ editorArea.setFont(parent.getFont());
+ editorAreaStack = new StackLayout();
+ editorArea.setLayout(editorAreaStack);
+ for (Category category : rootCategories) {
+ createCategoryEditor(editorArea, category);
+ }
+ }
+
+ private void createCategoryEditor(Composite parent, Category category) {
+ IncludeGroupStyle style = null;
+ Key styleKey = category.getStyleKey();
+ if (styleKey != null) {
+ IncludeKind includeKind = category.getIncludeKind();
+ String str = getValue(styleKey);
+ if (str != null)
+ style = IncludeGroupStyle.fromString(str, includeKind);
+ if (style == null)
+ style = new IncludeGroupStyle(includeKind);
+ }
+ IncludeGroupStyleBlock block = new IncludeGroupStyleBlock(fContext, fProject, fContainer,
+ category.getDescription(), category.getGroupingKey(), style);
+ Control composite = block.createContents(parent);
+
+ category.setEditorArea(composite);
+
+ for (Category child : category.getChildren()) {
+ createCategoryEditor(parent, child);
+ }
+ }
+
+ @Override
+ protected void updateControls() {
+ super.updateControls();
+ // XXX Implement
+ }
+
+ private void updateConfigurationBlock(List