diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index edce4e6458c..c7bf891c0ec 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,3 +1,12 @@
+2004-06-09 David Inglis
+
+ added new ICDescriptor manager method to get a descriptor with the option of creating
+ one if it does not exists.
+
+ * src/org/eclipse/cdt/core/ICDescriptorManager.java
+ * src/org/eclipse/cdt/core/CCorePlugin.java
+ * src/org/eclipse/cdt/internal/core/CDescriptorManager.java
+
2004-06-08 Tanya Wolff
Fix for I18N defect 66136
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index cfbd102a160..037fee6a105 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -703,10 +703,29 @@ public class CCorePlugin extends Plugin {
return fCoreModel;
}
+ /**
+ * @param project
+ * @return
+ * @throws CoreException
+ * @deprecated use getCProjetDescription(IProject project, boolean create)
+ */
public ICDescriptor getCProjectDescription(IProject project) throws CoreException {
return fDescriptorManager.getDescriptor(project);
}
+ /**
+ * Get the ICDescriptor for the given project, if create is true then a descriptor will be created
+ * if one does not exist.
+ *
+ * @param project
+ * @param create
+ * @return ICDescriptor or null if create is false and no .cdtproject file exists on disk.
+ * @throws CoreException
+ */
+ public ICDescriptor getCProjectDescription(IProject project, boolean create) throws CoreException {
+ return fDescriptorManager.getDescriptor(project, create);
+ }
+
public void mapCProjectOwner(IProject project, String id, boolean override) throws CoreException {
if (!override) {
fDescriptorManager.configure(project, id);
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java
index b27bc4b5ed0..67fe30ae6f9 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java
@@ -14,13 +14,50 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
public interface ICDescriptorManager {
+
+ /**
+ * @param project
+ * @param id
+ * @throws CoreException
+ */
public void configure(IProject project, String id) throws CoreException;
+ /**
+ * @param project
+ * @param id
+ * @throws CoreException
+ */
public void convert(IProject project, String id) throws CoreException;
+ /**
+ * @param project
+ * @return
+ * @throws CoreException
+ */
public ICDescriptor getDescriptor(IProject project) throws CoreException;
+
+ /**
+ * @param project
+ * @param forceCreation
+ * @return
+ * @throws CoreException
+ */
+ public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException;
+ /**
+ * @param project
+ * @param op
+ * @param monitor
+ * @throws CoreException
+ */
public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException;
+ /**
+ * @param listener
+ */
public void addDescriptorListener(ICDescriptorListener listener);
+
+ /**
+ * @param listener
+ */
public void removeDescriptorListener(ICDescriptorListener listener);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
index 2939a6a302c..9eff7f22ba3 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
@@ -231,8 +231,12 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
}
synchronized public ICDescriptor getDescriptor(IProject project) throws CoreException {
+ return getDescriptor(project, true);
+ }
+
+ synchronized public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException {
CDescriptor descriptor = (CDescriptor)fDescriptorMap.get(project);
- if (descriptor == null) {
+ if (descriptor == null && create) {
descriptor = new CDescriptor(this, project);
fDescriptorMap.put(project, descriptor);
}
@@ -338,7 +342,10 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
}
public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException {
- ICDescriptor descriptor = getDescriptor(project);
+ ICDescriptor descriptor = getDescriptor(project, false);
+ if (descriptor == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Project does not have descriptor", null)); //$NON-NLS-1$
+ }
CDescriptorEvent event = null;
synchronized (descriptor) {
beginOperation(descriptor);