mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 475625 - Allow user to have empty variable names
When the user selects the second wizard page was forced to use a no empty variable name, however it's possible the parameter won't be used and the user wants to have a matching signature. Removed the check. The parameter name is still automatically set if the user click directly on "Finish" button. Change-Id: I665220b72d7b04b4bc89ffd5d764771cdfa8b243 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
244c43f414
commit
76bf5b4e7c
1 changed files with 15 additions and 6 deletions
|
@ -66,6 +66,14 @@ public class ValidatingLabeledTextField extends Composite {
|
|||
public void hasNoErrors() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Is an empty input allowed?
|
||||
* @return True if empty string is allowed, false otherwise
|
||||
*/
|
||||
public boolean emptyAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text the new value of the field
|
||||
* @return whether the value is valid or not
|
||||
|
@ -138,17 +146,18 @@ public class ValidatingLabeledTextField extends Composite {
|
|||
public void checkField() {
|
||||
String newName = textField.getText();
|
||||
|
||||
boolean isEmpty = (newName.length() == 0);
|
||||
boolean isEmpty = newName.length() == 0;
|
||||
|
||||
boolean isNameAlreadyInUse = nameAlreadyInUse(textField, newName);
|
||||
boolean isValid = validator.isValidInput(newName);
|
||||
boolean isKeyword = NameHelper.isKeyword(newName);
|
||||
boolean isValidName = NameHelper.isValidLocalVariableName(newName);
|
||||
boolean isEmptyAllowed = validator.emptyAllowed();
|
||||
boolean isValidName = (isEmpty && isEmptyAllowed) || NameHelper.isValidLocalVariableName(newName);
|
||||
|
||||
boolean isOk = isValid && !isNameAlreadyInUse && !isEmpty && !isKeyword && isValidName;
|
||||
boolean isOk = isValid && !isNameAlreadyInUse && !isKeyword && isValidName;
|
||||
if (isOk) {
|
||||
setErrorStatus(EMPTY_STRING);
|
||||
} else if (isEmpty) {
|
||||
} else if (isEmpty && !isEmptyAllowed) {
|
||||
setErrorStatus(validator.errorMessageForEmptyField());
|
||||
} else if (!isValid || !isValidName) {
|
||||
setErrorStatus(validator.errorMessageForInvalidInput());
|
||||
|
@ -159,8 +168,8 @@ public class ValidatingLabeledTextField extends Composite {
|
|||
}
|
||||
validationStatus.put(textField, isOk);
|
||||
|
||||
if (validationStatus.values().contains(Boolean.FALSE) || isEmpty || isNameAlreadyInUse || isKeyword
|
||||
|| !isValidName) {
|
||||
if (validationStatus.values().contains(Boolean.FALSE) || (isEmpty && !isEmptyAllowed)
|
||||
|| isNameAlreadyInUse || isKeyword || !isValidName) {
|
||||
validator.hasErrors();
|
||||
} else {
|
||||
validator.hasNoErrors();
|
||||
|
|
Loading…
Add table
Reference in a new issue