summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Salinas2012-05-09 11:23:14 (EDT)
committerVivian Kong2012-05-09 11:38:54 (EDT)
commit2e27470c13c9d66befa5d86030177c83e8b4af72 (patch)
treebbbc072ce992e77c800c3628b3dc87ce19623c42
parenta45da7ed8a79a1b23741a9132f0ae06ddff74c12 (diff)
downloadorg.eclipse.cdt-2e27470c13c9d66befa5d86030177c83e8b4af72.zip
org.eclipse.cdt-2e27470c13c9d66befa5d86030177c83e8b4af72.tar.gz
org.eclipse.cdt-2e27470c13c9d66befa5d86030177c83e8b4af72.tar.bz2
Bug 375859 - Refresh scope becomes empty after closing/opening project
if left to default
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java44
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java29
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java27
3 files changed, 66 insertions, 34 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
index 2bb3664..02686a7 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RefreshPolicyTab.java
@@ -18,13 +18,18 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+
import org.eclipse.cdt.core.resources.ExclusionInstance;
import org.eclipse.cdt.core.resources.ExclusionType;
import org.eclipse.cdt.core.resources.RefreshExclusion;
import org.eclipse.cdt.core.resources.RefreshScopeManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.newui.CDTPropertyManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -66,7 +71,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
* @since 8.0
*/
@SuppressWarnings("restriction")
-public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
+public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
private final Image IMG_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER);
private final Image IMG_FILE = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_FILE_OBJ);
@@ -93,6 +98,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
HashMap<IResource, List<RefreshExclusion>> resourceMap = fConfigurationToResourcesToExclusionsMap.get(configName);
if (resourceMap == null) {
resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
+ resourceMap.put(fProject, new ArrayList<RefreshExclusion>());
fConfigurationToResourcesToExclusionsMap.put(configName, resourceMap);
}
@@ -107,8 +113,8 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
HashMap<String, HashMap<IResource, List<RefreshExclusion>>> target = new HashMap<String, HashMap<IResource, List<RefreshExclusion>>>();
- if (source.size() == 0)
- return null;
+ if (source.isEmpty())
+ return target;
Iterator<String> config_iterator = source.keySet().iterator();
// for each Configuration ...
@@ -125,8 +131,13 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
List<RefreshExclusion> target_exclusions = new LinkedList<RefreshExclusion>();
for (RefreshExclusion exclusion : source_exclusions) {
// ADD each exclusion to the target exclusion list.
- RefreshExclusion target_exclusion = (RefreshExclusion) exclusion.clone();
- target_exclusions.add(target_exclusion);
+ try {
+ RefreshExclusion target_exclusion = (RefreshExclusion) exclusion.clone();
+ target_exclusions.add(target_exclusion);
+ } catch (CloneNotSupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
// ADD the exclusion list for this resource
@@ -135,13 +146,15 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
// ADD each resource.
target.put(configName, target_resourceMap);
+
}
+
return target;
}
private void loadInfo() {
HashMap<String, HashMap<IResource, List<RefreshExclusion>>> configMap = fManager.getConfigurationToResourcesMap(fProject);
- if ( (configMap != null) && !(configMap.isEmpty()))
+ if (configMap != null)
fConfigurationToResourcesToExclusionsMap = copyHashMap(configMap);
}
@@ -151,6 +164,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
if(exclusions == null) {
exclusions = new LinkedList<RefreshExclusion>();
resourceMap.put(resource, exclusions);
+
}
return resourceMap.get(resource);
}
@@ -159,10 +173,10 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
* Wrapper for IResource/RefreshExclusion
*/
class _Entry {
- //if this is a refresh exclusion, resourceToRefresh will be null
+ //if this is not a resource to refresh, resourceToRefresh will be null
IResource resourceToRefresh = null;
- //if this is a resource to refresh, exclusion will be null
+ //if this is not a refresh exclusion, exclusion will be null
RefreshExclusion exclusion = null;
//if this is a refresh exclusion, parent is the Exceptions node this is a child of
@@ -300,6 +314,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
if (exclusions == null) {
exclusions = new LinkedList<RefreshExclusion>();
getResourcesToExclusionsMap(getConfigName()).put(parent.resourceToRefresh, exclusions);
+
}
exclusions.add(exclusion);
}
@@ -349,6 +364,8 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
}
}
+
+
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#createControls(org.eclipse.swt.widgets.Composite)
*/
@@ -370,7 +387,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
Group g1 = setupGroup(usercomp, Messages.RefreshPolicyTab_resourcesGroupLabel, 2, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
fSrc = new ArrayList<_Entry>();
- generateTreeContent();
+ generateTreeContent();
fTree = new TreeViewer(g1);
fTree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -505,6 +522,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
@Override
protected void performDefaults() {
// TODO Auto-generated method stub
+
}
@Override
@@ -521,6 +539,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
}
}
+
@Override
protected void updateButtons() {
TreeItem[] sel = fTree.getTree().getSelection();
@@ -538,7 +557,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
@Override
public Object[] getChildren(Object element) {
ArrayList<Object> filteredChildren = new ArrayList<Object>(Arrays.asList(super.getChildren(element)));
- Iterator<IResource> iterator = getResourcesToExclusionsMap(getConfigName()).keySet().iterator(); //fResourcesToRefresh.iterator();
+ Iterator<IResource> iterator = getResourcesToExclusionsMap(getConfigName()).keySet().iterator();
while (iterator.hasNext()) {
filteredChildren.remove(iterator.next());
@@ -676,12 +695,15 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
*/
@Override
protected void performOK() {
+
+
Iterator<String> config_iterator = fConfigurationToResourcesToExclusionsMap.keySet().iterator();
while (config_iterator.hasNext()) {
String configName = config_iterator.next();
- fManager.setResourcesToExclusionsMap(fProject, configName, getResourcesToExclusionsMap(configName));
+ fManager.setResourcesToExclusionsMap(fProject, configName, getResourcesToExclusionsMap(configName));
+
}
try {
fManager.persistSettings(getResDesc().getConfiguration().getProjectDescription());
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
index 81c4628..c6d45b6 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
@@ -27,10 +27,12 @@ import org.eclipse.cdt.core.resources.ExclusionInstance;
import org.eclipse.cdt.core.resources.ExclusionType;
import org.eclipse.cdt.core.resources.RefreshExclusion;
import org.eclipse.cdt.core.resources.RefreshScopeManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -406,8 +408,13 @@ public class RefreshScopeTests extends TestCase {
IResource config1_resource = fProject;
- manager.addResourceToRefresh(fProject, config1, config1_resource);
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false);
+ ICConfigurationDescription conf = projectDescription.getActiveConfiguration();
+ String conf_name = conf.getName();
+ manager.addResourceToRefresh(fProject, conf_name, config1_resource);
+
// create a series of nested exclusions that include/exclude certain folders
// will be included/excluded as follows
/*
@@ -428,7 +435,8 @@ public class RefreshScopeTests extends TestCase {
ExclusionInstance instance2 = new ExclusionInstance();
instance2.setResource(fFolder2);
exclusion1.addExclusionInstance(instance2);
- manager.addExclusion(fProject, config1, config1_resource, exclusion1);
+ manager.addExclusion(fProject, conf_name, config1_resource, exclusion1);
+
ResourceExclusion exclusion2 = new ResourceExclusion();
ExclusionInstance instance3 = new ExclusionInstance();
@@ -444,14 +452,15 @@ public class RefreshScopeTests extends TestCase {
// now check and see if the right folders are included/excluded
- assertEquals(true, manager.shouldResourceBeRefreshed(config1, config1_resource));
- assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder1));
- assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder2));
- assertEquals(true, manager.shouldResourceBeRefreshed(config1, fFolder3));
- assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder4));
- assertEquals(true, manager.shouldResourceBeRefreshed(config1, fFolder5));
- assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder6));
-
+ assertEquals(true, manager.shouldResourceBeRefreshed(conf_name, config1_resource));
+ assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder1));
+ assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder2));
+ assertEquals(true, manager.shouldResourceBeRefreshed(conf_name, fFolder3));
+ assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder4));
+ assertEquals(true, manager.shouldResourceBeRefreshed(conf_name, fFolder5));
+ assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder6));
+
+
// now let's create a bunch of files in these directories using java.io.File (so that we don't get
// resource deltas happening), and refresh the project according to the policy. We should only see the files
// in the same folders above when consulting the resource system
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
index 33af877..c3cb38a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
@@ -148,8 +148,10 @@ public class RefreshScopeManager {
|| (delta.getKind() == IResourceDelta.CHANGED && ((delta
.getFlags() & IResourceDelta.OPEN) != 0))) {
+ fIsLoading = true;
loadSettings(ResourcesPlugin.getWorkspace()
.getRoot(), project);
+ fIsLoading = false;
return false;
}
@@ -344,17 +346,17 @@ public class RefreshScopeManager {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- HashMap<String,HashMap<IResource, List<RefreshExclusion>>> configMap = getConfigurationToResourcesMap(project);
-
- Iterator<String> it = configMap.keySet().iterator();
- while (it.hasNext()) {
- String configName = it.next();
- List<IResource> resourcesToRefresh = getResourcesToRefresh(project,configName);
- for (IResource resource : resourcesToRefresh) {
- List<RefreshExclusion> exclusions = getExclusions(project,configName,resource);
- refreshResources(configName, resource, exclusions, monitor);
- }
- }
+
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
+ .getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
+ ICConfigurationDescription active_conf = projectDescription.getActiveConfiguration();
+ String name = active_conf.getName();
+ List<IResource> resourcesToRefresh = getResourcesToRefresh(project,name);
+ for (IResource resource : resourcesToRefresh) {
+ List<RefreshExclusion> exclusions = getExclusions(project,name,resource);
+ refreshResources(name, resource, exclusions, monitor);
+ }
}
};
@@ -723,8 +725,7 @@ public class RefreshScopeManager {
/**
* @since 5.4
*/
- public synchronized void setResourcesToExclusionsMap(IProject project, String configName, HashMap<IResource, List<RefreshExclusion>> source_resourceMap) { // List<IResource> resources) {
-
+ public synchronized void setResourcesToExclusionsMap(IProject project, String configName, HashMap<IResource, List<RefreshExclusion>> source_resourceMap) {
HashMap<IResource, List<RefreshExclusion>> target_resourceMap = getResourcesToExclusionsMap(project,configName);
target_resourceMap.clear();