1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

2004-11-10 Chris Wiebe

Fix for 78200
	* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties
	* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
	* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
This commit is contained in:
Chris Wiebe 2004-11-10 18:07:54 +00:00
parent 202b01f023
commit 28922940be
4 changed files with 46 additions and 61 deletions

View file

@ -1,3 +1,10 @@
2004-11-10 Chris Wiebe
Fix for 78200
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
2004-11-05 Alain Magloire
Framework for code formatter.
* src/org/eclipse/cdt/internal/coreext/CodeFormatterUtil.java

View file

@ -16,7 +16,6 @@ AbstractFileCreationWizard.title= New File
AbstractFileCreationWizardPage.error.SelectedProjectError= Error in determining the selected project.
AbstractFileCreationWizardPage.error.DefaultSourceFolderError= Error in determining the default source folder.
AbstractFileCreationWizardPage.error.NotAvailableForNonCProjects= The wizard is not available for non C/C++ projects.
AbstractFileCreationWizardPage.sourceFolder.label=Source &Folder:
AbstractFileCreationWizardPage.sourceFolder.button=Br&owse...
AbstractFileCreationWizardPage.ChooseSourceFolderDialog.title=Folder Selection
@ -25,7 +24,8 @@ AbstractFileCreationWizardPage.error.EnterSourceFolderName=Source folder name is
AbstractFileCreationWizardPage.error.NotAFolder=''{0}'' is not a project or folder.
AbstractFileCreationWizardPage.error.NotASourceFolder=Folder ''{0}'' is not a source folder.
AbstractFileCreationWizardPage.error.ProjectClosed=Project ''{0}'' must be accessible.
AbstractFileCreationWizardPagewarning.NotACProject=Folder is not a C/C++ project.
AbstractFileCreationWizardPage.error.FolderDoesNotExist=Folder ''{0}'' does not exist.
AbstractFileCreationWizardPage.warning.NotACProject=Folder is not a C/C++ project.
AbstractFileCreationWizardPage.warning.NotInACProject=Folder is not in a C/C++ project.
# ------- NewHeaderFileCreationWizard -------

View file

@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.filewizard;
import java.io.File;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
@ -22,6 +19,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@ -37,7 +35,7 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
private StringDialogField fNewFileDialogField;
public NewHeaderFileCreationWizardPage() {
super(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.title"));
super(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.title")); //$NON-NLS-1$
setDescription(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.description")); //$NON-NLS-1$
fNewFileDialogField = new StringDialogField();
@ -92,40 +90,31 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$
return status;
}
IPath sourceFolderPath = getSourceFolderFullPath();
if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
return status;
}
// check if file already exists
IPath workspacePath = getWorkspaceRoot().getLocation();
File file = workspacePath.append(filePath).toFile();
// if (file == null || !file.exists()) {
// IResource res = fWorkspaceRoot.findMember(path);
// if (res != null && res.exists()) {
// file = res.getLocation().toFile();
// }
// }
if (file != null && file.exists()) {
if (file.isFile()) {
IResource file = getWorkspaceRoot().findMember(filePath);
if (file != null && file.exists()) {
if (file.getType() == IResource.FILE) {
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$
} else if (file.isDirectory()) {
} else if (file.getType() == IResource.FOLDER) {
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$
} else {
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$
}
return status;
} else if (filePath.segmentCount() > 1) {
IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1);
File folder = parentFolderPath.toFile();
if (folder != null && folder.exists() && folder.isDirectory()) {
// folder exists
} else {
status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$
return status;
}
}
// make sure file is inside source folder
IPath folderPath = getSourceFolderFullPath();
if (folderPath != null && !folderPath.isPrefixOf(filePath)) {
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
// check if folder exists
IPath folderPath = filePath.removeLastSegments(1).makeRelative();
IResource folder = getWorkspaceRoot().findMember(folderPath);
if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.FolderDoesNotExist", folderPath)); //$NON-NLS-1$
return status;
}

View file

@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.filewizard;
import java.io.File;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
@ -22,6 +19,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@ -36,7 +34,7 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
private StringDialogField fNewFileDialogField;
public NewSourceFileCreationWizardPage() {
super(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.title"));
super(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.title")); //$NON-NLS-1$
setDescription(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.description")); //$NON-NLS-1$
fNewFileDialogField = new StringDialogField();
@ -82,7 +80,7 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
}
return path;
}
protected IStatus fileNameChanged() {
StatusInfo status = new StatusInfo();
@ -91,40 +89,31 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$
return status;
}
IPath sourceFolderPath = getSourceFolderFullPath();
if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
return status;
}
// check if file already exists
IPath workspacePath = getWorkspaceRoot().getLocation();
File file = workspacePath.append(filePath).toFile();
// if (file == null || !file.exists()) {
// IResource res = fWorkspaceRoot.findMember(path);
// if (res != null && res.exists()) {
// file = res.getLocation().toFile();
// }
// }
if (file != null && file.exists()) {
if (file.isFile()) {
IResource file = getWorkspaceRoot().findMember(filePath);
if (file != null && file.exists()) {
if (file.getType() == IResource.FILE) {
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$
} else if (file.isDirectory()) {
} else if (file.getType() == IResource.FOLDER) {
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$
} else {
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$
}
return status;
} else if (filePath.segmentCount() > 1) {
IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1);
File folder = parentFolderPath.toFile();
if (folder != null && folder.exists() && folder.isDirectory()) {
// folder exists
} else {
status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$
return status;
}
}
// make sure file is inside source folder
IPath folderPath = getSourceFolderFullPath();
if (folderPath != null && !folderPath.isPrefixOf(filePath)) {
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
// check if folder exists
IPath folderPath = filePath.removeLastSegments(1).makeRelative();
IResource folder = getWorkspaceRoot().findMember(folderPath);
if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.FolderDoesNotExist", folderPath)); //$NON-NLS-1$
return status;
}