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) { private static Collection<? extends SuggestToken> getLogicalOperatorSuggestion(final String rsqlQuery) {
final int currentQueryLength = rsqlQuery.length(); if (!rsqlQuery.endsWith(" ")) {
// only return and/or suggestion when there is a space at the end return Collections.emptyList();
}
if (rsqlQuery.endsWith(" ")) { 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 Collection<String> tokenImages = TokenDescription.getTokenImage(TokenDescription.LOGICAL_OP);
final List<SuggestToken> logicalOps = new ArrayList<>(tokenImages.size()); final List<SuggestToken> logicalOps = new ArrayList<>(tokenImages.size());
for (final String tokenImage : tokenImages) { for (final String tokenImage : tokenImages) {

View File

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

View File

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