Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2007-02-22 15:13:52 +0000
committerAnton Leherbauer2007-02-22 15:13:52 +0000
commitdb942775bb6b5cb21b5dbb1ac70fd8eaef127513 (patch)
tree59b61ad89ca4ef6099cc362d6898d3d445d6467a
parentadb747feb2e90fcc331d29e86060fc0513e918ac (diff)
downloadorg.eclipse.cdt-db942775bb6b5cb21b5dbb1ac70fd8eaef127513.tar.gz
org.eclipse.cdt-db942775bb6b5cb21b5dbb1ac70fd8eaef127513.tar.xz
org.eclipse.cdt-db942775bb6b5cb21b5dbb1ac70fd8eaef127513.zip
Fix for Bug 174762 - [Working Set] working set cannot be restored for closed projects
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java42
2 files changed, 42 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
index d28a8a7d25b..0b37e21c932 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2007 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Rational Software - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@@ -570,6 +571,7 @@ public class DeltaProcessor {
//Don't process children
return false;
}
+ return false;
}
if ((flags & IResourceDelta.DESCRIPTION) != 0) {
IProject res = (IProject)delta.getResource();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
index 25498d2049b..547ce717e01 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 IBM Corporation 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
@@ -11,8 +11,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
+import java.io.File;
+
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
@@ -35,6 +41,7 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable
// These persistence constants are stored in XML. Do not
// change them.
private static final String TAG_PATH = "path";//$NON-NLS-1$
+ private static final String TAG_TYPE = "type";//$NON-NLS-1$
private static final String FACTORY_ID = "org.eclipse.cdt.ui.PersistableCElementFactory";//$NON-NLS-1$
@@ -66,14 +73,42 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable
return null;
}
- fCElement = CoreModel.getDefault().create(new Path(fileName));
+ IPath elementPath= new Path(fileName);
+ fCElement = CoreModel.getDefault().create(elementPath);
if (fCElement != null && fCElement.getResource() != null) {
IResource resource= fCElement.getResource();
if (!resource.isAccessible()) {
return resource;
}
}
- return fCElement;
+ if (fCElement != null) {
+ return fCElement;
+ }
+
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Integer elementType= memento.getInteger(TAG_TYPE);
+ if (elementType == null) {
+ if (elementPath.segmentCount() == 1) {
+ return root.getProject(fileName);
+ }
+ IFolder folder= root.getFolder(elementPath);
+ File osFile= folder.getLocation().toFile();
+ if (osFile.isDirectory()) {
+ return folder;
+ }
+ return root.getFile(elementPath);
+ }
+ switch (elementType.intValue()) {
+ case IResource.ROOT:
+ return root;
+ case IResource.PROJECT:
+ return root.getProject(fileName);
+ case IResource.FOLDER:
+ return root.getFolder(elementPath);
+ case IResource.FILE:
+ return root.getFile(elementPath);
+ }
+ return null;
}
/**
@@ -89,6 +124,7 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable
public void saveState(IMemento memento) {
if (fCElement.getResource() != null) {
memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString());
+ memento.putInteger(TAG_TYPE, fCElement.getResource().getType());
}
}
}

Back to the top