Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Ryall2007-05-04 21:04:56 +0000
committerKen Ryall2007-05-04 21:04:56 +0000
commitaa25f299656e9b7e407b9978d5d80da1c8e63477 (patch)
treea637e4faf0b18dab9cd220e903cf85aea39ea894
parent18e23110d276a47d1dcdb9e1fd751ba5d79081c6 (diff)
downloadorg.eclipse.cdt-aa25f299656e9b7e407b9978d5d80da1c8e63477.tar.gz
org.eclipse.cdt-aa25f299656e9b7e407b9978d5d80da1c8e63477.tar.xz
org.eclipse.cdt-aa25f299656e9b7e407b9978d5d80da1c8e63477.zip
Bug 174238 - Fix problems when the project is not a source root.
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java20
2 files changed, 22 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index 3b5b97a557d..7995b62511f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -9,6 +9,7 @@
* QNX Software Systems - initial API and implementation
* IBM Corporation
* Markus Schorn (Wind River Systems)
+ * Warren Paul (Nokia) - 174238
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
@@ -114,7 +115,9 @@ public class NewClassWizardUtil {
if (sourceFolder != null)
return sourceFolder;
if (resType == IResource.PROJECT) {
- return (ICContainer)elem;
+ if (elem instanceof ICContainer) {
+ return (ICContainer)elem;
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 888dff1467f..05d4b4d4f22 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* IBM Corporation
+ * Warren Paul (Nokia) - 174238
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
@@ -1198,6 +1199,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
changedFields = HEADER_FILE_ID | SOURCE_FILE_ID;
updateFileGroupEnableState();
+ handleFieldChanged(SOURCE_FOLDER_ID);
}
if (field == fHeaderFileDialogField) {
changedFields |= HEADER_FILE_ID;
@@ -1451,8 +1453,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.warning.NotInACProject")); //$NON-NLS-1$
}
if (NewClassWizardUtil.getSourceFolder(res) == null) {
- status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$
- return status;
+ if (isUseDefaultSelected()) {
+ status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$
+ return status;
+ }
}
} else {
status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$
@@ -1698,6 +1702,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status;
}
+ // Make sure the file location is under a source root
+ if (NewClassWizardUtil.getSourceFolder(path) == null) {
+ status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.HeaderFileNotInSourceFolder")); //$NON-NLS-1$
+ return status;
+ }
+
boolean fileExists = false;
// check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path);
@@ -1765,6 +1775,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status;
}
+ // Make sure the file location is under a source root
+ if (NewClassWizardUtil.getSourceFolder(path) == null) {
+ status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.SourceFileNotInSourceFolder")); //$NON-NLS-1$
+ return status;
+ }
+
boolean fileExists = false;
// check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path);

Back to the top