mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 05:15:43 +02:00
Bug 326105 - MakeFile Project with Existing Code wizard got issues
This commit is contained in:
parent
12f2b8f8d5
commit
7ce1c8fa8b
5 changed files with 90 additions and 26 deletions
|
@ -28,7 +28,7 @@
|
||||||
category="org.eclipse.cdt.ui.newCWizards"
|
category="org.eclipse.cdt.ui.newCWizards"
|
||||||
class="org.eclipse.cdt.managedbuilder.ui.wizards.NewMakeProjFromExisting"
|
class="org.eclipse.cdt.managedbuilder.ui.wizards.NewMakeProjFromExisting"
|
||||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||||
icon="icons/obj16/convert-normal.gif"
|
icon="icons/elcl16/newmngcc_app.gif"
|
||||||
id="org.eclipse.cdt.ui.wizards.NewMakeFromExisting"
|
id="org.eclipse.cdt.ui.wizards.NewMakeFromExisting"
|
||||||
name="%NewMakeFromExisting.name"
|
name="%NewMakeFromExisting.name"
|
||||||
project="true">
|
project="true">
|
||||||
|
|
|
@ -161,7 +161,7 @@ public class Messages extends NLS {
|
||||||
public static String NewConfiguration_label_group;
|
public static String NewConfiguration_label_group;
|
||||||
public static String NewConfiguration_label_name;
|
public static String NewConfiguration_label_name;
|
||||||
public static String NewConfiguration_label_warning;
|
public static String NewConfiguration_label_warning;
|
||||||
public static String NewMakeProjFromExisting_0;
|
public static String NewMakeProjFromExisting_wizard_title;
|
||||||
public static String NewMakeProjFromExisting_1;
|
public static String NewMakeProjFromExisting_1;
|
||||||
public static String NewMakeProjFromExistingPage_0;
|
public static String NewMakeProjFromExistingPage_0;
|
||||||
public static String NewMakeProjFromExistingPage_1;
|
public static String NewMakeProjFromExistingPage_1;
|
||||||
|
|
|
@ -137,7 +137,7 @@ MBSWizardHandler_0=At least one toolchain should be selected
|
||||||
CMainWizardPage_1=Show project types and toolchains only if they are supported on the platform
|
CMainWizardPage_1=Show project types and toolchains only if they are supported on the platform
|
||||||
AbstractCWizard_0=Empty Project
|
AbstractCWizard_0=Empty Project
|
||||||
|
|
||||||
NewMakeProjFromExisting_0=Import Existing Code
|
NewMakeProjFromExisting_wizard_title=New Project
|
||||||
NewMakeProjFromExisting_1=Importing Existing Code
|
NewMakeProjFromExisting_1=Importing Existing Code
|
||||||
NewMakeProjFromExistingPage_0=Import Existing Code
|
NewMakeProjFromExistingPage_0=Import Existing Code
|
||||||
NewMakeProjFromExistingPage_1=Import Existing Code
|
NewMakeProjFromExistingPage_1=Import Existing Code
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||||
setWindowTitle(Messages.NewMakeProjFromExisting_0);
|
setWindowTitle(Messages.NewMakeProjFromExisting_wizard_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,10 +20,14 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
import org.eclipse.jface.wizard.WizardPage;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -51,6 +55,14 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
IWorkspaceRoot root;
|
IWorkspaceRoot root;
|
||||||
List tcList;
|
List tcList;
|
||||||
Map<String, IToolChain> tcMap = new HashMap<String, IToolChain>();
|
Map<String, IToolChain> tcMap = new HashMap<String, IToolChain>();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the user entered a non-empty string in the project name field. In that state, we avoid
|
||||||
|
* automatically filling the project name field with the directory name (last segment of the location) he
|
||||||
|
* has entered.
|
||||||
|
*/
|
||||||
|
boolean projectNameSetByUser;
|
||||||
|
|
||||||
protected NewMakeProjFromExistingPage() {
|
protected NewMakeProjFromExistingPage() {
|
||||||
super(Messages.NewMakeProjFromExistingPage_0);
|
super(Messages.NewMakeProjFromExistingPage_0);
|
||||||
|
@ -88,18 +100,77 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
projectName.addModifyListener(new ModifyListener() {
|
projectName.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
validateProjectName();
|
validatePage();
|
||||||
|
if (getProjectName().isEmpty()) {
|
||||||
|
projectNameSetByUser = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Note that the modify listener gets called not only when the user enters text but also when we
|
||||||
|
// programatically set the field. This listener only gets called when the user modifies the field
|
||||||
|
projectName.addKeyListener(new KeyAdapter() {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
projectNameSetByUser = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the contents of the page, setting the page error message and Finish button state accordingly
|
||||||
|
*
|
||||||
|
* @since 8.1
|
||||||
|
*/
|
||||||
|
protected void validatePage() {
|
||||||
|
// Don't generate an error if project name or location is empty, but do disable Finish button.
|
||||||
|
String msg = null;
|
||||||
|
boolean complete = true; // ultimately treated as false if msg != null
|
||||||
|
|
||||||
|
String name = getProjectName();
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
complete = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.PROJECT);
|
||||||
|
if (!status.isOK()) {
|
||||||
|
msg = status.getMessage();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IProject project = root.getProject(name);
|
||||||
|
if (project.exists()) {
|
||||||
|
msg = Messages.NewMakeProjFromExistingPage_4;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg == null) {
|
||||||
|
String loc = getLocation();
|
||||||
|
if (loc.isEmpty()) {
|
||||||
|
complete = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final File file= new File(loc);
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
// Set the project name to the directory name but not if the user has supplied a name
|
||||||
|
// (bugzilla 368987)
|
||||||
|
if (!projectNameSetByUser && !name.equals(file.getName())) {
|
||||||
|
projectName.setText(file.getName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg = Messages.NewMakeProjFromExistingPage_8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setErrorMessage(msg);
|
||||||
|
setPageComplete((msg == null) && complete);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Replaced by {@link #validatePage()} */
|
||||||
|
@Deprecated
|
||||||
public void validateProjectName() {
|
public void validateProjectName() {
|
||||||
String name = projectName.getText();
|
validatePage();
|
||||||
IProject project = root.getProject(name);
|
|
||||||
if (project.exists())
|
|
||||||
setErrorMessage(Messages.NewMakeProjFromExistingPage_4);
|
|
||||||
else
|
|
||||||
setErrorMessage(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSourceSelector(Composite parent) {
|
public void addSourceSelector(Composite parent) {
|
||||||
|
@ -115,10 +186,10 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
location.addModifyListener(new ModifyListener() {
|
location.addModifyListener(new ModifyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
validateSource();
|
validatePage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
validateSource();
|
validatePage();
|
||||||
|
|
||||||
Button browse = new Button(group, SWT.NONE);
|
Button browse = new Button(group, SWT.NONE);
|
||||||
browse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
|
browse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
|
||||||
|
@ -139,17 +210,10 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Replaced by {@link #validatePage()} */
|
||||||
|
@Deprecated
|
||||||
void validateSource() {
|
void validateSource() {
|
||||||
File file= new File(location.getText());
|
validatePage();
|
||||||
if (file.isDirectory()) {
|
|
||||||
setErrorMessage(null);
|
|
||||||
// Set the project name to the directory name but not if a
|
|
||||||
// name has already been specified (bugzilla 368987)
|
|
||||||
if (projectName.getText().isEmpty()) {
|
|
||||||
projectName.setText(file.getName());
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
setErrorMessage(Messages.NewMakeProjFromExistingPage_8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLanguageSelector(Composite parent) {
|
public void addLanguageSelector(Composite parent) {
|
||||||
|
@ -177,7 +241,7 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
group.setText(Messages.NewMakeProjFromExistingPage_10);
|
group.setText(Messages.NewMakeProjFromExistingPage_10);
|
||||||
|
|
||||||
tcList = new List(group, SWT.SINGLE);
|
tcList = new List(group, SWT.SINGLE | SWT.BORDER);
|
||||||
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
tcList.add(Messages.NewMakeProjFromExistingPage_11);
|
tcList.add(Messages.NewMakeProjFromExistingPage_11);
|
||||||
|
|
||||||
|
@ -197,11 +261,11 @@ public class NewMakeProjFromExistingPage extends WizardPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectName() {
|
public String getProjectName() {
|
||||||
return projectName.getText();
|
return projectName.getText().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location.getText();
|
return location.getText().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isC() {
|
public boolean isC() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue