1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug #43020 : allow creation project on a basis of existing one.

This commit is contained in:
Oleg Krasilnikov 2007-05-21 17:14:59 +00:00
parent f65ab9e7f1
commit 9e61b19314
3 changed files with 28 additions and 7 deletions

View file

@ -542,6 +542,8 @@ StdProjectTypeHandler.2=Default
StdProjectTypeHandler.3=creation Make project: IBuilder is null
CDTConfigWizardPage.0=Select configurations
CDTCommonProjectWizard.0=Old project will be overridden
CDTCommonProjectWizard.1=Existing project settings will be overridden.\nImport feature can be used instead to preserve old settings.\nOK to override ?
NewModelProjectWizard.0=CDT project
NewModelProjectWizard.1=Create CDT project of selected type
NewModelProjectWizard.2=C++ project

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.ui.wizards;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -30,6 +31,7 @@ import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
@ -113,6 +115,22 @@ implements IExecutableExtension, IWizardWithMemory
if (newProject != null && isChanged())
clearProject();
if (newProject == null) {
existingPath = false;
IPath p = fMainPage.getProjectLocation();
if (p == null) p = ResourcesPlugin.getWorkspace().getRoot().getLocation();
p = p.append(fMainPage.getProjectName());
File f = p.toFile();
if (f.exists() && f.isDirectory()) {
if (p.append(".project").toFile().exists()) { //$NON-NLS-1$
if (!
MessageDialog.openConfirm(getShell(),
UIMessages.getString("CDTCommonProjectWizard.0"), //$NON-NLS-1$
UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$
)
return null;
}
existingPath = true;
}
savedHandler = fMainPage.h_selected;
savedHandler.saveState();
lastProjectName = fMainPage.getProjectName();
@ -212,7 +230,6 @@ implements IExecutableExtension, IWizardWithMemory
*/
public IProject createIProject(final String name, final IPath location) throws CoreException{
if (newProject != null) return newProject;
existingPath = (location != null && location.toFile().exists());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();

View file

@ -336,9 +336,9 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
bad = false;
}
if (bad) {
if (bad) { // Sic !! Show message but allow creation.
setErrorMessage(UIMessages.getString("CMainWizardPage.10")); //$NON-NLS-1$
return false;
return true;
}
}
@ -347,11 +347,13 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
if (p == null) p = ResourcesPlugin.getWorkspace().getRoot().getLocation();
File f = p.append(getProjectName()).toFile();
if (f.exists()) {
if (f.isDirectory())
setErrorMessage(UIMessages.getString("CMainWizardPage.6")); //$NON-NLS-1$
else
if (f.isDirectory()) {
setErrorMessage(UIMessages.getString("CMainWizardPage.7")); //$NON-NLS-1$
return false;
return true; // Sic !! Show message but allow creation.
} else {
setErrorMessage(UIMessages.getString("CMainWizardPage.6")); //$NON-NLS-1$
return false;
}
}
}