Apply CDT patch to prevent refreshing of exe list.
authorryall
Wed, 27 May 2009 15:25:05 -0500
changeset 11 b95605ba8677
parent 10 79d8b140b8cd (current diff)
parent 9 cf4891b2fe55 (diff)
child 12 063eb66097dc
Apply CDT patch to prevent refreshing of exe list.
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java	Wed May 27 15:25:05 2009 -0500
@@ -33,6 +33,7 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 
 /**
  * Creates labels for ICElement objects.
@@ -722,7 +723,14 @@
 		if (rootQualified) {
 			buf.append(container.getPath().makeRelative().toString());
 		} else {
-			buf.append(container.getElementName());
+			if (CCorePlugin.showSourceRootsAtTopOfProject()) {
+				buf.append(container.getElementName());
+			}
+			else {
+				String elementName = container.getElementName();
+				IPath path = new Path(elementName);
+				buf.append(path.lastSegment());
+			}
 			if (getFlag(flags, ROOT_QUALIFIED)) {
 				if (resource != null && container instanceof ISourceRoot && isReferenced((ISourceRoot)container)) {
 					buf.append(CONCAT_STRING);
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java	Wed May 27 15:25:05 2009 -0500
@@ -1186,5 +1186,13 @@
 		return UserVarSupplier.getInstance();
 	}
 	
-	
+	/**
+	 * Returns preference controlling whether source roots are shown at the top of projects
+	 * or embedded within the resource tree of projects when they are not top level folders.
+	 * 
+	 * @return boolean preference value
+	 */
+	public static boolean showSourceRootsAtTopOfProject() {
+		return getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT) == true;
+	}
 }
\ No newline at end of file
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java	Wed May 27 15:25:05 2009 -0500
@@ -126,4 +126,9 @@
 	 * Attempt to show source files for executable binaries.
 	 */
 	public static final String SHOW_SOURCE_FILES_IN_BINARIES = CCorePlugin.PLUGIN_ID + ".showSourceFilesInBinaries"; //$NON-NLS-1$
+	
+	/**
+	 * Show source roots at the top level of projects.
+	 */
+	public static final String SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT = CCorePlugin.PLUGIN_ID + ".showSourceRootsAtTopLevelOfProject"; //$NON-NLS-1$
 }
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java	Wed May 27 15:25:05 2009 -0500
@@ -61,6 +61,8 @@
 
 		defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true);
 		defaultPreferences.putBoolean(CCorePlugin.PREF_USE_STRUCTURAL_PARSE_MODE, false);
+		
+		defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true);
 
 		// indexer defaults
 		IndexerPreferences.initializeDefaultPreferences(defaultPreferences);
Binary file cdt/cdt_5_0_x/org.eclipse.cdt.ui/icons/obj16/sroot2_obj.gif has changed
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java	Wed May 27 15:25:05 2009 -0500
@@ -26,6 +26,7 @@
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.ui.model.IWorkbenchAdapter;
 
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.IArchive;
@@ -344,6 +345,7 @@
 			
 		List<ICElement> list= new ArrayList<ICElement>();
 		ICElement[] children = cproject.getChildren();
+
 		for (int i= 0; i < children.length; i++) {
 			ICElement child = children[i];
 			if (child instanceof ISourceRoot && child.getResource().getType() == IResource.PROJECT) {
@@ -351,8 +353,12 @@
 				ICElement[] c2 = ((ISourceRoot)child).getChildren();
 				for (int k = 0; k < c2.length; ++k)
 					list.add(c2[k]);
-			} else
+			} else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
 				list.add(child);
+			} else if (child instanceof ISourceRoot && 
+						child.getResource().getParent().equals(cproject.getProject())) {	
+				list.add(child);
+			}
 		}
 
 		Object[] objects = list.toArray();
@@ -483,16 +489,19 @@
 			// folder we have to exclude it as a normal child.
 			if (o instanceof IFolder) {
 				IFolder folder = (IFolder)o;
-				boolean found = false;
+				ISourceRoot root = null;
 				for (int j = 0; j < roots.length; j++) {
 					if (roots[j].getPath().equals(folder.getFullPath())) {
-						found = true;
+						root = roots[j];
 						break;
 					}
 				}
 				// it is a sourceRoot skip it.
-				if (found) {
-					continue;
+				if (root != null) {
+					if (CCorePlugin.showSourceRootsAtTopOfProject())
+						continue;
+					else
+						o = root;
 				}
 			} else if (o instanceof IFile){
 				boolean found = false;
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java	Wed May 27 15:25:05 2009 -0500
@@ -98,6 +98,7 @@
 	public static final String IMG_OBJS_TUNIT_RESOURCE_H= NAME_PREFIX + "ch_resource_obj.gif"; //$NON-NLS-1$
 	public static final String IMG_OBJS_TUNIT_RESOURCE_A= NAME_PREFIX + "asm_resource_obj.gif"; //$NON-NLS-1$
 	public static final String IMG_OBJS_SOURCE_ROOT=  NAME_PREFIX + "sroot_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+	public static final String IMG_OBJS_SOURCE2_ROOT=  NAME_PREFIX + "sroot2_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
 	public static final String IMG_OBJS_CFOLDER=  NAME_PREFIX + "cfolder_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
 	public static final String IMG_OBJS_CONFIG =  NAME_PREFIX + "config.gif"; // $NON-NLS-1$  //$NON-NLS-1$
 	public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
@@ -180,6 +181,7 @@
 	public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_H= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_H);
 	public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_A= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_A);
 	public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT);
+	public static final ImageDescriptor DESC_OBJS_SOURCE2_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE2_ROOT);
 	public static final ImageDescriptor DESC_OBJS_CFOLDER= createManaged(T_OBJ, IMG_OBJS_CFOLDER);
 	public static final ImageDescriptor DESC_OBJS_CONFIG = createManaged(T_OBJ, IMG_OBJS_CONFIG);
 	public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java	Wed May 27 15:25:05 2009 -0500
@@ -12,6 +12,7 @@
 package org.eclipse.cdt.internal.ui.preferences;
 
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Preferences;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -28,7 +29,10 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonNavigator;
 
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
 import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.cdt.ui.PreferenceConstants;
 
@@ -47,6 +51,7 @@
 	private SelectionButtonDialogField fOutlineGroupNamespaces;
 	private SelectionButtonDialogField fCViewGroupIncludes;
 	private SelectionButtonDialogField fCViewSeparateHeaderAndSource;
+	private SelectionButtonDialogField fShowSourceRootsAtTopOfProject;
 	
 	public AppearancePreferencePage() {
 		setPreferenceStore(PreferenceConstants.getPreferenceStore());
@@ -77,6 +82,12 @@
 		fCViewSeparateHeaderAndSource= new SelectionButtonDialogField(SWT.CHECK);
 		fCViewSeparateHeaderAndSource.setDialogFieldListener(listener);
 		fCViewSeparateHeaderAndSource.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewSeparateHeaderAndSource_label); 
+	
+		fShowSourceRootsAtTopOfProject= new SelectionButtonDialogField(SWT.CHECK);
+		fShowSourceRootsAtTopOfProject.setDialogFieldListener(listener);
+		fShowSourceRootsAtTopOfProject.setLabelText(PreferencesMessages.AppearancePreferencePage_showSourceRootsAtTopOfProject_label); 
+		
+	
 	}
 
 	private void initFields() {
@@ -86,6 +97,8 @@
 		fCViewSeparateHeaderAndSource.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
 		fOutlineGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
 		fOutlineGroupNamespaces.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
+		boolean showSourceRootsAtTopOfProject = CCorePlugin.showSourceRootsAtTopOfProject();
+		fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsAtTopOfProject);
 	}
 	
 	/*
@@ -120,7 +133,6 @@
 		new Separator().doFillIntoGrid(result, nColumns);
 		
 		fCViewSeparateHeaderAndSource.doFillIntoGrid(result, nColumns);
-		
 		String noteTitle= PreferencesMessages.AppearancePreferencePage_note;
 		String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyForNewViews; 
 		Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
@@ -128,6 +140,10 @@
 		gd.horizontalSpan= 2;
 		noteControl.setLayoutData(gd);
 		
+		
+		new Separator().doFillIntoGrid(result, nColumns);
+		fShowSourceRootsAtTopOfProject.doFillIntoGrid(result, nColumns);
+		
 		initFields();
 		
 		Dialog.applyDialogFont(result);
@@ -165,6 +181,8 @@
 		prefs.setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, fOutlineGroupIncludes.isSelected());
 		prefs.setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, fOutlineGroupNamespaces.isSelected());
 		CUIPlugin.getDefault().savePluginPreferences();
+		CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, fShowSourceRootsAtTopOfProject.isSelected());
+		CCorePlugin.getDefault().savePluginPreferences();
 		return super.performOk();
 	}	
 	
@@ -179,6 +197,8 @@
 		fCViewSeparateHeaderAndSource.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
 		fOutlineGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
 		fOutlineGroupNamespaces.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
+		Preferences corePrefs = CCorePlugin.getDefault().getPluginPreferences();
+		fShowSourceRootsAtTopOfProject.setSelection(corePrefs.getDefaultBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT));
 		super.performDefaults();
 	}
 }
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java	Wed May 27 15:25:05 2009 -0500
@@ -139,6 +139,7 @@
 	public static String AppearancePreferencePage_outlineGroupNamespaces_label;
 	public static String AppearancePreferencePage_note;
 	public static String AppearancePreferencePage_preferenceOnlyForNewViews;
+	public static String AppearancePreferencePage_showSourceRootsAtTopOfProject_label;
 	public static String CEditorPreferencePage_folding_title;
 	public static String FoldingConfigurationBlock_enable;
 	public static String FoldingConfigurationBlock_combo_caption;
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties	Wed May 27 15:25:05 2009 -0500
@@ -153,6 +153,7 @@
 AppearancePreferencePage_outlineGroupNamespaces_label= Group namespaces in the Outline view
 AppearancePreferencePage_note=Note:
 AppearancePreferencePage_preferenceOnlyForNewViews=This preference does not affect open views
+AppearancePreferencePage_showSourceRootsAtTopOfProject_label=Show source roots at top of project
 
 #Folding
 CEditorPreferencePage_folding_title= &Folding
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java	Wed May 27 15:07:28 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java	Wed May 27 15:25:05 2009 -0500
@@ -14,8 +14,12 @@
 package org.eclipse.cdt.internal.ui.viewsupport;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
@@ -23,6 +27,7 @@
 import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.model.IWorkbenchAdapter;
 
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.IArchiveContainer;
@@ -45,6 +50,9 @@
 import org.eclipse.cdt.ui.CElementImageDescriptor;
 import org.eclipse.cdt.ui.CUIPlugin;
 
+import org.eclipse.cdt.internal.core.model.CModel;
+import org.eclipse.cdt.internal.core.model.CModelManager;
+
 import org.eclipse.cdt.internal.ui.CPluginImages;
 
 
@@ -137,6 +145,9 @@
 				Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
 				descriptor = new CElementImageDescriptor(descriptor, 0, size);
 			}
+		} else if (!CCorePlugin.showSourceRootsAtTopOfProject() &&
+				element instanceof IFolder && isParentOfSourceRoot(element)) {
+			descriptor = CPluginImages.DESC_OBJS_SOURCE2_ROOT;
 		}
 		if (descriptor == null && element instanceof IAdaptable) {
 			descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
@@ -147,6 +158,24 @@
 		return null;
 	}
 
+	private boolean isParentOfSourceRoot(Object element) {
+		IFolder folder = (IFolder)element;
+		ICProject cproject = CModelManager.getDefault().getCModel().findCProject(folder.getProject());
+		if (cproject != null) {
+			try {
+				IPath folderPath = folder.getFullPath();
+				for (ICElement sourceRoot : cproject.getSourceRoots()) {
+					if (folderPath.isPrefixOf(sourceRoot.getPath())) {
+						return true;
+					}
+				}
+			} catch (CModelException e) {
+			}
+		}
+		
+		return false;
+	}
+
 	public static ImageDescriptor getImageDescriptor(int type) {
 		switch (type) {
 			case ICElement.C_VCONTAINER: