Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorLeo Treggiari2005-09-09 02:33:49 +0000
committerLeo Treggiari2005-09-09 02:33:49 +0000
commit8a7ca5b2aa5cb9b5453b6d24749c81da9f442827 (patch)
tree78e583a2f9e6aa27227c55fab32e432688fbcb26 /build
parentd616526e79ab3e7bc85fc672c8b85e46610566f3 (diff)
downloadorg.eclipse.cdt-8a7ca5b2aa5cb9b5453b6d24749c81da9f442827.tar.gz
org.eclipse.cdt-8a7ca5b2aa5cb9b5453b6d24749c81da9f442827.tar.xz
org.eclipse.cdt-8a7ca5b2aa5cb9b5453b6d24749c81da9f442827.zip
Fix bugs with validating configuration names
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java16
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java17
2 files changed, 26 insertions, 7 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
index a43ee052c06..b7d8d0b7dc1 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
@@ -469,6 +469,10 @@ public class NewConfigurationDialog extends StatusDialog {
* @return <I>true</i> is the name is a valid directory name with no whitespaces
*/
private boolean validateName(String name) {
+ // Names must be at least one character in length
+ if (name.trim().length() == 0)
+ return false;
+
// Iterate over the name checking for bad characters
char[] chars = name.toCharArray();
// No whitespaces at the start of a name
@@ -503,14 +507,18 @@ public class NewConfigurationDialog extends StatusDialog {
private void validateState() {
StatusInfo status= new StatusInfo();
String currentName = configName.getText();
- int nameLength = currentName.length();
- // Make sure the name is not a duplicate
- if (nameLength == 0) {
- // Not an error
+ // Trim trailing whitespace
+ while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
+ currentName = currentName.substring(0, currentName.length()-1);
+ }
+ // Make sure that the name is at least one character in length
+ if (currentName.length() == 0) {
+ // No error message, but cannot select OK
status.setError(""); //$NON-NLS-1$
} else if(clone ? definedConfigs.length == 0 : defaultConfigs.length == 0) {
// Not an error
status.setError(""); //$NON-NLS-1$
+ // Make sure the name is not a duplicate
} else if (isDuplicateName(currentName)) {
status.setError(ManagedBuilderUIMessages.getFormattedString(DUPLICATE, currentName));
} else if (isSimilarName(currentName)) {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java
index 75f2d7d65c2..4664f2dcd03 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java
@@ -248,6 +248,10 @@ public class RenameConfigurationDialog extends StatusDialog {
* @return <I>true</i> is the name is a valid directory name with no whitespaces
*/
private boolean validateName(String name) {
+ // Names must be at least one character in length
+ if (name.trim().length() == 0)
+ return false;
+
// Iterate over the name checking for bad characters
char[] chars = name.toCharArray();
// No whitespaces at the start of a name
@@ -282,9 +286,16 @@ public class RenameConfigurationDialog extends StatusDialog {
private void validateState() {
StatusInfo status= new StatusInfo();
String currentName = configName.getText();
- int nameLength = currentName.length();
- // Make sure the name is not a duplicate
- if (isDuplicateName(currentName)) {
+ // Trim trailing whitespace
+ while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
+ currentName = currentName.substring(0, currentName.length()-1);
+ }
+ // Make sure that the name is at least one character in length
+ if (currentName.length() == 0) {
+ // No error message, but cannot select OK
+ status.setError(""); //$NON-NLS-1$
+ // Make sure the name is not a duplicate
+ } else if (isDuplicateName(currentName)) {
status.setError(ManagedBuilderUIMessages.getFormattedString(DUPLICATE, currentName));
} else if (isSimilarName(currentName)) {
status.setError(ManagedBuilderUIMessages.getFormattedString(CASE, currentName));

Back to the top