More refactoring (added early returns)

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Philip Knoblauch
2016-10-04 10:16:08 +02:00
parent fa3cee62bf
commit 8c7af7d28d
3 changed files with 22 additions and 13 deletions

View File

@@ -92,9 +92,12 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
}
private static Collection<? extends SuggestToken> getLogicalOperatorSuggestion(final String rsqlQuery) {
final int currentQueryLength = rsqlQuery.length();
// only return and/or suggestion when there is a space at the end
if (!rsqlQuery.endsWith(" ")) {
return Collections.emptyList();
}
if (rsqlQuery.endsWith(" ")) {
final int currentQueryLength = rsqlQuery.length();
// only return and/or suggestion when there is a space at the end
final Collection<String> tokenImages = TokenDescription.getTokenImage(TokenDescription.LOGICAL_OP);
final List<SuggestToken> logicalOps = new ArrayList<>(tokenImages.size());
for (final String tokenImage : tokenImages) {

View File

@@ -379,10 +379,14 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void onSearchIconClick() {
if (!queryTextField.isValidationError()) {
queryTextField.showValidationInProgress();
queryTextField.getExecutor().execute(queryTextField.new StatusCircledAsync(UI.getCurrent()));
if (queryTextField.isValidationError()) {
return;
}
queryTextField.showValidationInProgress();
queryTextField.getExecutor().execute(queryTextField.new StatusCircledAsync(UI.getCurrent()));
}
@Override

View File

@@ -54,14 +54,16 @@ public class AutoCompleteTextFieldConnector extends AbstractExtensionConnector {
@Override
public void showSuggestions(final SuggestionContextDto suggestContext) {
select.clearItems();
if (suggestContext != null) {
final List<SuggestTokenDto> suggestions = suggestContext.getSuggestions();
if (suggestions != null && !suggestions.isEmpty()) {
select.addItems(suggestions, textFieldWidget, panel, rpc);
panel.showRelativeTo(textFieldWidget);
select.moveSelectionDown();
return;
}
if (suggestContext == null) {
panel.hide();
return;
}
final List<SuggestTokenDto> suggestions = suggestContext.getSuggestions();
if (suggestions != null && !suggestions.isEmpty()) {
select.addItems(suggestions, textFieldWidget, panel, rpc);
panel.showRelativeTo(textFieldWidget);
select.moveSelectionDown();
return;
}
panel.hide();
}