diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 6ab529a5306..12824d657a2 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -539,4 +539,5 @@ preferenceKeywords.markoccurrences=editor occurrence mark highlight
preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically
historyAction.label = History...
createScriptAction.label = Create Script...
-applyScriptAction.label = Apply Script...
\ No newline at end of file
+applyScriptAction.label = Apply Script...
+renameParticipant.name = Source Folder Rename
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index dadcd20f9f8..fbf55e0e0e0 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -3209,4 +3209,27 @@
id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
new file mode 100644
index 00000000000..c90a88df72e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences 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:
+ * Institute for Software (IFS)- initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class RenameCSourceFolderChange extends Change {
+
+ private IPath oldName;
+ private IPath newName;
+ private IProject project;
+ private IFolder folder;
+
+
+
+ public RenameCSourceFolderChange(IPath oldFolderPath, IPath newFolderPath, IProject project, IFolder oldFolder) {
+ super();
+ this.oldName = oldFolderPath;
+ this.newName = newFolderPath;
+ this.project = project;
+ folder = oldFolder;
+
+ }
+
+ @Override
+ public Object getModifiedElement() {
+ return folder;
+ }
+
+ @Override
+ public String getName() {
+ return MessageFormat.format(Messages.getString("RenameCSourceFolderChange.Name0"), oldName.lastSegment(), newName.lastSegment()); //$NON-NLS-1$
+ }
+
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {
+ }
+
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ if(folder.exists()) {
+ return RefactoringStatus.create(Status.OK_STATUS);
+ }else {
+ return RefactoringStatus.create(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, MessageFormat.format(Messages.getString("RenameCSourceFolderChange.ErroMsg"), folder.getName()))); //$NON-NLS-1$
+
+ }
+
+ }
+
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+
+ changeEntryInAllCfgs(CCorePlugin.getDefault().getProjectDescription(project, true));
+ IFolder folder2 = project.getFolder(newName.lastSegment());
+ return new RenameCSourceFolderChange(newName, oldName, project, folder2);
+ }
+
+ private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException{
+ ICConfigurationDescription cfgs[] = des.getConfigurations();
+ for(ICConfigurationDescription cfg : cfgs){
+ ICSourceEntry[] entries = cfg.getSourceEntries();
+ entries = renameEntry(entries);
+ cfg.setSourceEntries(entries);
+ }
+ CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor());//TODO Add PM
+ }
+
+ private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){
+ Set set = new HashSet();
+ for(ICSourceEntry se : entries){
+ String seLocation = se.getName();
+ if(seLocation.equals(oldName.toPortableString())) {
+ ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags());
+ set.add(newSE);
+ }else {
+ Set exPatters = new HashSet();
+ for (IPath filter : se.getExclusionPatterns()) {
+ IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1);
+ if(filter.equals(oldSegments)) {
+ exPatters.add(newName.removeFirstSegments(newName.segmentCount() -1));
+ }else {
+ exPatters.add(filter);
+ }
+ }
+
+ set.add(new CSourceEntry(se.getValue(), exPatters.toArray(new IPath[exPatters.size()]), se.getFlags()));
+ }
+ }
+ return set.toArray(new ICSourceEntry[set.size()]);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java
new file mode 100644
index 00000000000..b8863dfe4a6
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences 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:
+ * Institute for Software (IFS)- initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class RenameSourceFolder extends RenameParticipant {
+
+ private IFolder oldFolder;
+ private String newName;
+
+ /**
+ *
+ */
+ public RenameSourceFolder() {
+ }
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws OperationCanceledException {
+
+ RenameArguments arg = getArguments();
+ newName = arg.getNewName();
+ return RefactoringStatus.create(Status.OK_STATUS);
+ }
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ IPath oldFolderPath = oldFolder.getFullPath();
+ IPath newFolderPath = oldFolder.getFullPath().uptoSegment(oldFolder.getFullPath().segmentCount()-1).append(newName);
+
+ return new RenameCSourceFolderChange(oldFolderPath, newFolderPath, oldFolder.getProject(), oldFolder);
+ }
+
+ @Override
+ public String getName() {
+ return Messages.getString("RenameSourceFolder.0"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected boolean initialize(Object element) {
+ if (element instanceof IFolder) {
+ oldFolder = (IFolder) element;
+ return true;
+
+ }
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
index 9c4cf5a89d4..756a9d167f9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
@@ -95,3 +95,6 @@ ASTManager.warning.parsingError.detailed=Parsing error - {0} -
ASTManager.warning.parsingError.withFile={0} in file ''{1}''
ASTManager.warning.parsingError.withFileAndLine={0} in file ''{1}'' at line ''{2}''
ASTManager.error.macro.name.conflict=''{0}'' conflicts with the name of an existing macro!
+RenameCSourceFolderChange.ErroMsg=Folder {0} does not exist
+RenameCSourceFolderChange.Name0=Rename source Folder {0} to {1}
+RenameSourceFolder.0=Rename CDT Source Folder