1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Bug 174238 - Fix problems when the project is not a source root.

This commit is contained in:
Ken Ryall 2007-05-04 21:04:56 +00:00
parent 18e23110d2
commit aa25f29965
2 changed files with 22 additions and 3 deletions

View file

@ -9,6 +9,7 @@
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* IBM Corporation * IBM Corporation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Warren Paul (Nokia) - 174238
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard; package org.eclipse.cdt.internal.ui.wizards.classwizard;
@ -114,7 +115,9 @@ public class NewClassWizardUtil {
if (sourceFolder != null) if (sourceFolder != null)
return sourceFolder; return sourceFolder;
if (resType == IResource.PROJECT) { if (resType == IResource.PROJECT) {
return (ICContainer)elem; if (elem instanceof ICContainer) {
return (ICContainer)elem;
}
} }
} }
} }

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* IBM Corporation * IBM Corporation
* Warren Paul (Nokia) - 174238
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.wizards; package org.eclipse.cdt.ui.wizards;
@ -1198,6 +1199,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
} }
changedFields = HEADER_FILE_ID | SOURCE_FILE_ID; changedFields = HEADER_FILE_ID | SOURCE_FILE_ID;
updateFileGroupEnableState(); updateFileGroupEnableState();
handleFieldChanged(SOURCE_FOLDER_ID);
} }
if (field == fHeaderFileDialogField) { if (field == fHeaderFileDialogField) {
changedFields |= HEADER_FILE_ID; changedFields |= HEADER_FILE_ID;
@ -1451,8 +1453,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.warning.NotInACProject")); //$NON-NLS-1$ status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.warning.NotInACProject")); //$NON-NLS-1$
} }
if (NewClassWizardUtil.getSourceFolder(res) == null) { if (NewClassWizardUtil.getSourceFolder(res) == null) {
status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$ if (isUseDefaultSelected()) {
return status; status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$
return status;
}
} }
} else { } else {
status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$ status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$
@ -1698,6 +1702,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status; 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; boolean fileExists = false;
// check if file already exists // check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path); IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path);
@ -1765,6 +1775,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status; 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; boolean fileExists = false;
// check if file already exists // check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path); IResource file = NewClassWizardUtil.getWorkspaceRoot().findMember(path);