1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Fix bug 159173, improved validation and error reporting.

This commit is contained in:
Ken Ryall 2007-02-11 17:07:04 +00:00
parent 7a0a8bd1f8
commit 554bab40b6

View file

@ -71,6 +71,8 @@ public class ImportExecutablePageTwo extends WizardPage {
private AbstractImportExecutableWizard wizard; private AbstractImportExecutableWizard wizard;
private boolean shouldUpdateButtons = true;
public ImportExecutablePageTwo(AbstractImportExecutableWizard wizard) { public ImportExecutablePageTwo(AbstractImportExecutableWizard wizard) {
super("ImportExecutablePageTwo"); super("ImportExecutablePageTwo");
this.wizard = wizard; this.wizard = wizard;
@ -96,6 +98,7 @@ public class ImportExecutablePageTwo extends WizardPage {
} }
public void checkExecutableSettings() { public void checkExecutableSettings() {
shouldUpdateButtons = false;
if (isCreateNewProjectSelected) { if (isCreateNewProjectSelected) {
String defaultName = getDefaultProjectName(); String defaultName = getDefaultProjectName();
if (defaultName.length() > 0) { if (defaultName.length() > 0) {
@ -106,48 +109,14 @@ public class ImportExecutablePageTwo extends WizardPage {
existingProjectName.setText(defaultName); existingProjectName.setText(defaultName);
existingProjectButton.setSelection(true); existingProjectButton.setSelection(true);
newProjectButton.setSelection(false); newProjectButton.setSelection(false);
checkExistingProjectName();
} else { } else {
newProjectName.setText(defaultName); newProjectName.setText(defaultName);
checkNewProjectName();
} }
setLaunchConfigurationName(defaultName); setLaunchConfigurationName(defaultName);
} }
} }
} updateControls();
shouldUpdateButtons = true;
protected void checkExistingProjectName() {
ICProject project = getExistingCProject();
setErrorMessage(null);
setPageComplete(project != null);
if (project == null) {
setErrorMessage(Messages.ImportExecutablePageTwo_BadProjectName);
}
}
protected void checkLaunchConfigurationName() {
String newName = configurationName.getText();
setErrorMessage(null);
if (isCreateLaunchConfigurationSelected) {
setPageComplete(newName.length() > 0);
if (newName.length() == 0) {
setErrorMessage(Messages.ImportExecutablePageTwo_EnterLaunchConfig);
}
}
}
protected void checkNewProjectName() {
String newName = newProjectName.getText().trim();
setErrorMessage(null);
setPageComplete(newName.length() > 0);
if (newName.length() == 0) {
setErrorMessage(Messages.ImportExecutablePageTwo_EnterProjectName);
}
ICProject cProject = CoreModel.getDefault().getCModel().getCProject(
newName);
if (cProject.exists()) {
setErrorMessage(Messages.ImportExecutablePageTwo_ProjectAlreadyExists);
}
} }
protected ICProject chooseCProject() { protected ICProject chooseCProject() {
@ -190,7 +159,6 @@ public class ImportExecutablePageTwo extends WizardPage {
newProjectButton.addSelectionListener(new SelectionAdapter() { newProjectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
isCreateNewProjectSelected = newProjectButton.getSelection(); isCreateNewProjectSelected = newProjectButton.getSelection();
checkNewProjectName();
updateControls(); updateControls();
} }
}); });
@ -202,7 +170,7 @@ public class ImportExecutablePageTwo extends WizardPage {
newProjectName.addModifyListener(new ModifyListener() { newProjectName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
checkNewProjectName(); updateControls();
} }
}); });
@ -226,7 +194,6 @@ public class ImportExecutablePageTwo extends WizardPage {
existingProjectButton.addSelectionListener(new SelectionAdapter() { existingProjectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
isCreateNewProjectSelected = !newProjectButton.getSelection(); isCreateNewProjectSelected = !newProjectButton.getSelection();
checkExistingProjectName();
updateControls(); updateControls();
} }
}); });
@ -238,7 +205,7 @@ public class ImportExecutablePageTwo extends WizardPage {
existingProjectName.addModifyListener(new ModifyListener() { existingProjectName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
checkExistingProjectName(); updateControls();
} }
}); });
@ -281,7 +248,6 @@ public class ImportExecutablePageTwo extends WizardPage {
isCreateLaunchConfigurationSelected = createLaunch isCreateLaunchConfigurationSelected = createLaunch
.getSelection(); .getSelection();
setLaunchConfigurationName(configurationName.getText().trim()); setLaunchConfigurationName(configurationName.getText().trim());
checkLaunchConfigurationName();
updateControls(); updateControls();
} }
}); });
@ -310,7 +276,7 @@ public class ImportExecutablePageTwo extends WizardPage {
configurationName.addModifyListener(new ModifyListener() { configurationName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
checkLaunchConfigurationName(); updateControls();
} }
}); });
@ -406,7 +372,7 @@ public class ImportExecutablePageTwo extends WizardPage {
private void setLaunchConfigurationName(String defaultName) { private void setLaunchConfigurationName(String defaultName) {
configurationName.setText(DebugPlugin.getDefault().getLaunchManager() configurationName.setText(DebugPlugin.getDefault().getLaunchManager()
.generateUniqueLaunchConfigurationNameFrom(defaultName)); .generateUniqueLaunchConfigurationNameFrom(defaultName));
checkLaunchConfigurationName(); updateControls();
} }
protected void updateControls() { protected void updateControls() {
@ -419,5 +385,42 @@ public class ImportExecutablePageTwo extends WizardPage {
configTypes.setEnabled(isCreateLaunchConfigurationSelected); configTypes.setEnabled(isCreateLaunchConfigurationSelected);
configurationName.setEnabled(isCreateLaunchConfigurationSelected); configurationName.setEnabled(isCreateLaunchConfigurationSelected);
configurationNameLabel.setEnabled(isCreateLaunchConfigurationSelected); configurationNameLabel.setEnabled(isCreateLaunchConfigurationSelected);
if (shouldUpdateButtons )
getContainer().updateButtons();
} }
public boolean isPageComplete() {
setErrorMessage(null);
if (isCreateNewProjectSelected()) {
if (getNewProjectName().length() == 0) {
setErrorMessage(Messages.ImportExecutablePageTwo_EnterProjectName);
return false;
}
ICProject cProject = CoreModel.getDefault().getCModel().getCProject(getNewProjectName());
if (cProject.exists()) {
setErrorMessage(Messages.ImportExecutablePageTwo_ProjectAlreadyExists);
return false;
}
} else if (!isCreateNewProjectSelected()) {
ICProject project = getExistingCProject();
if (project == null) {
setErrorMessage(Messages.ImportExecutablePageTwo_BadProjectName);
return false;
}
}
if (isCreateLaunchConfigurationSelected() && getNewConfigurationName().length() == 0) {
setErrorMessage(Messages.ImportExecutablePageTwo_EnterLaunchConfig);
return false;
}
return super.isPageComplete();
}
} }